Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 284b0a4b953ad3d39d4aaffe4f1fe8edf8e413ce
Ticket: 571385ffffffffffffffffffffffffffffffffff
segfaults in execution tracing.
User & Date: hemanglavana on 2002-06-20 20:02:14
Changes

  1. icomment:
    Logged In: YES 
    user_id=81875
    
    Since there are no execution traces involved, 
    
    (cmdPtr->flags & CMD_HAS_EXEC_TRACES) 
    
    should never be true unless cmdPtr is pointing
    to arbitrary memory location. cmdPtr may be
    NULL or even if cmdPtr is invalidated, the above
    condition should not be true. So, we need to
    first figure out, why this bit was set.
    
    I could not replicate this problem on solaris2.6:
    godel:76> /tmp/hlavana/tcltk/bin/tclsh8.4
    % info patch
    8.4a5
    % proc foo {} {
    proc foo {} {puts NEW}
    uplevel foo
    }
    % foo
    NEW
    % exit
    godel:77>
    
    Don, can you provide the script that gives seg. fault.
    
    Next question is: what should be its behavior
    when execution traces are set and the command
    has been modified in some way. The execution
    traces should be disabled.
    
    Although I am not very familiar with 'cmdPtr->cmdEpoch',
    a cursory look at the code tells me that it is sufficient to
    check whether 'cmdPtr->cmdEpoch' has been modified
    or not (it covers CMD_IS_DELTED case as well). I am
    providing the following patch to prevent 'leave' traces
    from being invoked when the command itself has been
    modified.
    
    godel:80> cvs diff tclBasic.c 
    Index: tclBasic.c
    ===================================================================
    RCS file: /cvsroot/tcl/tcl/generic/tclBasic.c,v
    retrieving revision 1.61
    diff -r1.61 tclBasic.c
    2927a2928
    >     int cmdEpoch;
    2974a2976,2985
    >          * According to tclInt.h, cmdPtr->cmdEpoch is incremented 
    >          * to invalidate any references that point to this command 
    >          * when the it is renamed, deleted, hidden, or exposed. 
    >          * Save the current value of cmdPtr->cmdEpoch, so that we
    >          * can use it later on to find out if the command has been
    >          * modified in any way or not.
    >          */
    >         cmdEpoch = cmdPtr->cmdEpoch;
    > 
    >         /*
    2978d2988
    <             int cmdEpoch = cmdPtr->cmdEpoch;
    3021c3031,3032
    <      * Call 'leave' command traces
    ---
    >      * If the command has been modified in any while executing the code, 
    >      * then do not call any traces.
    3023,3025c3034,3035
    <     if ((cmdPtr->flags & CMD_HAS_EXEC_TRACES) && (traceCode == TCL_OK)) {
    <       traceCode = TclCheckExecutionTraces(interp, command, length,
    <                      cmdPtr, code, TCL_TRACE_LEAVE_EXEC, objc, objv);
    ---
    >     if (cmdEpoch != cmdPtr->cmdEpoch) {
    >         checkTraces = 0;
    3027,3028c3037,3043
    <     if (iPtr->tracePtr != NULL && traceCode == TCL_OK) {
    <       traceCode = TclCheckInterpTraces(interp, command, length,
    ---
    > 
    >     /*
    >      * Call 'leave' command traces, if needed.
    >      */
    >     if ((checkTraces) && (command != NULL)) {
    >         if ((cmdPtr->flags & CMD_HAS_EXEC_TRACES) && (traceCode == TCL_OK)) {
    >           traceCode = TclCheckExecutionTraces(interp, command, length,
    3029a3045,3049
    >         }
    >         if (iPtr->tracePtr != NULL && traceCode == TCL_OK) {
    >           traceCode = TclCheckInterpTraces(interp, command, length,
    >                      cmdPtr, code, TCL_TRACE_LEAVE_EXEC, objc, objv);
    >         }
    godel:81> 
    
    
  2. login: "hemanglavana"
  3. mimetype: "text/plain"
  4. username: "hemanglavana"