Artifacts Associated With Ticket 3062331
Ticket change [63f2216db6] (rid 92670) by pcmacdon on 2010-09-09 02:22:01:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
The script below crashes wish 8.5.9 and 8.5.8 (on Linux). # Crash script pack [ttk::button .b -textvariable Y] trace variable Y u "destroy .b" unset Y
- foundin initialized to: "obsolete: 8.5.9"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "pcmacdon"
- subsystem initialized to: "07. Variables"
- title initialized to: "segfault in var traces with ttk::button"
- type initialized to: "RFE"
Ticket change [d83348b4b2] (rid 107398) by pcmacdon on 2010-09-09 09:27:09:
- icomment:
Possibly related is ID: 2629338 Note, this may be due to the fact the handler is trying to remove the trace thats to be called next.
- login: "pcmacdon"
- mimetype: "text/plain"
- username: "pcmacdon"
- icomment:
Ticket change [0c45b2a7c5] (rid 114145) by dgp on 2010-10-04 22:56:34:
- assignee changed to: "dgp"
- priority changed to: "9 Immediate"
- subsystem changed to: "46. Traces"
Ticket change [af4af01f5a] (rid 97785) by dgp on 2010-10-12 23:53:24:
- icomment:
Program received signal SIGSEGV, Segmentation fault. 0x08223505 in Tcl_GetString (objPtr=0x83c8578) at /home/dgp/cvs/tcl-only/generic/tclObj.c:1625 1625 if (objPtr->typePtr->updateStringProc == NULL) { (gdb) up #1 0x080eeb9a in VarTraceProc (clientData=0x844eae8, interp=0x82e6768, name1=0x8454420 "Y", name2=0x0, flags=192) at /home/dgp/cvs/tk/unix/../generic/ttk/ttkTrace.c:42 42 name = Tcl_GetString(tracePtr->varnameObj); - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [d6704b6b58] (rid 123806) by dgp on 2010-10-12 23:57:00:
- icomment:
suggests an invalid state in tracePtr->varNameObj where both objPtr->bytes == NULL and objPtr->typePtr == NULL. Something somewhere is not following the rules.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [82d30b5dd8] (rid 117294) by dgp on 2010-10-13 00:00:14:
- assignee changed to: "jenglish"
- icomment:
That points the finger of blame at ttkTrace.c in Tk. I'll leave this item open for now in case we can close it quickly. If not, we should re-open in the Tk tracker.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
Ticket change [dd9af63d93] (rid 114701) by dgp on 2010-10-13 01:08:14:
- icomment:
Possibly a flaw still in Tcl_UntraceVar2() as well. The call to Tcl_UnsetVar2() is bailing out based on the flags set in the variable before it gets to the code that scans the activeVarPtr chain for presence of the trace that's getting unset.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [2173951573] (rid 130583) by jenglish on 2010-10-13 01:19:34:
- icomment:
Quick diagnosis indicates that this is the same problem as #2629338 -- the trace machinery is calling a VarTraceProc after it has been removed. Not sure what to do about this.
- login: "jenglish"
- mimetype: "text/plain"
- username: "jenglish"
- icomment:
Ticket change [8d47bf9edf] (rid 127902) by dgp on 2010-10-13 01:26:20:
- icomment:
I wanted to blame var reform for this, but the same test case also crashes Tcl/Tk 8.5a6 in what appears to be the same way.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [876301455c] (rid 131686) by dgp on 2010-10-13 02:08:27:
- icomment:
A lawyer could probably make a case that things are behaving "as documented" in the ACCESSING VARIABLE DURING TRACES section. During an unset operation, when unset traces fire, they see the variable (and all traces attached to it) as already gone. This means that those bits of code trying valiantly to tidy up by removing those unset traces that are no longer valid get turned into no-ops. Then they cannot remove these invalid trace routines before the unset operations launches them anyway and they crash. "As documented", true, but that just means we've documented a system that's completely unworkable. le sigh.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [4d11e1d8aa] (rid 127001) by dgp on 2010-10-13 02:08:28:
- assignee changed to: "dgp"
Ticket change [da6ba2d24b] (rid 107781) by dgp on 2010-10-13 21:46:07:
- icomment:
so, two perspectives on what's wrong here. 1) Tcl_UntraceVar() can be a no-op. Code that doesn't account for that can run into this trouble, but accounting for that is at best inconvenient, and possibly unworkably difficult. 2) Once an [unset] operations gets started, its set of unset traces is locked in place. You can't get rid of any of them, even if you know they will crash when run. Two ways of describing the same inherent brokenness in the unset trace model. :P - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [b612619dfb] (rid 125360) by dgp on 2011-06-15 01:38:32:
- closedate changed to: "2011-06-14T18:38:32"
- closer changed to: "dgp"
- icomment:
allow_comments - 1 Fixed for Ttk 8.5.10 +
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "dgp"
Ticket change [6f57840f9e] (rid 100301) by jenglish on 2011-06-15 03:13:57:
- icomment:
Note that the attempted fix (fossil commit ca3d9b7274) -- zero out tracePtr->varnameObj in Ttk_UntraceVariable() and test it in the trace callback -- is not completely correct, since tracePtr itself is freed (this will probably crash in a TCL_MEM_DEBUG build for example).
- login: "jenglish"
- mimetype: "text/plain"
- username: "jenglish"
- icomment:
Ticket change [92b005ee0d] (rid 120812) by jenglish on 2011-06-15 05:20:35:
- icomment:
I don't think the second fix (fossil e9e6f67c5b) fixes it either (check under valgrind) -- calling Tcl_Preserve()/Tcl_Release() in VarTraceProc() is too late, since tracePtr (VarTraceProc's clientData) has already been EventuallyFree()d by the time it gets there. Timeline is: script-level unset trace calls [destroy .b] .b's cleanup code calls Ttk_UntraceVariable, which frees the trace handle and (attempts to) remove the trace hook; trace hook gets called anyway, accessing freed memory.
- login: "jenglish"
- mimetype: "text/plain"
- username: "jenglish"
- icomment:
Ticket change [60d0f24ee7] (rid 92137) by jenglish on 2011-06-15 05:20:36:
- icomment:
allow_comments - 0
- login: "jenglish"
- mimetype: "text/plain"
- username: "jenglish"
- icomment:
Ticket change [2527fa544d] (rid 131238) by dgp on 2011-06-16 01:19:23:
- icomment:
Reverting failed patches.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "None"
- status changed to: "Open"
- username: "dgp"
- icomment:
Ticket change [be27127841] (rid 102026) by dgp on 2011-06-17 01:30:48:
- icomment:
Here's a related demo of the problem, using only the (testing) commands of Tcl, leaving out the Tk complication: testlink create {*}[lrepeat 14 1] trace add variable int unset {testlink delete; #} unset int This does not crash, but it does leave the variable "int" linked to its C counterpart while all the other special variables of the [testlink] command properly have their links broken by [testlink delete]. - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [fecc27a47f] (rid 108648) by dgp on 2011-06-17 03:28:43:
- icomment:
See new Tk branch bug-3062331 for a new attempt to fix this in Ttk.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [7812581380] (rid 89886) by jenglish on 2011-06-17 06:38:16:
- icomment:
Looks like [e1302383c5] ought to do the trick. (My only suggestion would be to add a note mentioning this bug #, to explain why the extra machinery bypassing Tcl_UntraceVar is necessary.) (Also also: the comment in Tcl_UntraceVar2() claiming that "The code below makes it possible to delete traces while traces are active" perhaps ought to be amended, lest others fall into the same trap I did of believing what it says...)
- login: "jenglish"
- mimetype: "text/plain"
- username: "jenglish"
- icomment:
Ticket change [ad11403c7a] (rid 101406) by dgp on 2011-06-18 01:44:27:
- icomment:
data_type - 360894 Converting this to a lower prio feature request. I'd like to think a saner trace design is possible whenever the time comes we can more seriously consider such a thing. May be wishful thinking. History shows that deletes, destructors and the like are devilishly tricky. May be no "right" design to achieve.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [23df240ccc] (rid 131007) by dgp on 2011-06-18 01:44:28:
- foundin changed to: "None"
- priority changed to: "5 Medium"
- subsystem changed to: "46. Traces"
Ticket change [6f9fc8a6d2] (rid 100344) by jenglish on 2011-10-24 23:44:42:
- icomment:
See also #3425285. Initial fix (2011-06-17) introduced another bug, now fixed (2011-06-29). Unfortunately the buggy version made it into Tk release 8.5.10. See http://core.tcl.tk/tk/info/b938e2364a for the final fix.
- login: "jenglish"
- mimetype: "text/plain"
- title changed to: "segfault in variable traces with ttk::* widgets"
- username: "jenglish"
- icomment:
Ticket change [d2abb1ae06] (rid 140199) by dgp on 2014-10-09 14:13:53:
- closedate changed to: "2456940.09297679"
- comment changed to:
The script below crashes wish 8.5.9 and 8.5.8 (on Linux). # Crash script pack [ttk::button .b -textvariable Y] trace variable Y u "destroy .b" unset Y
- icomment: "Appears this was finished long ago."
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- severity changed to: "Minor"
- status changed to: "Closed"