Artifacts Associated With Ticket 2981154
Ticket change [ae9057143b] (rid 101663) by dgp on 2010-04-02 15:11:17:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Using the 8.5.8 sources (so I rule out more recent commits) and with a --enable-threads --enable-symbols build, I sometimes see a segfault at the end of async.test. I managed to catch it in gdb: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x40646b90 (LWP 825)] 0x0814bcfb in Tcl_MutexLock (mutexPtr=0x10) at /home/dgp/cvs/tcl8.5/unix/../unix/tclUnixThrd.c:519 519 if (*mutexPtr == NULL) { (gdb) bt #0 0x0814bcfb in Tcl_MutexLock (mutexPtr=0x10) at /home/dgp/cvs/tcl8.5/unix/../unix/tclUnixThrd.c:519 #1 0x08067c88 in Tcl_AsyncMark (async=0x8e0b274) at /home/dgp/cvs/tcl8.5/unix/../generic/tclAsync.c:167 #2 0x08054baf in AsyncThreadProc (clientData=0x8e16c18) at /home/dgp/cvs/tcl8.5/unix/../generic/tclTest.c:936 #3 0x080c1fbd in NewThreadProc (clientData=0xbbe12f0) at /home/dgp/cvs/tcl8.5/unix/../generic/tclEvent.c:1487 #4 0x0088773b in start_thread () from /lib/libpthread.so.0 #5 0x007dccfe in clone () from /lib/libc.so.6 Don't know whether this is another symptom of Tcl Bug 2869384. I believe that when the segfault happens, it is always after test async-4.3 has failed (Tcl Bug 1774689). However, async-4.3 can also fail without a segfault following. - foundin initialized to: "obsolete: 8.5.8"
- is_private initialized to: "0"
- priority initialized to: "9 Immediate"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "49. Threading"
- title initialized to: "async.test segfault"
- type initialized to: "Bug"
Ticket change [ef702920a4] (rid 108994) by dgp on 2011-04-14 22:39:52:
- icomment:
FWIW, I just saw this one again on trunk tip.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [60313d4ccc] (rid 115950) by ferrieux on 2011-08-19 04:44:01:
- icomment:
Quoting mistachkin in 1774689: To see this test fail reliably, simply change the line in proc hang3 from: [string repeat {;incr i;} 1500000] to: [string repeat {;incr i;} 150] doing this I get it reliably on trunk tip. - login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [03e70ef982] (rid 119903) by ferrieux on 2011-08-19 05:14:34:
- icomment:
I also get non-systematic segfault, but there're news: the non-segfaulting is correlated to Tcl_AsyncMark *not* being called. It's an iff. So there's a race condition that hides the segfault by not letting the thread go far enough.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [763be709d3] (rid 105543) by ferrieux on 2011-08-19 05:51:33:
- icomment:
Probability of segfault gets close to 1 with 15 instead of 150 in the modified loop. Theory: the asyncmark may happen: (a) during the loopless stretch of BC (b) during the main interp's teardown (c) not at all, since the process has exited Clearly only the gray area (b) segfaults. I guess during teardown things are not as airtight as during normal operation.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [bb2ec2a979] (rid 129436) by ferrieux on 2011-08-19 05:59:27:
- icomment:
Come to think of it, as mistachkin noted, the whole test setup is geared towards (a), ie there's absolutely no effort to be teardown-proof. So playing with too small stretches of BC is completely out of the intended range. Hence, I believe the proper fix is to increase the size of the loopless BC stretch in that test.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [4b60dc48b8] (rid 126702) by ferrieux on 2011-08-19 13:56:14:
- icomment:
To clarify: in the comments below, "teardown" is the test's cleanup part which does Tcl_AsyncDelete. So maybe there's a race condition between Tcl_AsyncDelete and the real invocation of an already Tcl_AsyncMark'ed handler. In case this is true, it ought to be fixed generically rather than pulled under the rug.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [ea5a020825] (rid 103361) by ferrieux on 2011-08-19 13:59:59:
- icomment:
OK, the previous hypothesis is proven wrong: the bug is really tclTest.c's lack of protection of its interthread data access. Will add a mutex.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [e797b0a458] (rid 104487) by ferrieux on 2011-08-19 21:04:34:
- closedate changed to: "2011-08-19T14:04:34"
- closer changed to: "ferrieux"
- icomment:
Fixed in HEAD, by (1) mutex-protecting the process-wide static holding the list of TestAsyncHandlers (along with the unique id counter ;-), and (2) moving from a pointer-to-struct to an integer-id API in async handlers. The mutex-protected lookup by id is done twice: once in the alien thread, as a prerequisite to calling AsyncMark with the proper token; and once in the async handler, since the handler may have been deleted between the two. Passes test suite. Verified that even wit the 1500000->15 tweak, even though the test consistently fails, it never segfaults.
- login: "ferrieux"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "ferrieux"
Ticket change [3784d0241d] (rid 107292) by dgp on 2011-08-19 21:35:40:
- icomment:
Is the patch suitable for backport to 8.5.11 ?
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [6d78635a7e] (rid 128703) by ferrieux on 2011-08-19 22:25:22:
- icomment:
Backported.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment: