flightaware/tcllauncher — pull request #3 by gahr (2014-09-25 18:56:20+00:00)
Title: Link against threads library to avoid deadlocking.

This sample code deadlocks if tcllauncher is not linked against
the threading library:

if {[fork]} { exit }
after 3000 { exit }
vwait _forever

The parent immediately quits, the child remains hanged in its
[exit] and never run to completion. The following stack trace
shows how Tcl_ConditionWait is stuck waiting for the notifier to
notify the condition variable notifierCV. I conjecture - but this
might well be a far fetched hypothesis - that when tcllauncher is
not linked against the threads library, the notifier doesn't run
inside its own thread, and thus the cv is never notified.

3 0x0000000800c0452d in Tcl_ConditionWait (condPtr=0x800e6cb08 , mutexPtr=0x800e6caf0 , timePtr=0x0) at tclUnixThrd.c:551
4 0x0000000800c061af in Tcl_FinalizeNotifier (clientData=0x80205a010) at tclUnixNotfy.c:405
5 0x0000000800b9ec75 in TclFinalizeNotifier () at generic/tclNotify.c:192
6 0x0000000800b36d60 in Tcl_FinalizeThread () at generic/tclEvent.c:1298
7 0x0000000800b36ac0 in Tcl_Exit (status=0) at generic/tclEvent.c:986
8 0x0000000800a61238 in Tcl_ExitObjCmd (dummy=0x0, interp=0x802076010, objc=1, objv=0x802084770) at generic/tclCmdAH.c:833
9 0x0000000800a51511 in Dispatch (data=0x8022fa628, interp=0x802076010, result=0) at generic/tclBasic.c:4359
10 0x0000000800a4d11c in TclNRRunCallbacks (interp=0x802076010, result=0, rootPtr=0x0) at generic/tclBasic.c:4392
11 0x0000000800a4ce39 in Tcl_EvalObjv (interp=0x802076010, objc=3, objv=0x8020842f0, flags=2097168) at generic/tclBasic.c:4123
12 0x0000000800a4e958 in TclEvalEx (interp=0x802076010, script=0x80234b010
"#\n# tcllauncher.tcl - tcl code that tcllauncher uses to do its thing\n#\n\npackage require Tclx\n\n
#\n# this is the code that gets called when Tcl launches because the\n# tcllauncher \"version\" of Tcl jimmies"...,
numBytes=2149, flags=0, line=76, clNextOuter=0x0, outerScript=0x80234b010
"#\n# tcllauncher.tcl - tcl code that tcllauncher uses to do its thing\n#\n\npackage require Tclx\n\n
#\n# this is the code that gets called when Tcl launches because the\n# tcllauncher \"vers ion\" of Tcl jimmies"...) at generic/tclBasic.c:5261
13 0x0000000800b8ab23 in Tcl_FSEvalFileEx (interp=0x802076010, pathPtr=0x80212f330, encodingName=0x0) at generic/tclIOUtil.c:1815
14 0x0000000800b961aa in Tcl_MainEx (argc=-1, argv=0x802017050, appInitProc=0x4009e0 , interp=0x802076010) at generic/tclMain.c:417
15 0x00000000004009d5 in main (argc=2, argv=0x802017040) at unix/tclAppInit.c:109