Skip to content
Tcl Source Code History Of Ticket 3602706fffffffffffffffffffffffffffffffff
Login

History Of Ticket 3602706fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 3602706fffffffffffffffffffffffffffffffff

  1. Ticket change [8147007645] (rid 117002) by tombert on 2013-01-30 21:23:22:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Somewhere between the checkins from 2012-12-07 till 2013-01-30 a bug was introduced.
      There is no need to run a script, it crashes by simply starting the tclsh. Sidenote: I also updated tcl 8.6 and there is no crash.
      Happens in Windows 7, MinGw, gcc 4.6.2.
      
      Here is the output of gdb:
      
      Starting program: E:\CM.git\tcltk85\debug\bin\tclsh85g.exe
      [New Thread 9456.0x1ec8]
      
      Program received signal SIGSEGV, Segmentation fault.
      TclThreadAllocObj () at ./../generic/tclThreadAlloc.c:570
      570         cachePtr->firstObjPtr = objPtr->internalRep.otherValuePtr;
      
      
      ----------------------------------
      thx for your support
      
    4. foundin initialized to: "obsolete: 8.5.13"
    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: "tombert"
    10. subsystem initialized to: "49. Threading"
    11. title initialized to: "Segfault on tclsh startup"
    12. type initialized to: "Bug"
  2. Ticket change [ded7b43df3] (rid 114919) by andreas_kupries on 2013-01-31 04:31:04:

    1. icomment:
      Thomas, is possible for you to 'fossil bisect' the issue until you have the exact revision which causes the crash?
      
      I rmemeber we had recent issues with CPUID detection and code.
      Are you by chance on a 64bit platform?
      
      From the naming of the tclsh I deduce that you have a debug build of some kind, is that correct ?
      
      If yes, does the crash happen for a non-debug build also ?
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. priority changed to: "9 Immediate"
    5. username: "andreas_kupries"
  3. Ticket change [5c2b418af9] (rid 115250) by nijtmans on 2013-01-31 04:50:25:

    1. icomment:
      I suspect this is a dup of 3601260
      
      Does the following branch have the problem as well?
         <http://core.tcl.tk/tcl/info/10b2640e48>
      
      I wasn't able to create a strack-trace.
      
      Regards,
              Jan Nijtmans
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  4. Ticket change [e3993b2e8d] (rid 87820) by tombert on 2013-01-31 13:40:45:

    1. icomment:
      It happens in the release version as well.
      Ok - I will "fossil bisect" into it ...
      
      
    2. login: "tombert"
    3. mimetype: "text/plain"
    4. username: "tombert"
  5. Ticket change [da93910cbf] (rid 107812) by tombert on 2013-01-31 16:15:21:

    1. icomment:
      2013-01-13 23:15:10 8aca9a8e961fb172 BAD
      2013-01-13 09:04:10 4c2509336a9c2b2c GOOD CURRENT
      
      
    2. login: "tombert"
    3. mimetype: "text/plain"
    4. username: "tombert"
  6. Ticket change [0612f763ba] (rid 89156) by dkf on 2013-01-31 16:21:59:

    1. icomment:
      In the context of the 8aca9a8e961fb172 commit, do we have a backtrace at the point of the crash?
      Are any problems hit in an --enable-symbols=mem build?
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [0563e1c00a] (rid 89058) by nijtmans on 2013-01-31 16:22:13:

    1. icomment:
      When bisecting Bug #3601260, I came to exactly the same
      commit which started the problem! Looks they are really dups,
      even though the effect is different with different mingw
      compiler versions.
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  8. Ticket change [b5fb5ff3fd] (rid 125343) by dkf on 2013-01-31 16:27:13:

    1. icomment:
      The trigger for this crash is not on a codepath that my machine seems to exercise (for whatever reason); I can't hunt it directly. I *SUSPECT* that it is an unfixed location in the Win-specific code, but I have no true justification for that other than a hunch.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  9. Ticket change [84f545f409] (rid 131240) by nijtmans on 2013-01-31 16:30:40:

    1. icomment:
      Looking at the changes in [8aca9a8e961fb172], I suspect
      that it is related to refCounting objects. The segfault
      occurs in the thread allocator, where objPtr point
      to invalid memory, so somewhere the
      Tcl_IncRefCount/Tcl_DecrRefCount's don't match.
      That's my current theory. (this might be
      in win-specific code, indeed, which is
      fixed in trunk)
      
      The easiest fix would be to simply
      revert [8aca9a8e961fb172] on
      core-8-5-branch and then merge-mark
      to trunk (so the improvement is kept there)
      That gives some time to investigate this,
      without everyone (like me) being hindered by this.
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  10. Ticket change [555b897555] (rid 94121) by dgp on 2013-01-31 21:59:28:

    1. icomment:
      Opened new branch bug-3602706 for
      finding and fixing the bug.  Please confirm
      it demonstrates the problem.  It Works For Me. 
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  11. Ticket change [cf4e460600] (rid 112953) by nijtmans on 2013-01-31 22:24:21:

    1. icomment:
      Yes it has the bug. I also checked my theory that this is a refCount bug, by
      uncommenting all Tcl_DecrRefCount() calls (which makes all tests pass)
      and then restoring them one by one until the tests fail again.
      
      It turns out the the refCount goes wrong with the part2Ptr in the
      function Tcl_GetVar2Ex. Minimal fix is in the branch now. I'm
      not 100% sure this is the right fix, but it works!
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  12. Ticket change [d117246b82] (rid 113291) by dgp on 2013-01-31 22:49:16:

    1. icomment:
      Thanks!  Will examine.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  13. Ticket change [77319e5b29] (rid 89740) by nijtmans on 2013-01-31 22:59:54:

    1. icomment:
      It looks like we must thank dkf that trunk didn't have the crash. In
      the following commit he added a lot of IncrRefCount/DecrRefCount
      pairs on "trunk":
      <http://core.tcl.tk/tcl/info/d91c86d0da>
      Those were never backported to core-8-5-branch.
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  14. Ticket change [df576dcc4e] (rid 115000) by dgp on 2013-01-31 23:43:17:

    1. icomment:
      That suggests the problem lies in callers
      of Tcl_GetVar2() which differs between
      the two branches, bypassing the suspected
      broken Tcl_GetVar2Ex() on the trunk, but
      hitting it on 8.5.
      
      Grep says that tclWinInit.c calls Tcl_GetVar2()
      to set some vars in the ::env array.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  15. Ticket change [b87a91cdef] (rid 128973) by dgp on 2013-02-01 00:03:31:

    1. icomment:
      The only other places Tcl_GetVar2 is called
      is in the testing command [testset2] which is
      hardly used at all, and in write traces on ::env
      which is generic code.  There ought to be a way
      to use that to demo the trouble on all platforms
      on this bug branch.
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  16. Ticket change [3533347550] (rid 106879) by dkf on 2013-02-01 08:24:46:

    1. icomment:
      FWIW, that commit was (partially) about reducing the depth of callframes associated with the legacy variable interfaces, keeping things simpler in backtraces and *maybe* reducing costs.
      
      I wasn't trying to armour against someone else's bugs. :-)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  17. Ticket change [331a5f7515] (rid 106525) by nijtmans on 2013-02-01 15:44:31:

    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"
  18. Ticket change [96f21b8d81] (rid 106423) by nijtmans on 2013-02-01 16:49:52:

    1. icomment:
      In tclParse.c, I see the following code:
      ....
      arrayIndex = Tcl_GetObjResult(interp);
      Tcl_IncrRefCount(arrayIndex);
      ....
      varName = Tcl_NewStringObj(tokenPtr[1].start,
      tokenPtr[1].size);
      appendObj = Tcl_ObjGetVar2(interp, varName, arrayIndex,
      TCL_LEAVE_ERR_MSG);
      Tcl_DecrRefCount(varName);
      ....
          if (arrayIndex != NULL) {
      Tcl_DecrRefCount(arrayIndex);
          }
      
      So, for 'arrayIndex' the refCount is incremented before the
      Tcl_ObjGetVar2 call, but for 'varName' it is not! For
      "novem" it might be better to let Tcl_ObjGetVar2 clean up
      part1Ptr and part2Ptr if the refCount is 0. That would
      allow to simplify the above code to:
      ....
      arrayIndex = Tcl_GetObjResult(interp);
      /* Tcl_IncrRefCount(arrayIndex); No longer necessary */
      ....
      varName = Tcl_NewStringObj(tokenPtr[1].start,
      tokenPtr[1].size);
      appendObj = Tcl_ObjGetVar2(interp, varName, arrayIndex,
      TCL_LEAVE_ERR_MSG);
      /* Tcl_DecrRefCount(varName); No longer necessary */
      ....
          /* if (arrayIndex != NULL) {
      Tcl_DecrRefCount(arrayIndex);
          } No longer necessary */
      
      
      
    2. login: "nijtmans"
    3. mimetype: "text/plain"
    4. username: "nijtmans"
  19. Ticket change [2e62fa9d01] (rid 119214) by nijtmans on 2013-02-04 21:31:17:

    1. assignee changed to: "dgp"
    2. subsystem changed to: "07. Variables"
  20. Ticket change [d65608221e] (rid 123784) by dgp on 2013-02-04 23:54:08:

    1. assignee changed to: "andreas_kupries"
    2. icomment:
      Returning to the scene of the crime, I've
      extended the mig-review branch to add the
      refcount housekeeping and comment that
      got missed or botched the first time.
      
      
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. subsystem changed to: "49. Threading"
    6. username: "dgp"
  21. Ticket change [1be7327bd7] (rid 123232) by dgp on 2013-02-05 00:15:39:

    1. icomment:
      New forked tip of the bug-3602706 branch
      cherrypicks those fixes where they might be
      conveniently tested.
      
      Would be better to add cross-platform tests
      that demonstrate the bug, but for now I'll
      beg for a test run from the Windows crowd.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  22. Ticket change [a66baec770] (rid 98597) by dgp on 2013-02-05 01:01:45:

    1. icomment:
      AArrgh.  Botched it again.  Please stand by.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  23. Ticket change [f4de84bb20] (rid 130002) by dgp on 2013-02-05 01:40:46:

    1. icomment:
      Ok, fixed right this time, and a cross-platform test.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  24. Ticket change [39a382810b] (rid 112427) by dgp on 2013-02-05 03:49:41:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2013-02-04T20:49:41"
    3. closer changed to: "dgp"
    4. icomment:
      
      
      allow_comments - 1
      
      8.5 and trunk branches updated with fix.
      
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
    9. subsystem changed to: "07. Variables"
    10. username: "dgp"