Hi,<br><br> I thought I would have a try at fixing the problem in AutoFlushWr with the little program below.<br>Alas I couldnt get a grip on it so maybe you guys could shed some light.<br><br>This was with RC4 and on an amd64 linux box.<br>
<br>It invariably crashes in FileWr.Seek where some invariant seems to be<br>awry so obviously the worker thread created in AutoFlushWr is hitting or causing<br>a race condition. Probably easily fixed.<br><br>The thing that intrigued me was that most of the time running it did not cause<br>
the normal crash sequence and I had to ctrl-c to get back to the bash prompt<br>which judging from the stack trace something in the threads area is amiss.<br><br><br>Regards Peter<br><br><br><br>MODULE Main;<br><br>IMPORT FileWr,Wr,Rd,AutoFlushWr,Stdio,IO,Fmt,Thread;<br>
<br>VAR<br> myout := NEW(AutoFlushWr.T).init(Stdio.stdout);<br><br>BEGIN<br> FOR i := 0 TO 10000 DO<br> Wr.PutText(myout,Fmt.Int(i) & "\n");<br> END;<br><br>(*<br> Thread.Pause(1.0D0);<br> IO.Put("hit enter to end\n");<br>
*)<br><br> EVAL Rd.GetChar(Stdio.stdin);<br><br>END Main.<br><br><br><br><br><br>... some iterations and<br>5155<br>5156<br>5157<br>5158<br>5159<br>5160<br>5161<br>5162<br>5163<br>5164<br>5165<br>5166<br>5167<br>5168<br>
5169<br>5170<br>5171<br>5172<br>5173<br>5174<br><br><br>***<br>*** runtime error:<br>*** Exception "FileWr.Error" not in RAISES list<br>*** file "../src/rw/FileWr.m3", line 81<br>***<br><br><br>Program received signal SIGABRT, Aborted.<br>
0x00007f1a8b6beed5 in raise () from /lib/libc.so.6<br><br>(m3gdb) thread apply all bt<br><br>Thread 3 (Thread 1106278736 (LWP 5197)):<br>#0 0x00007f1a8b9ead29 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0<br>
#1 0x00007f1a8bef8d4f in ThreadPThread__pthread_cond_wait (cond=0x24d0170,<br> mutex=0x24d0770) at ../src/thread/PTHREAD/ThreadPThreadC.c:326<br>#2 0x00007f1a8bef1ce0 in XWait (self=16_00000000024f2a48, m=16_00000000024ef030,<br>
c=16_00000000024ef0b8, alertable=FALSE)<br> at ../src/thread/PTHREAD/ThreadPThread.m3:238<br>#3 0x00007f1a8bef214d in Wait (m=16_00000000024ef030, c=16_00000000024ef0b8)<br> at ../src/thread/PTHREAD/ThreadPThread.m3:280<br>
#4 0x00007f1a8c9e2c62 in Worker (cl=16_00000000024f2a38)<br> at ../src/rw/AutoFlushWr.m3:211<br>#5 0x00007f1a8bef4447 in RunThread (me=16_00000000024d0a40)<br> at ../src/thread/PTHREAD/ThreadPThread.m3:589<br>#6 0x00007f1a8bef4140 in ThreadBase (param=16_00000000024d0a40)<br>
at ../src/thread/PTHREAD/ThreadPThread.m3:565<br>#7 0x00007f1a8b9e6fc7 in start_thread () from /lib/libpthread.so.0<br>#8 0x00007f1a8b75c5ad in clone () from /lib/libc.so.6<br>#9 0x0000000000000000 in ?? ()<br><br>
Thread 2 (Thread 139752010405600 (LWP 5194)):<br>#0 0x00007f1a8b6beed5 in raise () from /lib/libc.so.6<br>#1 0x00007f1a8b6c03f3 in abort () from /lib/libc.so.6<br>#2 0x00007f1a8beef0ff in Crash () at ../src/runtime/POSIX/RTOS.m3:20<br>
#3 0x00007f1a8bee2b1d in Crash (msg=NIL) at ../src/runtime/common/RTProcess.m3:65<br>#4 0x00007f1a8bedffba in EndError (crash=TRUE) at ../src/runtime/common/RTError.m3:118<br>#5 0x00007f1a8bedfcb2 in MsgS (file=16_00007f1a8ccc84d8, line=81,<br>
msgA=16_00007f1a8c12dda8, msgB=16_000000000250e078, msgC=16_00007f1a8c12ddf0)<br> at ../src/runtime/common/RTError.m3:40<br>#6 0x00007f1a8bee048d in Crash (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=TRUE, rte=16_00007f1a8c124ca0)<br>
at ../src/runtime/common/RTException.m3:79<br>#7 0x00007f1a8bee0186 in DefaultBackstop (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=FALSE) at ../src/runtime/common/RTException.m3:41<br>
#8 0x00007f1a8bee0076 in InvokeBackstop (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=FALSE) at ../src/runtime/common/RTException.m3:25<br>
#9 0x00007f1a8bef03db in Raise (act=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END) at ../src/runtime/ex_frame/RTExFrame.m3:29<br>
---Type <return> to continue, or q <return> to quit---<br>#10 0x00007f1a8bee01f6 in DefaultBackstop (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=TRUE) at ../src/runtime/common/RTException.m3:47<br>
#11 0x00007f1a8bee0076 in InvokeBackstop (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=TRUE) at ../src/runtime/common/RTException.m3:25<br>
#12 0x00007f1a8bef04e8 in Raise (act=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END) at ../src/runtime/ex_frame/RTExFrame.m3:51<br>
#13 0x00007f1a8bec791f in Raise (ex=16_00007f1a8ccc8380, arg=NIL,<br> module=16_00007f1a8ccc8540, line=81) at ../src/runtime/common/RTHooks.m3:79<br>#14 0x00007f1a8c9dd8f4 in Seek (wr=16_00000000024e9448, n=24765)<br> at ../src/rw/FileWr.m3:81<br>
#15 0x00007f1a8c9e0b0e in Seek (wr=16_00000000024ef0d8, n=24765)<br> at ../src/rw/AutoFlushWr.m3:106<br>#16 0x00007f1a8c9d684e in PutStringDefault (wr=16_00000000024ef0d8, a=<br> {'5','1','7','5','\n'}) at ../src/rw/Wr.m3:193<br>
#17 0x00007f1a8c9d5b4c in FastPutText (wr=16_00000000024ef0d8, t=16_000000000250e040)<br> at ../src/rw/Wr.m3:105<br>#18 0x00007f1a8c9d598a in PutText (wr=16_00000000024ef0d8, t=16_000000000250e040)<br> at ../src/rw/Wr.m3:93<br>
#19 0x000000000040108c in Main (mode=1) at ../src/Main.m3:10<br>#20 0x00007f1a8bedf12b in RunMainBody (m=16_00000000006016c0)<br> at ../src/runtime/common/RTLinker.m3:399<br>#21 0x00007f1a8bede312 in AddUnitI (m=16_00000000006016c0)<br>
at ../src/runtime/common/RTLinker.m3:113<br>#22 0x00007f1a8bede3b0 in AddUnit (b={"Main_M3", Declared at: ../src/Main.m3:8})<br> at ../src/runtime/common/RTLinker.m3:122<br>#23 0x0000000000400f2c in main (argc=1, argv=0x7fff6d396f08, envp=0x7fff6d396f18)<br>
at _<a href="http://m3main.mc:4">m3main.mc:4</a><br>#24 0x00007f1a8b6ab1a6 in __libc_start_main () from /lib/libc.so.6<br>#25 0x0000000000400e29 in _start ()<br><br>Thread 1 (LWP 5194):<br>#0 0x00007f1a8b6beed5 in raise () from /lib/libc.so.6<br>
#1 0x00007f1a8b6c03f3 in abort () from /lib/libc.so.6<br>#2 0x00007f1a8beef0ff in Crash () at ../src/runtime/POSIX/RTOS.m3:20<br>#3 0x00007f1a8bee2b1d in Crash (msg=NIL) at ../src/runtime/common/RTProcess.m3:65<br>#4 0x00007f1a8bedffba in EndError (crash=TRUE) at ../src/runtime/common/RTError.m3:118<br>
#5 0x00007f1a8bedfcb2 in MsgS (file=16_00007f1a8ccc84d8, line=81,<br> msgA=16_00007f1a8c12dda8, msgB=16_000000000250e078, msgC=16_00007f1a8c12ddf0)<br> at ../src/runtime/common/RTError.m3:40<br>#6 0x00007f1a8bee048d in Crash (a=<br>
---Type <return> to continue, or q <return> to quit---<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=TRUE, rte=16_00007f1a8c124ca0)<br>
at ../src/runtime/common/RTException.m3:79<br>#7 0x00007f1a8bee0186 in DefaultBackstop (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=FALSE) at ../src/runtime/common/RTException.m3:41<br>
#8 0x00007f1a8bee0076 in InvokeBackstop (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=FALSE) at ../src/runtime/common/RTException.m3:25<br>
#9 0x00007f1a8bef03db in Raise (act=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END) at ../src/runtime/ex_frame/RTExFrame.m3:29<br>
#10 0x00007f1a8bee01f6 in DefaultBackstop (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=TRUE) at ../src/runtime/common/RTException.m3:47<br>
#11 0x00007f1a8bee0076 in InvokeBackstop (a=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END, raises=TRUE) at ../src/runtime/common/RTException.m3:25<br>
#12 0x00007f1a8bef04e8 in Raise (act=<br> RECORD exception = 16_00007f1a8c124ca0; arg = 16_000000000000000d; module = 16_00007f1a8ccc8540; line = 81; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007f1a8ccc8380; un_arg = NIL; END) at ../src/runtime/ex_frame/RTExFrame.m3:51<br>
#13 0x00007f1a8bec791f in Raise (ex=16_00007f1a8ccc8380, arg=NIL,<br> module=16_00007f1a8ccc8540, line=81) at ../src/runtime/common/RTHooks.m3:79<br>#14 0x00007f1a8c9dd8f4 in Seek (wr=16_00000000024e9448, n=24765)<br> at ../src/rw/FileWr.m3:81<br>
#15 0x00007f1a8c9e0b0e in Seek (wr=16_00000000024ef0d8, n=24765)<br> at ../src/rw/AutoFlushWr.m3:106<br>#16 0x00007f1a8c9d684e in PutStringDefault (wr=16_00000000024ef0d8, a=<br> {'5','1','7','5','\n'}) at ../src/rw/Wr.m3:193<br>
#17 0x00007f1a8c9d5b4c in FastPutText (wr=16_00000000024ef0d8, t=16_000000000250e040)<br> at ../src/rw/Wr.m3:105<br>#18 0x00007f1a8c9d598a in PutText (wr=16_00000000024ef0d8, t=16_000000000250e040)<br> at ../src/rw/Wr.m3:93<br>
#19 0x000000000040108c in Main (mode=1) at ../src/Main.m3:10<br>#20 0x00007f1a8bedf12b in RunMainBody (m=16_00000000006016c0)<br> at ../src/runtime/common/RTLinker.m3:399<br>#21 0x00007f1a8bede312 in AddUnitI (m=16_00000000006016c0)<br>
at ../src/runtime/common/RTLinker.m3:113<br>#22 0x00007f1a8bede3b0 in AddUnit (b={"Main_M3", Declared at: ../src/Main.m3:8})<br>---Type <return> to continue, or q <return> to quit---<br> at ../src/runtime/common/RTLinker.m3:122<br>
#23 0x0000000000400f2c in main (argc=1, argv=0x7fff6d396f08, envp=0x7fff6d396f18)<br> at _<a href="http://m3main.mc:4">m3main.mc:4</a><br>#24 0x00007f1a8b6ab1a6 in __libc_start_main () from /lib/libc.so.6<br>#25 0x0000000000400e29 in _start ()<br>
#0 0x00007f1a8b6beed5 in raise () from /lib/libc.so.6<br>(m3gdb) <br><br><br>Now why is the stack trace duplicated for Thread 1 and Thread 2 and also<br>why is there that last line #0 0x00007f1a8b6beed5 in raise () from /lib/libc.so.6 in the<br>
last frame? The first and last frame are duplicated. Havent seen it in other stack traces.<br>Maybe something wrong with my setup?<br><br><br>running once more we get<br><br>....... some iterations<br>4311<br>4312<br>4313<br>
4314<br>4315<br>4316<br>4317<br>4318<br><br><br>***<br>*** runtime error:<br>*** Exception "FileWr.Error" not in RAISES list<br>*** file "../src/rw/FileWr.m3", line 81<br>***<br><br>OK here I had to ctrl-c it since it is hung<br>
<br><br>^C<br>Program received signal SIGINT, Interrupt.<br>0x00007fd82e657384 in __lll_lock_wait () from /lib/libpthread.so.0<br>(m3gdb) thread apply all bt<br><br>Thread 3 (Thread 1113143632 (LWP 5200)):<br>#0 0x00007fd82e654d29 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0<br>
#1 0x00007fd82eb62d4f in ThreadPThread__pthread_cond_wait (cond=0x19a9170,<br> mutex=0x19a9770) at ../src/thread/PTHREAD/ThreadPThreadC.c:326<br>#2 0x00007fd82eb5bce0 in XWait (self=16_00000000019caa48, m=16_00000000019c7030,<br>
c=16_00000000019c70b8, alertable=FALSE)<br> at ../src/thread/PTHREAD/ThreadPThread.m3:238<br>#3 0x00007fd82eb5c14d in Wait (m=16_00000000019c7030, c=16_00000000019c70b8)<br> at ../src/thread/PTHREAD/ThreadPThread.m3:280<br>
#4 0x00007fd82f64cc62 in Worker (cl=16_00000000019caa38)<br> at ../src/rw/AutoFlushWr.m3:211<br>#5 0x00007fd82eb5e447 in RunThread (me=16_00000000019a9a40)<br> at ../src/thread/PTHREAD/ThreadPThread.m3:589<br>#6 0x00007fd82eb5e140 in ThreadBase (param=16_00000000019a9a40)<br>
at ../src/thread/PTHREAD/ThreadPThread.m3:565<br>#7 0x00007fd82e650fc7 in start_thread () from /lib/libpthread.so.0<br>#8 0x00007fd82e3c65ad in clone () from /lib/libc.so.6<br>#9 0x0000000000000000 in ?? ()<br><br>
Thread 2 (Thread 140566490150624 (LWP 5198)):<br>#0 0x00007fd82e657384 in __lll_lock_wait () from /lib/libpthread.so.0<br>#1 0x00007fd82e652bf0 in _L_lock_102 () from /lib/libpthread.so.0<br>../../gdb/gdb/dwarf2-frame.c:490: internal-error: Unknown CFI encountered.<br>
A problem internal to GDB has been detected,<br>further debugging may prove unreliable.<br>Quit this debugging session? (y or n) <br><br><br>Is this a problem with m3gdb? <br><br>Running this program without the debugger more likely than not will produce a hung program, so <br>
I suspect some threading problem. That lll_lock_wait is definitely suspicious.<br><br><br>