Artifacts Associated With Ticket 804681ffffffffff
Ticket change [aac689cba0] (rid 100986) by hume on 2003-09-11 20:00:06:
- assignee initialized to: "dgp"
- cmimetype initialized to: "text/plain"
- comment initialized to:
If a variable trace is placed on errorInfo, certain errors cause a core dump in FreeListInternalRep() on both NT and Linux platforms. The crash does not happen with version 8.3 To show the error enter the following at the Tcl prompt: proc show args {puts $args} trace variable errorInfo wu show expr 9/0 Here is the NT stack: FreeListInternalRep(Tcl_Obj * 0x002eb348) line 1386 + 6 bytes TclExecuteByteCode(Tcl_Interp * 0x0029d380, ByteCode * 0x002a5390) line 4198 + 55 bytes TclCompEvalObj(Tcl_Interp * 0x0029d380, Tcl_Obj * 0x00294ba0) line 1008 + 13 bytes Tcl_EvalObjEx(Tcl_Interp * 0x0029d380, Tcl_Obj * 0x00294ba0, int 131072) line 3952 + 13 bytes Tcl_RecordAndEvalObj(Tcl_Interp * 0x0029d380, Tcl_Obj * 0x00294ba0, int 131072) line 142 + 23 bytes Tcl_Main(int 1, char * * 0x00274b30, int (Tcl_Interp *)* 0x00401005 _Tcl_AppInit) line 390 + 24 bytes main() line 110 + 19 bytes mainCRTStartup() line 338 + 17 bytes KERNEL32! 7c4e87f5() - foundin initialized to: "obsolete: 8.4.4"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "hume"
- subsystem initialized to: "46. Traces"
- title initialized to: "errorInfo trace can crash in FreeListInternalRep()"
- type initialized to: "Bug"
Ticket change [bc112e6c05] (rid 129594) by dgp on 2003-09-12 05:27:51:
- icomment:
Logged In: YES user_id=80530 Thanks for the report. Further investigation reveals this bug entered sometime between releases Tcl 8.4a4 and Tcl 8.4.0.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [e726918aea] (rid 104404) by dgp on 2003-09-12 05:43:03:
- icomment:
Logged In: YES user_id=80530 Between 8.4a4 and 8.4b1 even.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [060ed5aaf3] (rid 89152) by dgp on 2003-09-12 09:24:31:
- assignee changed to: "msofer"
- foundin changed to: "obsolete: 8.4b1"
- icomment:
Logged In: YES user_id=80530 This bug was introduced by msofer's commits on 2002-06-18.
- login: "dgp"
- mimetype: "text/plain"
- priority changed to: "7 High"
- subsystem changed to: "47. Bytecode Compiler"
- username: "dgp"
Ticket change [f7beeecafc] (rid 91422) by dgp on 2003-09-13 00:02:29:
- icomment:
Logged In: YES user_id=80530 The segfault happens as the bytecode execution engine tries to clear away items on the stack. It decrements and tries to free a list value that has already been freed. This list value is the $args value that was a local variable in the [show] proc. It has been freed already because it was freed when [show] returned, as one would expect. It's a mystery why there's a reference to $args on the bytecode execution stack, and another mystery why that reference, if it must indeed exist, never accounted for itself with a refCount.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [289ba0482b] (rid 88725) by dgp on 2003-09-13 04:00:40:
- icomment:
File Added - 61387: 804681.patch Logged In: YES user_id=80530 Here's a patch against the tip of the core-8-4-branch that fixes the segfault in the reported script. Leaving the report open for further review from msofer.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Add attachment "804681.patch" [64bb07ae38] (rid 92819) by dgp on 2003-09-13 04:00:40.
Ticket change [25722f5ea0] (rid 88173) by msofer on 2003-09-13 04:14:11:
- icomment:
Logged In: YES user_id=148712 Good catch Don! There's more of the same, the following still crashes after your patch: proc show args {puts $args} trace variable errorInfo wu show incr a ;# assuming no variable a is defined I'll hunt down all similar things in TEBC, now that you discovered what was happening. I'd also try to understand how those modifs introduced the bug - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [87d2032dbc] (rid 131764) by msofer on 2003-09-14 21:04:22:
- icomment:
Logged In: YES user_id=148712 Explicit bug description, for the record: (a) every call from TEBC to an outside function that may evaluate a bcc'ed script has to be protected by a (DE)CACHE_STACK_INFO() macro pair to insure the stack's integrity - namely, so that the nested TEBC knows where the not-in-use part of the stack starts. Failure to do so corrupts the evaluation stack. (b) due to the trace mechanism, every variable modification may end up evaluating bcc'ed code. Therefore, every call that touches a variable should be protected as above. (c) the error mechanism modifies ::errorInfo. But error reports are not protected in TEBC. Thus, a trace on ::errorInfo that calls a proc corrupts the evaluation stack. One possible fix is to identify every instance at risk and protect it. I have not yet been able to understand why TEBC was immune to this problem before, ie, what (subtle?) pre-existing protection I destroyed. TEBC will be fixed shortly with either a restoration of the previous mechanism, or else a bunch of new macro pairs.
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [db497c896a] (rid 107932) by msofer on 2003-09-15 15:18:45:
- icomment:
Logged In: YES user_id=148712 Pre-modif TEBC had the bug too, but it was more difficult to trigger. Witness mig@cx:/CVS/tcl8.3.4/unix$ ./tclsh % info patch 8.3.4 % proc show args {puts $args} % trace variable errorInfo wu show % expr {1+9/0} errorInfo {} w errorInfo {} w divide by zero % exit Segmentation fault Before those modifs, an instruction that caused an error removed its arguments from the stack before "goto checkForCatch", so that the corruption only happened when there were objects in the stack deeper than them - in the example, the "1" is in the stack when the division error occurs, so that removing the "9" and "0" is not quite enough. Now the stack is not cleared before "goto checkForCatch", so that the stack is always corrupted if error logging causes TEBC to be called. - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [7fe261c330] (rid 97638) by msofer on 2003-09-15 15:21:54:
- icomment:
Logged In: YES user_id=148712 The function calls that require protection are: Tcl_ResetResult, Tcl_AddObjErrorInfo, Tcl_AddErrorInfo, Tcl_SetObjErrorCode, Tcl_SetErrorCode, Tcl_SetErrorCodeVA, Tcl_PosixError, Tcl_LogCommandInfo
- login: "msofer"
- mimetype: "text/plain"
- priority changed to: "8"
- username: "msofer"
- icomment:
Ticket change [2ddb3fe9cd] (rid 119128) by msofer on 2003-09-20 01:06:31:
- closedate changed to: "2003-09-19T18:06:31"
- closer changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 Fixed in HEAD and 8.4-branch; patch attached as reference for evetnual backporters
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- title changed to:
traces on errorInfo/errorCode corrupt the evaluation stack
- username: "msofer"