Artifacts Associated With Ticket 0b874c344d
Ticket change [f4281addbd] (rid 135730) by cmcc on 2013-11-23 18:33:55:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
I have a 2000 line script which invariably generates a SEGV on [info frame]. I don't know how to get you the script. Contact me for it, please.
- foundin initialized to: "8.6b1"
- is_private initialized to: "0"
- login: "cmcc"
- priority initialized to: "5 Medium"
- private_contact initialized to: "16910d69b11045755316a073070779a85cd9218f"
- resolution initialized to: "None"
- severity initialized to: "Critical"
- status initialized to: "Open"
- submitter initialized to: "cmcc"
- subsystem initialized to: "04. Async Events"
- title initialized to: "Tcl SEGV"
- type initialized to: "Bug"
Add attachment "H.tcl" [931d4bfb6f] (rid 135731) by cmcc on 2013-11-23 18:42:03.
Ticket change [5ab37fd4a6] (rid 135732) by cmcc on 2013-11-23 18:44:54:
- comment changed to:
Attached a 2000 line script which invariably generates a SEGV on [info frame] SEGV occurs in InfoFrameCmd() lines /* TODO - deal with overflow */ topLevel += corPtr->caller.cmdFramePtr->level; Where (gdb) p *corPtr $11 = {cmdPtr = 0xb6a1a78, eePtr = 0x9a2fab0, callerEEPtr = 0x9743b68, caller = {framePtr = 0x8055d70, varFramePtr = 0x8055d70, cmdFramePtr = 0x0, lineLABCPtr = 0x9a20110}, running = {framePtr = 0xb68f668, varFramePtr = 0xb68f668, cmdFramePtr = 0xb68f860, lineLABCPtr = 0x9a205d0}, lineLABCPtr = 0x9a205d0, stackLevel = 0xbffff05c, auxNumLevels = 3, nargs = -1} (gdb) p corPtr->caller $12 = {framePtr = 0x8055d70, varFramePtr = 0x8055d70, cmdFramePtr = 0x0, lineLABCPtr = 0x9a20110} (gdb) p corPtr->caller.cmdFramePtr $13 = (struct CmdFrame *) 0x0 - login: "cmcc"
- mimetype: "text/plain"
- comment changed to:
Ticket change [6fbd8d0a8f] (rid 135733) by cmcc on 2013-11-23 18:46:14:
- icomment:
(gdb) bt #0 0xb7e8cde6 in InfoFrameCmd (dummy=0x0, interp=0x8055770, objc=1, objv=0xb68f8b4) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclCmdIL.c:1174 #1 0xb7e734ef in Dispatch (data=0xada4b5c, interp=0x8055770, result=0) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclBasic.c:4335 #2 0xb7e78b4f in TclNRRunCallbacks (interp=interp@entry=0x8055770, result=0, rootPtr=rootPtr@entry=0x810d108) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclBasic.c:4368 #3 0xb7e7c68f in TclEvalObjEx (interp=interp@entry=0x8055770, objPtr=objPtr@entry=0xb688bc0, flags=flags@entry=131072, invoker=invoker@entry=0x0, word=word@entry=0) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclBasic.c:5934 #4 0xb7e7c6db in Tcl_EvalObjEx (interp=interp@entry=0x8055770, objPtr=0xb688bc0, flags=flags@entry=131072) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclBasic.c:5915 #5 0xb7f54508 in AfterProc (clientData=0x97e49b0) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclTimer.c:1191 #6 0xb7f54854 in TimerHandlerEventProc (evPtr=evPtr@entry=0x9a0ef40, flags=flags@entry=-3) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclTimer.c:593 #7 0xb7f31da3 in Tcl_ServiceEvent (flags=flags@entry=-3) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclNotify.c:670 #8 0xb7f3203e in Tcl_DoOneEvent (flags=flags@entry=-3) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclNotify.c:907 #9 0xb7ef12cc in Tcl_VwaitObjCmd (clientData=0x0, interp=0x8055770, objc=2, objv=0x805ca30) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclEvent.c:1408 #10 0xb7e734ef in Dispatch (data=0xac8d824, interp=0x8055770, result=0) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclBasic.c:4335 #11 0xb7e78b4f in TclNRRunCallbacks (interp=interp@entry=0x8055770, result=0, rootPtr=rootPtr@entry=0x0) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclBasic.c:4368 #12 0xb7e78c7f in Tcl_EvalObjv (interp=interp@entry=0x8055770, objc=objc@entry=3, objv=objv@entry=0x805c8e0, flags=flags@entry=2097168) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclBasic.c:4099 #13 0xb7e7a168 in TclEvalEx (interp=interp@entry=0x8055770, script=0x80b0808 "# H.tcl - light Httpd 1.1\nif {[info exists argv0] && ($argv0 eq [info script])} {\n apply {{} {\n\tset home [file dirname [file normalize [info script]]]\n\tlappend ::auto_path $home [file join [file di"..., numBytes=5472, flags=flags@entry=0, line=1876, line@entry=1, clNextOuter=clNextOuter@entry=0x0, outerScript=0x80b0808 "# H.tcl - light Httpd 1.1\nif {[info exists argv0] && ($argv0 eq [info script])} {\n apply {{} {\n\tset home [file dirname [file normalize [info script]]]\n\tlappend ::auto_path $home [file join [file di"...) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclBasic.c:5237 #14 0xb7f25221 in Tcl_FSEvalFileEx (interp=interp@entry=0x8055770, pathPtr=pathPtr@entry=0x8082030, encodingName=0x0) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclIOUtil.c:1809 #15 0xb7f2beab in Tcl_MainEx (argc=<optimised out>, argc@entry=2, argv=<optimised out>, argv@entry=0xbffff674, appInitProc=appInitProc@entry=0x8048790 <Tcl_AppInit>, interp=0x8055770) at /home/colin/Desktop/packages/tcl8.6.1/generic/tclMain.c:417 #16 0x0804868a in main (argc=2, argv=0xbffff674) at /home/colin/Desktop/packages/tcl8.6.1/unix/tclAppInit.c:84 (gdb) - login: "cmcc"
- mimetype: "text/plain"
- username: "BackTrace"
- icomment:
Ticket change [cc6b081807] (rid 135734) by miguel on 2013-11-23 23:46:35:
- assignee changed to: "aku"
- icomment:
I believe corPtr->caller.cmdFramePtr should never be NULL. How did this happen?
- login: "miguel"
- mimetype: "text/plain"
- username: "[email protected]"
Ticket change [46b2303656] (rid 135770) by dgp on 2013-11-25 17:32:50:
- icomment:
In case it's helpful, the demo script generates a SEGV starting with checkin 2012-04-02 13:13:11 1d6747e53fa1fc82 BAD CURRENT That's the implementation of TIP 396.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [45ece106ae] (rid 135771) by aku on 2013-11-25 17:55:39:
- icomment:
Thanks for bisecting. I just opened this bug and started to update my checkouts to investigate. So yes, having the bad commit should help.
- login: "aku"
- mimetype: "text/plain"
- icomment:
Ticket change [739df5982a] (rid 135772) by aku on 2013-11-25 18:09:05:
- icomment:
While my checkouts continue to update I looked over the changes made by [1d6747e53fa1fc82]. My current primary suspect is the call to "TclNRYieldObjCmd" at the end of "TclNRYieldToObjCmd", going from "clientData" to "INT2PTR(CORO_ACTIVATE_YIELDM))". ... Update complete, I can now build and actually start trialing.
- login: "aku"
- mimetype: "text/plain"
- icomment:
Ticket change [00c288b312] (rid 135773) by aku on 2013-11-25 18:20:48:
- icomment:
First, I can confirm dgp's finding that revision [1d6747e53fa1fc82] is where things go bad, with the previous revision being ok.
- login: "aku"
- mimetype: "text/plain"
- icomment:
Ticket change [a682344e3b] (rid 135774) by dgp on 2013-11-25 20:23:35:
- icomment:
Part of the sequence of events leading to the segfault is the SAVE_CONTEXT(corPtr->caller); around line 8740 or so in tclBasic.c (in the TIP 396 commit, in case the file has changed a lot since then). This is called at a time when iPtr->cmdFramePtr is NULL, which puts the NULL value in place which [info frame] later crashes on attempting to dereference.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [bd6a1cbec3] (rid 135775) by aku on 2013-11-25 20:51:14:
- icomment:
Interestingly enough, the other branch of the condition is where CORO_ACTIVATE_YIELDM is handled.
- login: "aku"
- mimetype: "text/plain"
- icomment:
Ticket change [8ad7165b4d] (rid 135779) by aku on 2013-11-29 18:16:43:
- icomment:
Possible fix on branch "bug-0b874c344d-ak-info-frame-coro". Revision [f8164c896c]. Committed. Pushed.
- login: "aku"
- mimetype: "text/plain"
- icomment:
Ticket change [b5c7d71ccb] (rid 135784) by dgp on 2013-12-03 15:10:22:
- icomment:
So the fix takes the perspective that the implementation of [info frame] failed to account for an unusual, but normal condition. This is in contrast to a perspective that (corPtr->caller.cmdFramePtr == NULL) was an invalid state and some bug was wrongly allowing it to occur. Accepting that, we should merge the fix to the trunk. Any prospects for crafting a test for the test suite that doesn't require a 2100 line script?
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [b90afbe102] (rid 135791) by aku on 2013-12-03 18:33:05:
- icomment:
> Perspective Yes. There was actually code in the function for dealing with a possible NULL in the main iPtr->cmdFramePtr already. Given this it was considered to be possible for such a NULL to wind up in the corPtr->caller.cmdFramePtr as well. > Merging Ok. > Test(s) While accepting the possibility of a NULL winding up in the coro cmdFrame I am not sure yet how it actually happens. So, from me I have no prospects of crafting the necessary test. And yes, I do wish that Colin had taken the time to reduce his script as much as possible.
- login: "aku"
- mimetype: "text/plain"
- icomment:
Ticket change [95660eb5dc] (rid 135792) by dgp on 2013-12-03 19:58:52:
- icomment:
Here's a much shorter demo script: proc a {} { after 0 [info coroutine] yield coroutine C c } proc b {} { yield info frame } proc c {} { tailcall B } after 0 { coroutine A a coroutine B b } vwait forever - login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [efc5301ba4] (rid 135793) by dgp on 2013-12-03 20:07:13:
- icomment:
Simpler still; no event loop required: proc a {} {yield; coroutine C c} proc b {} {yield; info frame} proc c {} {tailcall B} coroutine A a coroutine B b A - login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [a3ed36cac2] (rid 135794) by aku on 2013-12-03 20:11:04:
- icomment:
Thank you Don. That is very short and sweet. Will work on making that a test ASAP.
- login: "aku"
- mimetype: "text/plain"
- priority changed to: "8"
- icomment:
Ticket change [55ceeaad48] (rid 135797) by dgp on 2013-12-04 12:55:52:
- icomment:
Final entry: coroutine X coroutine Y info frame
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [1594a0f703] (rid 135798) by dgp on 2013-12-04 14:37:30:
- icomment:
A variant of that: coroutine X coroutine Y info frame 0 demonstrates that the proposed fix is not enough to solve the problem.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [1c34360184] (rid 135821) by dgp on 2013-12-05 20:47:00:
- icomment: "Draft fix checked into branch bug-0b874c344d."
- login: "dgp"
- mimetype: "text/plain"
Ticket change [50781ee15f] (rid 136070) by dgp on 2013-12-18 18:23:29:
- closedate changed to: "2456645.26630907"
- closer changed to: "dgp"
- icomment: "Much improved fix now merged to trunk."
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"