[M3devel] pthread assertion failure exiting formsedit
Rodney M. Bates
rodney_bates at lcwb.coop
Sun Jun 28 04:20:34 CEST 2015
Tony, please review/comment on my analysis, as this kind if code is very delicate,
and this is the first time I have looked at it.
This is in ThreadPThread.m3.
It is possible that thread th, waiting on an M3 Condition variable in XWait,
line 239, by actually waiting on pthreads condition variable self.cond,
can be both Signaled and Alerted, before it reacquires self.mutex. Either of
Signal or Alert will pthread_cond_signal self.cond, but the other can acquire
self.mutex before th reacquires it, after the first pthread_cond_signal.
When th finally gets self.mutex, both self.alerted and self.waitingOn=NIL.
I propose to wrap lines 216 thru' 227 inside IF self.waitingOn # NIL THEN ...
Presumably, if both Signal and Alert have happened, we want to raise Alerted,
rather than just wake up th.
On 06/26/2015 11:03 AM, Rodney M. Bates wrote:
> This reproduces for me on AMD64_LINUX. As I recall, mika's thread test had passed
> on this target. I am rerunning it, but it has gone all night and is still going.
>
> self.waitingOn and c.mutex are revealed only in ThreadPThread.m3, so there is some hope this can be
> diagnosed by looking therein. Everything shallower in the backtrace (debugger's "down" = closer to
> top of stack--confusing, to me) looks irrelevant.
>
>
>
>
> ***
> *** runtime error:
> *** <*ASSERT*> failed.
> *** file "../src/thread/PTHREAD/ThreadPThread.m3", line 216
> ***
>
>
> Program received signal SIGABRT, Aborted.
> [Switching to Thread 140370469975808 (LWP 17456)]
> 0x00007faaa45a9f77 in raise () from /lib/x86_64-linux-gnu/libc.so.6
> (m3gdb) up
> #1 0x00007faaa45ad5e8 in abort () from /lib/x86_64-linux-gnu/libc.so.6
> (m3gdb) up
> #2 0x00007faaa4bc3f68 in Cstdlib__abort () at ../src/C/Common/CstdlibC.c:21
> 21 M3WRAP_RETURN_VOID(Cstdlib__abort, abort, (void), ())
> Current language: auto; currently c
> (m3gdb) up
> #3 0x00007faaa4bba364 in Crash () at ../src/runtime/POSIX/RTOS.m3:20
> 20 Cstdlib.abort ();
> Current language: auto; currently Modula-3
> (m3gdb) bt
> #0 0x00007faaa45a9f77 in raise () from /lib/x86_64-linux-gnu/libc.so.6
> #1 0x00007faaa45ad5e8 in abort () from /lib/x86_64-linux-gnu/libc.so.6
> #2 0x00007faaa4bc3f68 in Cstdlib__abort () at ../src/C/Common/CstdlibC.c:21
> #3 0x00007faaa4bba364 in Crash () at ../src/runtime/POSIX/RTOS.m3:20
> #4 0x00007faaa4baf027 in Crash (msg=NIL) at ../src/runtime/common/RTProcess.m3:65
> #5 0x00007faaa4bad11b in EndError (crash=TRUE) at ../src/runtime/common/RTError.m3:118
> #6 0x00007faaa4bace2d in MsgS (file=16_00007faaa4e033c7, line=216, msgA=16_00007faaa4dfeb70, msgB=16_00007faaa4df9900,
> msgC=16_00007faaa4dfeb70) at ../src/runtime/common/RTError.m3:40
> #7 0x00007faaa4bad577 in Crash (a=
> RECORD exception = 16_00007faaa4df9760; arg = 16_000000000000000c; module = 16_00007faaa4e19160; line = 216; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007faaa4df9760; un_arg = NIL; END, raises=FALSE, rte=16_00007faaa4df9760)
> at ../src/runtime/common/RTException.m3:79
> #8 0x00007faaa4bad26f in DefaultBackstop (a=
> RECORD exception = 16_00007faaa4df9760; arg = 16_000000000000000c; module = 16_00007faaa4e19160; line = 216; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007faaa4df9760; un_arg = NIL; END, raises=FALSE) at ../src/runtime/common/RTException.m3:39
> #9 0x00007faaa4bad1bf in InvokeBackstop (a=
> RECORD exception = 16_00007faaa4df9760; arg = 16_000000000000000c; module = 16_00007faaa4e19160; line = 216; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007faaa4df9760; un_arg = NIL; END, raises=FALSE) at ../src/runtime/common/RTException.m3:25
> #10 0x00007faaa4bbad0a in Raise (act=
> RECORD exception = 16_00007faaa4df9760; arg = 16_000000000000000c; module = 16_00007faaa4e19160; line = 216; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007faaa4df9760; un_arg = NIL; END) at ../src/runtime/ex_frame/RTExFrame.m3:85
> #11 0x00007faaa4bad31c in DefaultBackstop (a=
> RECORD exception = 16_00007faaa4df9760; arg = 16_000000000000000c; module = 16_00007faaa4e19160; line = 216; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007faaa4df9760; un_arg = NIL; END, raises=FALSE) at ../src/runtime/common/RTException.m3:47
> #12 0x00007faaa4bad1bf in InvokeBackstop (a=
> RECORD exception = 16_00007faaa4df9760; arg = 16_000000000000000c; module = 16_00007faaa4e19160; line = 216; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007faaa4df9760; un_arg = NIL; END, raises=FALSE) at ../src/runtime/common/RTException.m3:25
> #13 0x00007faaa4bbad0a in Raise (act=
> RECORD exception = 16_00007faaa4df9760; arg = 16_000000000000000c; module = 16_00007faaa4e19160; line = 216; pc = NIL; info0 = NIL; info1 = NIL; un_except = 16_00007faaa4df9760; un_arg = NIL; END) at ../src/runtime/ex_frame/RTExFrame.m3:85
> #14 0x00007faaa4b9782b in ReportFault (module=16_00007faaa4e19160, info=6912) at ../src/runtime/common/RTHooks.m3:111
> #15 0x00007faaa4bc17e1 in _m3_fault (arg=6912) from /usr/local/cm3-uniboot/bin/../lib/libm3core.so.5
> #16 0x00007faaa4bbc9c7 in XWait (self=16_0000000001856130, m=16_0000000001906318, c=16_0000000001906340, alertable=TRUE)
> at ../src/thread/PTHREAD/ThreadPThread.m3:216
> #17 0x00007faaa4bbcc4d in AlertWait (m=16_0000000001906318, c=16_0000000001906340) at ../src/thread/PTHREAD/ThreadPThread.m3:247
> #18 0x000000000040656b in EditorRootApply (root=16_00000000015d93e8) at ../src/FormsEditVBT.m3:272
> #19 0x00007faaa4bbe71e in RunThread (me=16_0000000001856130) at ../src/thread/PTHREAD/ThreadPThread.m3:518
> #20 0x00007faaa4bbe3d2 in ThreadBase (param=16_0000000001856130) at ../src/thread/PTHREAD/ThreadPThread.m3:491
> #21 0x00007faaa4942f6e in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
> #22 0x00007faaa466d9cd in clone () from /lib/x86_64-linux-gnu/libc.so.6
> (m3gdb) frame 16
> #16 0x00007faaa4bbc9c7 in XWait (self=16_0000000001856130, m=16_0000000001906318, c=16_0000000001906340, alertable=TRUE)
> at ../src/thread/PTHREAD/ThreadPThread.m3:216
> 216 <*ASSERT self.waitingOn = c.mutex*>
> (m3gdb) info arg
> self = 16_0000000001856130
> m = (*16_0000000001906318*) OBJECT mutex = 16_0000000001854cb0; holder = NIL; waiters = NIL; END
> c = (*16_0000000001906340*) OBJECT mutex = 16_00007faa84000e20; waiters = NIL; name = 16_0000000000615b90; END
> alertable = TRUE
> (m3gdb) info loc
> prev = 16_00007faa8bffeb90
> next = 16_00007faaa4bc1db6
> (m3gdb) p self^
> $13 = RECORD frame = 16_00007faa8bffed00; mutex = 16_0000000001854dd0; cond = 16_0000000001854ce0; alerted = FALSE; waitingOn = NIL;
> nextWaiter = NIL; next = 16_00007faa8c00e530; prev = 16_000000000183b9f0; handle = 16_00007faa8bfff700;
> stackbase = 16_00007faa8bffee68; context = NIL; state = Started; slot = 6; floatState = RECORD behavior = {Trap, Trap, Trap, Trap,
> Trap, Trap, Trap}; sticky = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}; END; heapState = RECORD inCritical = 0;
> pool = RECORD note = Allocated; pure = FALSE; page = 16_0000000001760000; next = 16_00000000017600c8; limit = 16_0000000001770000;
> END; END; END
> (m3gdb) p c.name
> $14 = (*16_0000000000615b90*) Cannot access memory at address 0x615b90
> (m3gdb) p self.waitingOn
> $15 = NIL
> (m3gdb) p c.mutex
> $16 = 16_00007faa84000e20
> (m3gdb)
>
>
> On a previous run, after more poking around in the debugger, I had:
>
> (m3gdb) p c.name
> $12 = (*16_0000000000615b90*) "all editors closed"
>
> on 06/22/2015 08:50 PM, Jay K wrote:
>
>
>> Every time I exit formsedit on MacOS X:
>>
>>
>> (gdb) run
>> Starting program: /cm3/bin/formsedit
>> Reading symbols for shared libraries +++++++++++++++++++++..... done
>>
>>
>> ***
>> *** runtime error:
>> *** <*ASSERT*> failed.
>> *** file "../src/thread/PTHREAD/ThreadPThread.m3", line 216
>> ***
>>
>>
>> Program received signal SIGABRT, Aborted.
>> 0x940181ae in semaphore_wait_signal_trap ()
>> (gdb) bt
>> #0 0x940181ae in semaphore_wait_signal_trap ()
>> #1 0x9404a1c6 in _pthread_cond_wait ()
>> #2 0x9408f449 in pthread_cond_wait ()
>> #3 0x0093aaee in ThreadPThread__pthread_cond_wait (i=0x1400830, j=0x1400800) at ../src/thread/PTHREAD/ThreadPThreadC.c:459
>> #4 0x00935ade in ThreadPThread__XWait (self=0x14007a0, m=0x7e0084, c=0x1543644, alertable=0 '\0') at ../src/thread/PTHREAD/ThreadPThread.m3:239
>> #5 0x00937a54 in ThreadPThread__XJoin (self=0x14007a0, t=0x1543628, alertable=0 '\0') at ../src/thread/PTHREAD/ThreadPThread.m3:581
>> #6 0x00937b5c in Thread__Join (t=0x1543628) at ../src/thread/PTHREAD/ThreadPThread.m3:593
>> #7 0x00014392 in FormsEdit__main () at ../src/FormsEdit.m3:52
>> #8 0x0001451d in FormsEdit_M3 (mode=1) at ../src/FormsEdit.m3:62
>> #9 0x00927175 in RTLinker__RunMainBody (m=0x15c40) at ../src/runtime/common/RTLinker.m3:408
>> #10 0x00926601 in RTLinker__AddUnitI (m=0x15c40) at ../src/runtime/common/RTLinker.m3:115
>> #11 0x0092667c in RTLinker__AddUnit (b=0x143a8) at ../src/runtime/common/RTLinker.m3:124
>>
>>
>> WITH r = pthread_mutex_lock(self.mutex) DO <*ASSERT r=0*> END;
>> LOOP
>> IF alertable AND self.alerted THEN
>> self.alerted := FALSE;
>> <*ASSERT self.waitingOn = c.mutex*>
>>
>> NOTE: The Modula-3 assert does not break into the debugger. There is a later problem in pthread_cond_wait that does. This is with the gcc backend.
>>
>>
>> - Jay
>>
>
--
Rodney Bates
rodney.m.bates at acm.org
More information about the M3devel
mailing list