Artifacts Associated With Ticket 0ef291c1c287e325
Ticket change [2a396eeaeb] (rid 148819) by aspect on 2016-09-20 10:32:03:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Test script: ~~~ proc trans args {list initialize finalize write} chan push stdout trans proc trans args {list} ;# optional - cleans up output proc foo {} {puts okay} trace add execution foo enterstep {puts X; list} foo ~~~ aborts with: ~~~ file = /home/aspect/Tcl/Env/src/tcl/generic/tclListObj.c, line = 124 incrementing refCount of previously disposed object ~~~ valgrind, memtrace, gdb backtrace attached. - foundin initialized to: "8.6.6 and trunk"
- is_private initialized to: "0"
- login: "aspect"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "aspect"
- subsystem initialized to: "26. Channel Transforms"
- title initialized to: "memory corruption with trace + transchan"
- type initialized to: "Bug"
Add attachment "oops.bt" [956132c6fd] (rid 148821) by aspect on 2016-09-20 10:32:34.
Add attachment "oops.memtrace" [ee4f11916a] (rid 148823) by aspect on 2016-09-20 10:32:50.
Add attachment "oops.valgrind" [796a2088ae] (rid 148825) by aspect on 2016-09-20 10:33:09.
Ticket change [27a738820e] (rid 148826) by ferrieux on 2016-09-20 12:42:26:
- comment changed to:
Test script: ~~~ proc trans args {list initialize finalize write} chan push stdout trans#11 0x00007ffff7b162d0 in Tcl_PopCallFrame (interp=0x6305b0) at /home/aspect/Tcl/Env/src/tcl/generic/tclNamesp.c:404 proc trans args {list} ;# optional - cleans up output proc foo {} {puts okay} trace add execution foo enterstep {puts X; list} foo ~~~ aborts with: ~~~ file = /home/aspect/Tcl/Env/src/tcl/generic/tclListObj.c, line = 124 incrementing refCount of previously disposed object ~~~ valgrind, memtrace, gdb backtrace attached. - icomment:
Unless I'm mistaken, the gdb bt ends in a different panic: "invalid block: 0x7ffff7a0d9af: 2d ff" Does it mean there is an heisenbug touch to it ? Or that when compiling with -g, the behavior differs ?
- login: "ferrieux"
- mimetype: "text/plain"
- comment changed to:
Add attachment "oops-tcl-panic.bt" [04189ddfe8] (rid 148828) by aspect on 2016-09-20 14:13:50.
Ticket change [34cd4946c9] (rid 148829) by aspect on 2016-09-20 14:20:27:
- icomment:
> Or that when compiling with -g, the behavior differs ? Different compile options make it manifest differently - looks like memory corruption. My guess is refcount management, though whether in trace or transchan machinery or somewhere else I have no idea. [puts] in both locations seems to be required. oops.bt is --enable-symbols=yes, the others (and now oops-tcl-panic.bt) are with --enable-symbols=all. The stack traces start the same but diverge above TclNRRunCallbacks at #13/#11 .. maybe that's helpful.
- login: "aspect"
- mimetype: "text/plain"
- icomment:
Ticket change [8e2b653021] (rid 148830) by ferrieux on 2016-09-20 21:21:29:
- icomment:
Thanks, it's much better to chase a single goose at a time. With the proper configure flags I reproduced locally, and with a hardware watchpoint on the (constant) offending "previously disposed object", it appears the last overwrite is a bulk erasure within Tcl_DeleteHashEntry, *not* an individual object-freeing. So, as you suggest, something very wrong might have happened some time ago, ending up in InitArgsAndLocals passing a bunch of stale pointers to NewList. Need more digging...
- login: "ferrieux"
- mimetype: "text/plain"
- icomment:
Ticket change [ad369d5a2e] (rid 149107) by dkf on 2016-10-08 16:58:40:
- assignee changed to: "aku"
- login: "dkf"
- mimetype: "text/plain"
Ticket change [2df1e85b8c] (rid 258465) by serhiy.storchaka on 2026-10-17 08:23:03:
- foundin changed to: "8.6.18, 9.0.5, 9.1.0"
- icomment:
Reproduced on main and 8.6 (heap-use-after-free under ASan; 9.0 has the same code): InvokeTclMethod() in tclIORTrans.c fills the command words preallocated for the transform, so when the handler re-enters the same transform (here the trace's <nowiki>[puts]</nowiki>), the nested call overwrites and frees the words of the outer call that is still running. Proposed fix in branch [/timeline?r=iortrans-reentrant-argv|iortrans-reentrant-argv]: copy the words for each call. Test iortrans-bug-0ef291c1c2.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"