Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-08-14
06:07 • Closed ticket [1773040fff]: ::errorInfo trace exits Tcl in some cases plus 9... artifact: 3427b85815 user: dgp
05:52 • Ticket [1773040fff]: 4 changes artifact: a479844293 user: dgp
04:54 • Ticket [1773040fff]: 4 changes artifact: 007fd2fa6c user: mpc_janssen
04:42 • Ticket [1773040fff]: 4 changes artifact: 05551d1f72 user: mpc_janssen
04:31 • Ticket [1773040fff]: 4 changes artifact: d612109579 user: dgp
04:27 • Ticket [1773040fff]: 4 changes artifact: db79567202 user: mpc_janssen
02:20 • Add attachment trace.patch.2 to ticket [1773040fff] artifact: 295e9b99f4 user: mpc_janssen
02:20 • Ticket [1773040fff] ::errorInfo trace exits Tcl in some cases status still O... artifact: 3f38ba9bbc user: mpc_janssen
02:15 • Ticket [1773040fff]: 4 changes artifact: 9c60acd64f user: mpc_janssen
02:15 • Add attachment trace.patch to ticket [1773040fff] artifact: 6ac194d287 user: mpc_janssen
02:12 • Ticket [1773040fff] ::errorInfo trace exits Tcl in some cases status still O... artifact: 44650268d4 user: dgp
02:04 • Ticket [1773040fff]: 4 changes artifact: a88f0efbd0 user: dgp
01:23 • Ticket [1773040fff]: 4 changes artifact: a2937a02da user: mpc_janssen
2007-08-13
20:28 • Ticket [1773040fff]: 1 change artifact: 58b5e2dc4d user: msofer
20:27 • Ticket [1773040fff]: 1 change artifact: 8c3a6810d9 user: msofer
19:33 • Ticket [1773040fff]: 6 changes artifact: 855493acf3 user: dkf
18:21 • Ticket [1773040fff]: 4 changes artifact: 2fb33389bc user: mpc_janssen
11:11 • New ticket [1773040fff]. artifact: c094ddd38f user: mpc_janssen

::errorInfo trace exits Tcl in some cases

Closed / Fixed1773040fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-08-13 11:11:02
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
%
mpc_janssenplain2007-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
dkfplain2007-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
msofer Ticket [1773040fff]: 1 change [History diff]2007-08-13 20:27:38
msofer Ticket [1773040fff]: 1 change [History diff]2007-08-13 20:28:24
mpc_janssenplain2007-08-14 01:23:07
Logged In: YES 
user_id=1463011
Originator: YES

Code segfaults on 8.5a6 on Linux and Windows XP
dgpplain2007-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...
dgpplain2007-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.
mpc_janssenplain2007-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
mpc_janssenplain2007-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_janssenplain2007-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].
dgpplain2007-08-14 04:31:32
Logged In: YES 
user_id=80530
Originator: NO


This bug was first exposed
by the fix for 1397843.
mpc_janssenplain2007-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)
mpc_janssenplain2007-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
dgpplain2007-08-14 05:52:56
Logged In: YES 
user_id=80530
Originator: NO

The Tcl_LogCommandInfo() call out
of TEBC requires DECACHE/CACHE protection
dgpplain2007-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.
Log in (anonymous is fine) to add a comment.

Attachments: