#3760 ::errorInfo trace exits Tcl in some cases

obsolete: 8.5a7
closed-fixed
5
2007-08-13
2007-08-13
No

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
%

Discussion

  • Mark Janssen

    Mark Janssen - 2007-08-13

    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

     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902
    Originator: NO

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

     
  • Donal K. Fellows

    • milestone: --> 723989
    • status: open --> open-works-for-me
     
  • miguel sofer

    miguel sofer - 2007-08-13
    • milestone: 723989 --> obsolete: 8.5a7
     
  • miguel sofer

    miguel sofer - 2007-08-13
    • assigned_to: dgp --> msofer
     
  • Mark Janssen

    Mark Janssen - 2007-08-13

    Logged In: YES
    user_id=1463011
    Originator: YES

    Code segfaults on 8.5a6 on Linux and Windows XP

     
  • Don Porter

    Don Porter - 2007-08-13

    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...

     
  • Don Porter

    Don Porter - 2007-08-13

    Logged In: YES
    user_id=80530
    Originator: NO

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

     
  • Mark Janssen

    Mark Janssen - 2007-08-13

    Logged In: YES
    user_id=1463011
    Originator: YES

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

     
  • Mark Janssen

    Mark Janssen - 2007-08-13

    Test case

     
  • Mark Janssen

    Mark Janssen - 2007-08-13

    Test patch that will not break further tests when failing

     
  • Mark Janssen

    Mark Janssen - 2007-08-13

    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

     
  • Mark Janssen

    Mark Janssen - 2007-08-13

    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].

     
  • Don Porter

    Don Porter - 2007-08-13

    Logged In: YES
    user_id=80530
    Originator: NO

    This bug was first exposed
    by the fix for 1397843.

     
  • Mark Janssen

    Mark Janssen - 2007-08-13

    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)

     
  • Mark Janssen

    Mark Janssen - 2007-08-13

    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

     
  • Don Porter

    Don Porter - 2007-08-13

    Logged In: YES
    user_id=80530
    Originator: NO

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

     
  • Don Porter

    Don Porter - 2007-08-13
    • assigned_to: msofer --> dgp
    • labels: 104240 --> 47. Bytecode Compiler
    • status: open-works-for-me --> closed-fixed
     
  • Don Porter

    Don Porter - 2007-08-13

    Logged In: YES
    user_id=80530
    Originator: NO

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

    Committing it to HEAD.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks