Tcl Source Code

View Ticket
Login
Ticket UUID: 1773040
Title: ::errorInfo trace exits Tcl in some cases
Type: Bug Version: obsolete: 8.5a7
Submitter: mpc_janssen Created on: 2007-08-13 11:11:02
Subsystem: 47. Bytecode Compiler Assigned To: dgp
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-08-14 06:07:05
Resolution: Fixed Closed By: dgp
    Closed on: 2007-08-13 23:07:05
Description:
When setting an write trace on ::errorInfo, the Tcl process gets terminated in some cases.
The following script shows the problem:

H:\>tclsh
% trace add variable ::errorInfo write log_error
% proc log_error args {puts $args}
% dne
errorInfo {} write
invalid command name "dne"
% set dne
errorInfo {} write
errorInfo {} write

H:\>

version info:

H:\>tclsh
% info patch
8.5a7
% parray tcl_platform
tcl_platform(byteOrder)   = littleEndian
tcl_platform(machine)     = intel
tcl_platform(os)          = Windows NT
tcl_platform(osVersion)   = 5.1
tcl_platform(platform)    = windows
tcl_platform(pointerSize) = 4
tcl_platform(threaded)    = 1
tcl_platform(user)        = nlv18605
tcl_platform(wordSize)    = 4
%
User Comments: dgp added on 2007-08-14 06:07:05:
Logged In: YES 
user_id=80530
Originator: NO


protection already there on core-8-4-branch.

Committing it to HEAD.

dgp added on 2007-08-14 05:52:56:
Logged In: YES 
user_id=80530
Originator: NO

The Tcl_LogCommandInfo() call out
of TEBC requires DECACHE/CACHE protection

mpc_janssen added on 2007-08-14 04:54:52:
Logged In: YES 
user_id=1463011
Originator: YES

Some more info:
(gdb) info local
objPtr = (Tcl_Obj *) 0x0
initTosPtr = (Tcl_Obj **) 0x804cbe8
rangePtr = (ExceptionRange *) 0xbf990a78
valuePtr = (Tcl_Obj *) 0x4004b3a7
bytes = 0x8065b88 "set dne"
length = 7
eePtr = (ExecEnv *) 0x804cbd0
initStackTop = -1
initCatchTop = -1
compiledLocals = (Var *) 0x0
namespacePtr = (Namespace *) 0x804c9b8
catchTop = -1
tosPtr = (Tcl_Obj **) 0x804cbe8
pc = (unsigned char *) 0x806b9a2 "\f"
instructionCount = 2
expandNestList = (Tcl_Obj *) 0x0
checkInterp = 0
cleanup = 1
objResultPtr = (Tcl_Obj *) 0x8054a60
result = 1

mpc_janssen added on 2007-08-14 04:42:46:
Logged In: YES 
user_id=1463011
Originator: YES

with the first version that segfaults mentioned earlier the stack trace is:
% configure --enable-symbols && make gdb
.
.
.
Type "help" followed by command name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
(gdb) run
Starting program: /home/mjanssen/repos/bug/unix/tclsh
Failed to read a valid object file image from memory.
% proc log args {puts $args}
trace add variable ::errorInfo write log%
% set dne
errorInfo {} write

Program received signal SIGSEGV, Segmentation fault.
0x4009ef65 in TclExecuteByteCode (interp=0x804c710, codePtr=0x806b938)
    at /home/mjanssen/repos/bug/unix/../generic/tclExecute.c:6379
6379                    TclDecrRefCount(objPtr);
(gdb) bt
#0  0x4009ef65 in TclExecuteByteCode (interp=0x804c710, codePtr=0x806b938)
    at /home/mjanssen/repos/bug/unix/../generic/tclExecute.c:6379
#1  0x40090deb in TclCompEvalObj (interp=0x804c710, objPtr=0x8054820)
    at /home/mjanssen/repos/bug/unix/../generic/tclExecute.c:1051
#2  0x4004c5b2 in Tcl_EvalObjEx (interp=0x804c710, objPtr=0x8054820, flags=131072)
    at /home/mjanssen/repos/bug/unix/../generic/tclBasic.c:4033
#3  0x400a7082 in Tcl_RecordAndEvalObj (interp=0x804c710, cmdPtr=0x8054820, flags=131072)
    at /home/mjanssen/repos/bug/unix/../generic/tclHistory.c:146
#4  0x400c898b in Tcl_Main (argc=-1, argv=0xbfcf6998, appInitProc=0x80486ab <Tcl_AppInit>)
    at /home/mjanssen/repos/bug/unix/../generic/tclMain.c:545
#5  0x0804869c in main (argc=0, argv=0x1) at /home/mjanssen/repos/bug/unix/../unix/tclAppInit.c:87
(gdb)

dgp added on 2007-08-14 04:31:32:
Logged In: YES 
user_id=80530
Originator: NO


This bug was first exposed
by the fix for 1397843.

mpc_janssen added on 2007-08-14 04:27:53:
Logged In: YES 
user_id=1463011
Originator: YES

The following commit seems to have introduced the bug:
7cdf93ecbf7d5ffe46c0d56f14edb4e93f8a3076 is first bad commit
commit 7cdf93ecbf7d5ffe46c0d56f14edb4e93f8a3076
Author: dgp <dgp>
Date:   Wed Jan 11 17:34:54 2006 +0000

            * generic/tclBasic.c:   Moved Tcl_LogCommandInfo from tclBasic.c to
            * generic/tclNamesp.c:  tclNamesp.c to get access to identifier with
            * tests/error.test (error-7.0): file scope.  Added check for traces
            on ::errorInfo, and when present fall back to contruction of the
            stack trace in the variable so that write trace notification timings
            are compatible with earlier Tcl releases.  This reduces, but does not
            completely eliminate the ***POTENTIAL INCOMPATIBILITY*** created by
            the 2004-10-15 commit.  [Bug 1397843].

mpc_janssen added on 2007-08-14 02:20:54:

File Added - 241102: trace.patch.2

Logged In: YES 
user_id=1463011
Originator: YES

second version  removes trace on errorInfo in testcase cleanup, otherwise further tests will fail if this testcase fails because of the still existing errorInfo trace
File Added: trace.patch.2

mpc_janssen added on 2007-08-14 02:15:17:

File Added - 241101: trace.patch

Logged In: YES 
user_id=1463011
Originator: YES

attached patch adds a testcase for this issue
File Added: trace.patch

dgp added on 2007-08-14 02:12:09:
Logged In: YES 
user_id=80530
Originator: NO


more precisely, it appears the
1.255 -> 1.256 commit for tclBasic.c
fixed this.

dgp added on 2007-08-14 02:04:57:
Logged In: YES 
user_id=80530
Originator: NO


This bug was fixed by the
2007-06-21 commit that moved
Tcl_Parse structs off the C stack
and onto the Tcl stack.

Don't really know why yet...

mpc_janssen added on 2007-08-14 01:23:07:
Logged In: YES 
user_id=1463011
Originator: YES

Code segfaults on 8.5a6 on Linux and Windows XP

dkf added on 2007-08-13 19:33:04:
Logged In: YES 
user_id=79902
Originator: NO

Whatever is going wrong, I can't duplicate it with the HEAD

mpc_janssen added on 2007-08-13 18:21:42:
Logged In: YES 
user_id=1463011
Originator: YES

for easier copy and paste:

trace add variable ::errorInfo write log_error
proc log_error args {puts $args}
dne

Attachments: