Artifacts Associated With Ticket 3142026
Ticket change [338066f641] (rid 106603) by bharder on 2010-12-22 21:28:27:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
lsort -integer violates memory allocation when Tcl is compiled w/ TCL_MEM_DEBUG. This violation was introduced between 20Aug2009 and 21Aug2009 in CVS repo.
- foundin initialized to: "obsolete: 8.6b1"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "bharder"
- subsystem initialized to: "17. Commands I-L"
- title initialized to: "lsort -integer violates memory"
- type initialized to: "Bug"
Ticket change [016eb38afe] (rid 119483) by bharder on 2010-12-23 04:28:28:
- icomment:
File Added - 396766: lsortfail.tcl
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Add attachment "lsortfail.tcl" [b71f4b0c3d] (rid 125528) by bharder on 2010-12-23 04:28:28.
Ticket change [1935f1abec] (rid 122777) by hobbs on 2010-12-23 04:29:49:
- icomment:
Possibly related to the Tcl_LsortObjCmd change from ckalloc to stackalloc?
- login: "hobbs"
- mimetype: "text/plain"
- priority changed to: "8"
- username: "hobbs"
- icomment:
Ticket change [722b7aaf99] (rid 100810) by bharder on 2010-12-23 15:03:36:
- icomment:
File Added - 396784: patch-aa
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Ticket change [efb71b7b98] (rid 109050) by bharder on 2010-12-23 15:05:16:
- icomment:
see attached patch-aa for a minimal (absolute minimal?) patch against 14 Dec code that appears to solve this specific issue (as hinted by jeff hobbs).
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Ticket change [58279a687e] (rid 117753) by bharder on 2010-12-23 15:22:02:
- icomment:
Can confirm patch applies cleanly against CVS co of 23Dec2010 as well, and that Tcl 8.6 build passes test.
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Ticket change [9912538822] (rid 110723) by dkf on 2010-12-23 19:38:27:
- icomment:
I don't see any problem when building on OSX. Do you have a stack trace?
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [f58ea45eb8] (rid 130134) by dkf on 2010-12-23 19:57:12:
- icomment:
BTW, your patch is definitely not minimal. It touches unrelated code (the bits relating to lines 1312 to 1346 are nothing to do with [lsort]).
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [305e2c79c3] (rid 93242) by hobbs on 2010-12-24 01:41:05:
- icomment:
Donal - you have to compile with --enable-symbols=all (IOW -DTCL_MEM_DEBUG) to ensure the crash. Brad used NetBSD amd64 and I used SuSE Linux-64 to confirm.
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"
- icomment:
Ticket change [8b6679d12e] (rid 127561) by bharder on 2010-12-24 02:45:36:
- icomment:
File Added - 396835: patch-aa.v2
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Ticket change [a473606189] (rid 110208) by bharder on 2010-12-24 02:47:45:
- icomment:
Hi Donal -- indeed, my first patch was poor... I've reviewed and submitted 'patch-aa.v2' which is much more specific in the code it targets (strictly [lsort]) and does pass the case that was previously faulting. This is _not_ to say that [lindex] etc won't be subject to this same class of bug, but I won't speculate with my patch.
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Ticket change [f5e7008ba6] (rid 130197) by dkf on 2010-12-25 15:57:05:
- icomment:
I usually build with --enable-symbols=mem (so I can run memleak tests) and wasn't seeing it, and even with --enable-symbols=all in a clean build I still don't see it.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [3be6949cd3] (rid 112832) by dkf on 2010-12-26 02:09:09:
- icomment:
I'd like to emphasize that I don't mean to be difficult. I suspect that there may be some weird problem in the code to handle the temporary memory handling in the lsort command. But I can't reproduce for some reason; I need the stack trace from the crash and can't make it myself. :-( There's too many things that are trickier than they look in this code for me to hunt without at least a copy of a picture of the smoking gun available to me. :-/
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [2e83f64418] (rid 119237) by dkf on 2010-12-27 21:14:49:
- icomment:
Could you retest with the HEAD? I fixed another bug that I found when studying what this could possibly be, so maybe that will resolve this too (as I greatly simplified the memory management logic in the process; the handling of -index was unnecessarily over-clever before).
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [141fb0799e] (rid 124335) by bharder on 2010-12-28 04:53:55:
- icomment:
Tested, still failed. I've updated the patch that solves this particular ticket to work w/ your latest changes. (patch-aa.v3)
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Add attachment "patch-aa.v3" [979676c213] (rid 110463) by bharder on 2010-12-28 04:54:57.
Ticket change [f4823401bc] (rid 129932) by bharder on 2010-12-28 04:54:58:
- icomment:
File Added - 397016: patch-aa.v3
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Ticket change [622379ad7d] (rid 92363) by dkf on 2010-12-29 19:22:25:
- icomment:
File Deleted - 396835:
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [6af2819be6] (rid 128230) by dkf on 2010-12-30 08:18:14:
- icomment:
Finally managed to reproduce; it's a 64-bit only bug.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [603f8821f0] (rid 115959) by dkf on 2010-12-30 08:21:26:
- icomment:
fails on iteration 1334; stack trace follows: #0 0x00007fff83b9ff16 in __kill () #1 0x00007fff83c10f6d in abort () #2 0x00000001000ffc9c in Tcl_PanicVA (format=0x100167bd8 "Memory validation failure", argList=0x7fff5fbfeab0) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclPanic.c:118 #3 0x00000001000ffd7b in Tcl_Panic (format=0x100167bd8 "Memory validation failure") at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclPanic.c:147 #4 0x0000000100029d2f in ValidateMemory (memHeaderP=0x100247000, file=0x10016c260 "/Users/dkf/Documents/software/tcl8.6-commits/generic/tclExecute.c", line=910, nukeGuards=1) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclCkalloc.c:270 #5 0x000000010002a642 in Tcl_DbCkfree (ptr=0x100247038 "8?\"", file=0x10016c260 "/Users/dkf/Documents/software/tcl8.6-commits/generic/tclExecute.c", line=910) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclCkalloc.c:612 #6 0x000000010009fc79 in DeleteExecStack (esPtr=0x100247038) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclExecute.c:910 #7 0x000000010009ff91 in GrowEvaluationStack (eePtr=0x1003067b8, growth=4002, move=0) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclExecute.c:1092 #8 0x00000001000a01a6 in StackAllocWords (interp=0x100809e38, numWords=4002) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclExecute.c:1179 #9 0x00000001000a03d2 in TclStackAlloc (interp=0x100809e38, numBytes=32016) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclExecute.c:1263 #10 0x0000000100039605 in Tcl_LsortObjCmd (clientData=0x0, interp=0x100809e38, objc=3, objv=0x10022d488) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclCmdIL.c:3907 #11 0x000000010001d5a2 in NRRunObjProc (data=0x100458390, interp=0x100809e38, result=0) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclBasic.c:4385 #12 0x000000010001d341 in TclNRRunCallbacks (interp=0x100809e38, result=0, rootPtr=0x1003b58a8) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclBasic.c:4332 #13 0x000000010001fab9 in TclEvalObjEx (interp=0x100809e38, objPtr=0x6, flags=0, invoker=0x0, word=0) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclBasic.c:5907 #14 0x000000010001fa5d in Tcl_EvalObjEx (interp=0x100809e38, objPtr=0x6, flags=0) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclBasic.c:5888 #15 0x0000000100041fa1 in Tcl_TimeObjCmd (dummy=0x0, interp=0x100809e38, objc=2, objv=0x10022d1b8) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclCmdMZ.c:4089 #16 0x000000010001d5a2 in NRRunObjProc (data=0x1003c1d80, interp=0x100809e38, result=0) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclBasic.c:4385 #17 0x000000010001d341 in TclNRRunCallbacks (interp=0x100809e38, result=0, rootPtr=0x0) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclBasic.c:4332 #18 0x000000010001fab9 in TclEvalObjEx (interp=0x100809e38, objPtr=0x6, flags=131072, invoker=0x0, word=0) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclBasic.c:5907 #19 0x000000010001fa5d in Tcl_EvalObjEx (interp=0x100809e38, objPtr=0x6, flags=131072) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclBasic.c:5888 #20 0x00000001000c6ec9 in Tcl_RecordAndEvalObj (interp=0x100809e38, cmdPtr=0x1003a42c8, flags=131072) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclHistory.c:192 #21 0x00000001000f35bf in Tcl_MainEx (argc=-1, argv=0x7fff5fbff608, appInitProc=0x1000029f7 <Tcl_AppInit>, interp=0x100809e38) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclMain.c:518 #22 0x00000001000f3a39 in Tcl_Main (argc=1, argv=0x7fff5fbff600, appInitProc=0x1000029f7 <Tcl_AppInit>) at /Users/dkf/Documents/software/tcl8.6-commits/generic/tclMain.c:667 #23 0x00000001000029f0 in main (argc=1, argv=0x7fff5fbff600) at /Users/dkf/Documents/software/tcl8.6-commits/unix/tclAppInit.c:80
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [721205b474] (rid 100795) by dkf on 2010-12-30 08:24:45:
- icomment:
I'm guessing the issue is the need to increase the size of Tcl stack space (which appears to have hit a 32k boundary).
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [efe6143970] (rid 109081) by dkf on 2010-12-30 08:29:00:
- assignee changed to: "msofer"
- icomment:
On the basis of that, I suspect it's not a problem with [lsort] (which now has very conventional memory handling) but rather elsewhere; as such, the suggested patch is just papering over the real problem, not fixing it. Assigning to Miguel for comment.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
Ticket change [a300b8cd86] (rid 109987) by dkf on 2010-12-30 08:30:14:
- icomment:
(and students of stack traces will see that I have added [time] to it; it appears to be a by-stander in this)
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [6d62a2d039] (rid 128688) by dkf on 2010-12-30 08:35:14:
- icomment:
Actual crash message: hi guard byte 0 is 0x0 hi guard byte 1 is 0x0 hi guard byte 2 is 0x0 hi guard byte 3 is 0x0 hi guard byte 4 is 0x0 hi guard byte 5 is 0x0 hi guard byte 6 is 0x0 hi guard byte 7 is 0x0 total mallocs 68005 total frees 55127 current packets allocated 12878 current bytes allocated 645210 maximum packets allocated 12885 maximum bytes allocated 655885 high guard failed at 100247038, /Users/dkf/Documents/software/tcl8.6-commits/generic/tclExecute.c 910 32040 bytes allocated at (/Users/dkf/Documents/software/tcl8.6-commits/generic/tclExecute.c 1110) Memory validation failure
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [cbad331add] (rid 95559) by dkf on 2010-12-30 08:35:15:
- assignee changed to: "dkf"
Ticket change [10c1c946ed] (rid 95017) by dkf on 2010-12-30 08:36:13:
- assignee changed to: "msofer"
Ticket change [5b553eab36] (rid 118302) by msofer on 2010-12-30 18:01:30:
- icomment:
No 64bit platform handy to repro. Any chance to run under valgrind a -DPURIFY build? It should have symbols but no mem debug ...
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [6618522060] (rid 102651) by dkf on 2010-12-30 19:17:29:
- icomment:
Not in any config I have; my toolchain is somewhat obsolete now.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [63484de14d] (rid 92549) by hobbs on 2010-12-30 21:56:10:
- icomment:
I actually tried to trigger it under valgrind, but couldn't. Sorry that I didn't stress that both Brad and I used 64-bit before to test. I'm on the road now, so I don't have the other platforms easily at hand to test more variations. I thought it might be related to Jan's recent 64-bit alignment stuff, but apparently Brad did isolate it to this area.
- login: "hobbs"
- mimetype: "text/plain"
- username: "hobbs"
- icomment:
Ticket change [ca2a4d3cbb] (rid 122417) by msofer on 2010-12-31 01:38:54:
- icomment:
Note that this is a hi-guard failure when deleting an execution stack: the crash has possibly nothing to do with either lsort or stackAlloc, it looks like someone somewhere is writing zeros one byte past the end of the stack. The crash happens (much?) later when the stack is freed and the guard is checked.
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [2d70729221] (rid 119069) by msofer on 2010-12-31 06:11:41:
- icomment:
Fixed in HEAD, commit msg is: * generic/tclExecute.c (GrowEvaluationStack): off-by-one error in sizing the new allocation - was ok in comment but wrong in the code. Triggered by [Bug 3142026] which happened to require exactly one more than what was in existence. Leaving open as 2 things missing: 1. verify if backport is needed 2. devise a test that does not depend on sheer (un)luck
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [c755b74cb1] (rid 121912) by dkf on 2010-12-31 17:50:36:
- icomment:
Verified that it is fixed. Will consider testing.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [30703f1adc] (rid 93253) by dkf on 2010-12-31 23:55:12:
- icomment:
Difficult to test other than with exactly the script as provided. Ugh.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [eb844beba8] (rid 103556) by dkf on 2011-01-01 21:46:37:
- icomment:
Worked around that by using a slave interp. Test now committed (it fails in a 64-bit memdebug build). It's unfortunate that it still depends on some "luck", but I don't know of a better way to trigger it. Leaving this open for the backport question (up to Miguel).
- login: "dkf"
- mimetype: "text/plain"
- priority changed to: "7 High"
- username: "dkf"
- icomment:
Ticket change [593d2ce9cc] (rid 117940) by dkf on 2011-01-01 22:17:13:
- icomment:
BTW, it's categorically impossible to trigger the bug this way with 8.5; the 8.5 [lsort] code uses ckalloc and not TclStackAlloc for its temporary memory.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [027f036354] (rid 119659) by dkf on 2011-01-03 20:19:12:
- title changed to:
Stack fault due to off-by-one in GrowEvaluationStack
- title changed to:
Ticket change [683ee0e56b] (rid 103031) by bharder on 2011-01-06 13:09:31:
- icomment:
Data point: This appears solved on my machine (64bit NetBSD). My test program will now successfully run 99999 iterations to completion. Thx Miguel.
- login: "bharder"
- mimetype: "text/plain"
- username: "bharder"
- icomment:
Ticket change [2e0065ad3e] (rid 119149) by msofer on 2011-01-13 18:32:17:
- icomment:
Backported to 8.5
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [d30e4312a5] (rid 113626) by msofer on 2011-04-12 09:31:22:
- closedate changed to: "2011-04-12T02:31:22"
- closer changed to: "msofer"
- icomment:
allow_comments - 1
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "msofer"