Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 331a5f751565b23068e70ec05fffc3c3a1fb7eee
Ticket: 3602706fffffffffffffffffffffffffffffffff
Segfault on tclsh startup
User & Date: nijtmans on 2013-02-01 15:44:31
Changes

  1. icomment:
    I think I got it. The call that goes wrong is (tclWinInit.c):
        ptr = Tcl_GetVar2(interp, "env", "HOME", TCL_GLOBAL_ONLY);
    but only when $env(HOME) does not exist. My $HOME env
    variable was set while in Thomas' environment it wasn't,
    that explains the difference in effect. My env.test test
    cases were failing because they clean up the env array
    and then start up a new tclsh (which doesn't have
    $HOME --> crash). This explains everything!
    
    The stack trace looks like (manuallly reconstructed)
      Tcl_GetVar2
      Tcl_GetVar2Ex
      Tcl_ObjGetVar2
      TclObjLookupVarEx(.../*createPart1*/ 0, /*createPart2*/ 1, ...)
    
    Why is the createPart2 parameter 1???? That's the bug, is it?? Or
    is it needed for read traces on the array???? The
    effect is that a new hash entry is created for the env(HOME) key,
    so its refCount is incremented, and (at the end of
    TclObjLookupVarEx) it's decremented again. Callers
    of Tcl_ObjGetVar2 don't expect that, do they?
    
    Anyway, changing the parameter from 1 to 0 makes
    all test-cases pass. (Done now on the branch).
    
    Please evaluate! Tcl 8.6 has the same bug, but
    because of dkf's already mentioned commit it
    isn't noticed there.
    
    There are more TclObjLookupVarEx calls with
    createPart2=1, those should be checked too!
    
    
  2. login: "nijtmans"
  3. mimetype: "text/plain"
  4. username: "nijtmans"