[M3devel] A RT failure in ThreadPThread.Alert]

Tony Hosking hosking at cs.purdue.edu
Fri Sep 21 19:30:11 CEST 2007


waitCond should be valid for all live threads.  I'm assuming you are  
invoking Thread.Alert on a thread that is no longer alive.  Indeed,  
you can see from the debug output that the thread has completed.  I  
suppose we could silently ignore the alert for a completed thread,  
but I suspect this reveals some deeper problem with your code --  
should you really issue an alert to a thread that is incapable of  
receiving it.  I wonder if the alert flag is already set for that  
thread.  In any case I suppose we can simply check for NIL in Alert.   
I've checked in code to do this.

On Sep 21, 2007, at 12:57 PM, Rodney M. Bates wrote:

>
>
>
> I got a runtime failure in ThreadPThread.Alert, on this line:
>
> ---------------------------------------------------------------------- 
> ------------
> PROCEDURE Alert (t: T) =
>   BEGIN
>     WITH r = Upthread.mutex_lock(cm) DO <*ASSERT r=0*> END;
>     t.alerted := TRUE;
> --> WITH r = Upthread.cond_signal(t.waitCond^) DO <*ASSERT r=0*> END;
>     WITH r = Upthread.mutex_unlock(cm) DO <*ASSERT r=0*> END;
>   END Alert;
> ---------------------------------------------------------------------- 
> --------------
> Here, t.waitCond is NIL and being dereferenced.  I tried just  
> making this
> silently tolerate NIL t.waitCond, and it made the immediate symptom  
> go away,
> with no other immediately apparent problems.  But this seems not  
> very likely
> to be right.  For one thing, there are several other places that  
> assume
> waitCond is non-NIL.  And, a quick reading revealed only one place  
> that creates
> this object, which always allocates waitCond, no places that change  
> it, and
> T is opaque and revealed only in this module.  How could this happen?
>
>
> Here is a bit of debugger output: The display of t is at the bottom.
> ---------------------------------------------------------------------- 
> --------------
>
>
> ***
> *** runtime error:
> ***    Attempt to reference an illegal memory location.
> ***    file "../src/thread/PTHREAD/ThreadPThread.m3", line 304
> ***
>
> ------------------ EXCEPTION HANDLER STACK ---------------------
> 0xb5eb71dc TRY-EXCEPT  {0xa893a19c}
> 0xb5eb72bc LOCK  mutex = 0xb436e0e4
> 0xb5eb731c LOCK  mutex = 0xb6ebbc44
> ----------------------------------------------------------------
> [Switching to Thread -1242858592 (LWP 8289)]
>
> Breakpoint 2, 0x08126a38 in InnerRuntimeFailureDialog () at  
> AssertDevel.m3:272
> 272     ; PROCEDURE InnerRuntimeFailureDialog ( )
> (m3gdb) bt
> #0  0x08126a38 in InnerRuntimeFailureDialog () at AssertDevel.m3:272
> #1  0x08126c89 in RuntimeFailureDialog () at AssertDevel.m3:314
> #2  0xb72e596f in InvokeExitors () at RTProcess.m3:40
> #3  0xb72e59e3 in Crash (msg=NIL) at RTProcess.m3:61
> #4  0xb72e3648 in EndError (crash=TRUE) at RTError.m3:115
> #5  0xb72e3389 in MsgS (file=16_b731de58, line=304,  
> msgA=16_b7318068, msgB=16_b73126d4,
>     msgC=16_b7318068) at RTError.m3:40
> #6  0xb72e3a46 in Crash (a=
>     RECORD exception = 16_b73124c0; arg = 16_0000000c; module =  
> 16_b731e020; line = 304; pc = NIL;
> info0 = NIL; info1 = NIL; un_except = 16_b73124c0; un_arg =  
> 16_00000004;  END, raises=FALSE,
>     rte=16_b73124c0) at RTException.m3:79
> #7  0xb72e3770 in DefaultBackstop (a=
>     RECORD exception = 16_b73124c0; arg = 16_0000000c; module =  
> 16_b731e020; line = 304; pc = NIL;
> info0 = NIL; info1 = NIL; un_except = 16_b73124c0; un_arg =  
> 16_00000004;  END, raises=FALSE)
>     at RTException.m3:39
> #8  0xb72e36d4 in InvokeBackstop (a=
>     RECORD exception = 16_b73124c0; arg = 16_0000000c; module =  
> 16_b731e020; line = 304; pc = NIL;
> info0 = NIL; info1 = NIL; un_except = 16_b73124c0; un_arg =  
> 16_00000004;  END, raises=FALSE)
>     at RTException.m3:25
> #9  0xb72f3397 in Raise (act=
>     RECORD exception = 16_b73124c0; arg = 16_0000000c; module =  
> 16_b731e020; line = 304; pc = NIL;
> info0 = NIL; info1 = NIL; un_except = 16_b73124c0; un_arg =  
> 16_00000004;  END) at RTExFrame.m3:29
> #10 0xb72e3810 in DefaultBackstop (a=
>     RECORD exception = 16_b73124c0; arg = 16_0000000c; module =  
> 16_b731e020; line = 304; pc = NIL;
> info0 = NIL; info1 = NIL; un_except = 16_b73124c0; un_arg =  
> 16_00000004;  END, raises=FALSE)
>     at RTException.m3:47
> #11 0xb72e36d4 in InvokeBackstop (a=
>     RECORD exception = 16_b73124c0; arg = 16_0000000c; module =  
> 16_b731e020; line = 304; pc = NIL;
> info0 = NIL; info1 = NIL; un_except = 16_b73124c0; un_arg =  
> 16_00000004;  END, raises=FALSE)
>     at RTException.m3:25
> #12 0xb72f3397 in Raise (act=
>     RECORD exception = 16_b73124c0; arg = 16_0000000c; module =  
> 16_b731e020; line = 304; pc = NIL;
> info0 = NIL; info1 = NIL; un_except = 16_b73124c0; un_arg =  
> 16_00000004;  END) at RTExFrame.m3:29
> #13 0xb72cb223 in ReportFault (module=16_b731e020, info=9732) at  
> RTHooks.m3:110
> #14 0xb72fb697 in _m3_fault (arg=9732) from /usr/local/cm3/pkg/ 
> m3core/LINUXLIBC6/libm3core.so.5
> #15 0xb72f5cd7 in Alert (t=16_b3a9bdc8) at ThreadPThread.m3:304
> #16 0xb7df741d in DisplayDir (v=16_b436e004) at FileBrowserVBT.m3:496
> #17 0xb7df4d83 in Refresh (v=16_b436e004) at FileBrowserVBT.m3:210
> #18 0xb7df5413 in Watcher (cl=16_b6ebbc9c) at FileBrowserVBT.m3:254
> #19 0xb72f76f5 in RunThread (me=16_08e1c518) at ThreadPThread.m3:538
> #20 0xb72f7403 in ThreadBase (param=16_08e1c518) at  
> ThreadPThread.m3:519
> #21 0xb707c540 in start_thread () from /lib/i686/libpthread.so.0
> #22 0xb6fef55e in clone () from /lib/i686/libc.so.6
> (m3gdb) frame 5
> #5  0xb72e3389 in MsgS (file=16_b731de58, line=304,  
> msgA=16_b7318068, msgB=16_b73126d4,
>     msgC=16_b7318068) at RTError.m3:40
> 40      RTError.m3: No such file or directory.
>         in RTError.m3
> (m3gdb) p msgA
> $1 = (*16_b7318068*) ""
> (m3gdb) p msgB
> $2 = (*16_b73126d4*) "Attempt to reference an illegal memory  
> location."
> (m3gdb) p msgC
> $3 = (*16_b7318068*) ""
> (m3gdb) frame 15
> #15 0xb72f5cd7 in Alert (t=16_b3a9bdc8) at ThreadPThread.m3:304
> 304     ThreadPThread.m3: No such file or directory.
>         in ThreadPThread.m3
> (m3gdb) p t
> $4 = (*16_b3a9bdc8*) OBJECT act = 16_08e94678; closure = NIL;  
> result = NIL; cond = 16_b3a9bdf4;
>     waitingOn = NIL; nextWaiter = NIL; waitCond = NIL; alerted =  
> TRUE; completed = TRUE;
>     joined = FALSE; id = 73;  END
> (m3gdb)
> --
> -------------------------------------------------------------
> Rodney M. Bates, retired assistant professor
> Dept. of Computer Science, Wichita State University
> Wichita, KS 67260-0083
> 316-978-3922
> rodney.bates at wichita.edu
>




More information about the M3devel mailing list