Skip to content
Tcl Source Code History Of Ticket 1904907fffffffff
Login

History Of Ticket 1904907fffffffff

Artifacts Associated With Ticket 1904907fffffffff

  1. Ticket change [60ad429c9d] (rid 116038) by schwarzkopf on 2008-02-29 19:16:37:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      % parray tcl_platform
      tcl_platform(byteOrder)   = littleEndian
      tcl_platform(machine)     = x86_64
      tcl_platform(os)          = Linux
      tcl_platform(osVersion)   = 2.6.22-14-generic
      tcl_platform(platform)    = unix
      tcl_platform(pointerSize) = 8
      tcl_platform(threaded)    = 1
      tcl_platform(user)        = bschwarz
      tcl_platform(wordSize)    = 8
      
      I have a file with this in it, and it produces a segfault:
      
        et fid [chan create {r w} ::vchan]
      
        chan puts $fid "HELLO THERE"
        set data [read $fid]
      
      If I add the following at the end, it does not segfault (note that I need a catch, because there is another problem when I [chan close]):
      
        catch {chan close $fid}
        
      I don't see the problem on "normal" channels (i.e. opening a file on the filesystem with [open])
      
    4. foundin initialized to: "obsolete: 8.5.1"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "schwarzkopf"
    10. subsystem initialized to: "24. Channel Commands"
    11. title initialized to:
      get segfault when using a channel created with [chan create]
      
    12. type initialized to: "Bug"
  2. Add attachment "tst_chan.tcl" [c14398f8ac] (rid 111291) by schwarzkopf on 2008-03-01 02:38:05.

  3. Ticket change [515eb8f6db] (rid 126130) by schwarzkopf on 2008-03-01 02:38:08:

    1. icomment:
      
      
      File Added - 268627: tst_chan.tcl
      
      Logged In: YES 
      user_id=159778
      Originator: YES
      
      File Added: tst_chan.tcl
      
      
    2. login: "schwarzkopf"
    3. mimetype: "text/plain"
    4. username: "schwarzkopf"
  4. Ticket change [b21f63bf46] (rid 98280) by andreas_kupries on 2008-03-01 05:22:21:

    1. icomment:
      Logged In: YES 
      user_id=75003
      Originator: NO
      
      Information collected so far:
      - Happens for 64/32bit both
      - Happens for threaded/non-threaded both.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  5. Ticket change [daf18b38e4] (rid 107875) by schwarzkopf on 2008-03-01 06:28:59:

    1. icomment:
      Logged In: YES 
      user_id=159778
      Originator: YES
      
      the problem occurs on 32 bit Linux as well, and occurs on Windows
      
      
    2. login: "schwarzkopf"
    3. mimetype: "text/plain"
    4. username: "schwarzkopf"
  6. Ticket change [63ff0031bc] (rid 92673) by schwarzkopf on 2008-03-04 02:08:02:

    1. icomment:
      Logged In: YES 
      user_id=159778
      Originator: YES
      
      I started tracking this down, and I got as far as this. In the FlushChannel function in tclIO.c, it craps out at:
      
              written = (chanPtr->typePtr->outputProc)(chanPtr->instanceData,
                      RemovePoint(bufPtr), toWrite, &errorCode);
      
      Not sure how to track it from there, but I think I've tracked it pretty far...
      
      
    2. login: "schwarzkopf"
    3. mimetype: "text/plain"
    4. username: "schwarzkopf"
  7. Add attachment "STACK.txt" [ef2f75bff3] (rid 108951) by andreas_kupries on 2008-03-07 03:23:34.

  8. Ticket change [ded31af0d3] (rid 114916) by andreas_kupries on 2008-03-07 03:23:34:

    1. icomment:
      
      
      File Added - 269366: STACK.txt
      
      Logged In: YES 
      user_id=75003
      Originator: NO
      
      Using a symbol enabled tclsh I got myself a stacktrace from gdb ... Attached ...
      
      What happens is that FlushChannel (#20) invokes the driver output function, one 'ReflectOuptut' (#19), which delegates the writing to the '::vchan' via 'InvokeTclMethod' (#18), this then ends up in a call to '::vchan::write', and then it seems to compile this procedure (ProcCompileProc @ #10). And when it compiles the 'return' command of 'vchan::write' it craps out in 'TclMergeReturnOptions' (#5). This function was last changed Oct 18, 2007. The caller, 'TclCompileReturnCmd' (#6) was however changed last quite recently, Feb 28 2008, to fix a memory leak. As the crash happens on a Tcl_Obj with refCount 0 and otherwise looking already freed as well, I wonder if that change caused the problem.
      
      I will now get me some older revisions of the head and see if I can bisect the issue.
      
      File Added: STACK.txt
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  9. Ticket change [b26ddbc47b] (rid 98332) by andreas_kupries on 2008-03-07 03:23:35:

    1. priority changed to: "9 Immediate"
  10. Ticket change [c1fa694b39] (rid 111419) by dgp on 2008-03-07 04:36:45:

    1. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      The stack trace shows the problem
      coming from MarshallError() which
      to me indicates that 1428575 may
      be the best way out.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  11. Ticket change [13dd8e3d5b] (rid 124293) by dgp on 2008-03-07 06:03:28:

    1. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      Apparently several of us testing
      with the demo script are seeing
      different failures.  The one I see
      happens because Tcl_GetReturnOptions()
      is called after Tcl_FinalizeThread().
      
      The "fix" (workaround?) is to add
          keys[i] = NULL;
      at the right place in the ReleaseKeys()
      routine, so that in this scenario, the
      GetKeys() can re-initialize.  This stops
      the crash, but adds a memleak, so I don't
      want to commit without more analysis.
      This is looking like a finalization order
      dependency mess to untangle.
      
      Another way out would be to just take
      the whole GetKeys() business out (perhaps
      conditioned on TclInExit() ?) and force
      the routines using it to created their
      key values on demand instead of pulling
      from a per-thread cache.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  12. Ticket change [6e2b8c01dd] (rid 128829) by andreas_kupries on 2008-03-07 06:59:30:

    1. icomment:
      Logged In: YES 
      user_id=75003
      Originator: NO
      
      I am now convinced that threaded and non-threaded are seeing two different expression of the same ordering problem. Tcl_FinalizeThread is run, this releases the dict keys for the return options.
      
      In the non-threaded case this crashed when Tcl tried to compile the 'return' command in 'vchan::write' in preparation of its invokation by the ReflectOutput. In the threaded case the compile managed to complete successfully and we made to the execution stage, i.e. the procedure was actually invoked. After that a script level error (expected return of int, got nothing) caused the generation of an error message by the reflection code and marshalling that error then crashed on the same missing return option keys.
      
      Don's 'fix' is a fix for non-threaded as well, I just did not see that immediately because my tclsh picked up the old library. 'make install' was needed after recompile.
      
      I agree that this fix introduces a mem leak if Tcl is used in an environment where the 'OS' has no true processes which are fully cleaned up. Example: IOS.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  13. Ticket change [6a350cb31c] (rid 128104) by andreas_kupries on 2008-03-08 05:46:37:

    1. icomment:
      Logged In: YES 
      user_id=75003
      Originator: NO
      
      The workaround has been committed, with proper warning that it is a workaround, introduces a memory leak, and a proper fix has to wade into the tangel that is finalization ordering.
      
      This entry is left open, at lesser priority, and updated summary.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. priority changed to: "6"
    5. title changed to:
      Fix [chan create]/return opt dict key final'ion order issues
      
    6. username: "andreas_kupries"
  14. Ticket change [29d78266c4] (rid 118456) by andreas_kupries on 2008-03-08 05:47:29:

    1. title changed to:
      Fix [chan create]/return dict key finalization order issues
      
  15. Ticket change [eb8ab0099b] (rid 103558) by dgp on 2008-03-13 05:08:53:

    1. icomment:
      Logged In: YES 
      user_id=80530
      Originator: NO
      
      
      It seems that Tcl_GetReturnOptions() needs to
      be able to work on an interp argument over the
      entire lifetime of that interp.  This means
      the cleanup of these key values needs to be
      triggered by a Tcl_InterpDeleteProc associated
      with the interp, and not by a Tcl_ExitProc
      thread exit handler as is currently done.
      
      It helps with performance to have multiple
      interps in one thread share keys, so a solution
      that still permits that would be best.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"