Artifacts Associated With Ticket 3602706fffffffffffffffffffffffffffffffff
Ticket change [8147007645] (rid 117002) by tombert on 2013-01-30 21:23:22:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- 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
- foundin initialized to: "obsolete: 8.5.13"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "tombert"
- subsystem initialized to: "49. Threading"
- title initialized to: "Segfault on tclsh startup"
- type initialized to: "Bug"
Ticket change [ded7b43df3] (rid 114919) by andreas_kupries on 2013-01-31 04:31:04:
- 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 ?
- login: "andreas_kupries"
- mimetype: "text/plain"
- priority changed to: "9 Immediate"
- username: "andreas_kupries"
- icomment:
Ticket change [5c2b418af9] (rid 115250) by nijtmans on 2013-01-31 04:50:25:
- 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 - login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [e3993b2e8d] (rid 87820) by tombert on 2013-01-31 13:40:45:
- icomment:
It happens in the release version as well. Ok - I will "fossil bisect" into it ...
- login: "tombert"
- mimetype: "text/plain"
- username: "tombert"
- icomment:
Ticket change [da93910cbf] (rid 107812) by tombert on 2013-01-31 16:15:21:
- icomment:
2013-01-13 23:15:10 8aca9a8e961fb172 BAD 2013-01-13 09:04:10 4c2509336a9c2b2c GOOD CURRENT
- login: "tombert"
- mimetype: "text/plain"
- username: "tombert"
- icomment:
Ticket change [0612f763ba] (rid 89156) by dkf on 2013-01-31 16:21:59:
- 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?
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [0563e1c00a] (rid 89058) by nijtmans on 2013-01-31 16:22:13:
- 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.
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [b5fb5ff3fd] (rid 125343) by dkf on 2013-01-31 16:27:13:
- 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.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [84f545f409] (rid 131240) by nijtmans on 2013-01-31 16:30:40:
- 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.
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [555b897555] (rid 94121) by dgp on 2013-01-31 21:59:28:
- icomment:
Opened new branch bug-3602706 for finding and fixing the bug. Please confirm it demonstrates the problem. It Works For Me.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [cf4e460600] (rid 112953) by nijtmans on 2013-01-31 22:24:21:
- 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!
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [d117246b82] (rid 113291) by dgp on 2013-01-31 22:49:16:
- icomment:
Thanks! Will examine.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [77319e5b29] (rid 89740) by nijtmans on 2013-01-31 22:59:54:
- 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.
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [df576dcc4e] (rid 115000) by dgp on 2013-01-31 23:43:17:
- 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.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [b87a91cdef] (rid 128973) by dgp on 2013-02-01 00:03:31:
- 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.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [3533347550] (rid 106879) by dkf on 2013-02-01 08:24:46:
- 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. :-)
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [331a5f7515] (rid 106525) by nijtmans on 2013-02-01 15:44:31:
- 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! - login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [96f21b8d81] (rid 106423) by nijtmans on 2013-02-01 16:49:52:
- 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 */ - login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [2e62fa9d01] (rid 119214) by nijtmans on 2013-02-04 21:31:17:
- assignee changed to: "dgp"
- subsystem changed to: "07. Variables"
Ticket change [d65608221e] (rid 123784) by dgp on 2013-02-04 23:54:08:
- assignee changed to: "andreas_kupries"
- 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.
- login: "dgp"
- mimetype: "text/plain"
- subsystem changed to: "49. Threading"
- username: "dgp"
Ticket change [1be7327bd7] (rid 123232) by dgp on 2013-02-05 00:15:39:
- 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.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [a66baec770] (rid 98597) by dgp on 2013-02-05 01:01:45:
- icomment:
AArrgh. Botched it again. Please stand by.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [f4de84bb20] (rid 130002) by dgp on 2013-02-05 01:40:46:
- icomment:
Ok, fixed right this time, and a cross-platform test.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [39a382810b] (rid 112427) by dgp on 2013-02-05 03:49:41:
- assignee changed to: "dgp"
- closedate changed to: "2013-02-04T20:49:41"
- closer changed to: "dgp"
- icomment:
allow_comments - 1 8.5 and trunk branches updated with fix.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- subsystem changed to: "07. Variables"
- username: "dgp"