Skip to content
Tcl Source Code History Of Ticket 0ef291c1c2
Login

History Of Ticket 0ef291c1c2

Artifacts Associated With Ticket 0ef291c1c2

  1. Ticket change [2a396eeaeb] (rid 148819) by aspect on 2016-09-20 10:32:03:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. 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.
      
    5. foundin initialized to: "8.6.6 and trunk"
    6. is_private initialized to: "0"
    7. login: "aspect"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "aspect"
    13. subsystem initialized to: "26. Channel Transforms"
    14. title initialized to: "memory corruption with trace + transchan"
    15. type initialized to: "Bug"
  2. Add attachment "oops.bt" [956132c6fd] (rid 148821) by aspect on 2016-09-20 10:32:34.

  3. Add attachment "oops.memtrace" [ee4f11916a] (rid 148823) by aspect on 2016-09-20 10:32:50.

  4. Add attachment "oops.valgrind" [796a2088ae] (rid 148825) by aspect on 2016-09-20 10:33:09.

  5. Ticket change [27a738820e] (rid 148826) by ferrieux on 2016-09-20 12:42:26:

    1. 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.
      
    2. 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 ?
      
    3. login: "ferrieux"
    4. mimetype: "text/plain"
  6. Add attachment "oops-tcl-panic.bt" [04189ddfe8] (rid 148828) by aspect on 2016-09-20 14:13:50.

  7. Ticket change [34cd4946c9] (rid 148829) by aspect on 2016-09-20 14:20:27:

    1. 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.
      
    2. login: "aspect"
    3. mimetype: "text/plain"
  8. Ticket change [8e2b653021] (rid 148830) by ferrieux on 2016-09-20 21:21:29:

    1. 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...
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  9. Ticket change [ad369d5a2e] (rid 149107) by dkf on 2016-10-08 16:58:40:

    1. assignee changed to: "aku"
    2. login: "dkf"
    3. mimetype: "text/plain"
  10. Ticket change [2df1e85b8c] (rid 258465) by serhiy.storchaka on 2026-10-17 08:23:03:

    1. foundin changed to: "8.6.18, 9.0.5, 9.1.0"
    2. 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.
      
    3. login: "serhiy.storchaka"
    4. mimetype: "text/x-fossil-wiki"