Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: eec8ec10ade390844983f097841c571740537af8
Ticket: 2438181fffffffffffffffffffffffffffffffff
Incorrect error reporting in traces
User & Date: pooryorick on 2013-02-13 07:24:05
Changes

  1. icomment:
    Here's a proposed fix and a test:
    
    Index: generic/tclTrace.c
    ==================================================================
    --- generic/tclTrace.c
    +++ generic/tclTrace.c
    @@ -1483,11 +1483,15 @@
                lastTracePtr = active.nextTracePtr->nextPtr;
            }
         }
         iPtr->activeCmdTracePtr = active.nextPtr;
         if (state) {
    -       Tcl_RestoreInterpState(interp, state);
    +       if (traceCode) {
    +           Tcl_DiscardInterpState(state);
    +       } else {
    +           Tcl_RestoreInterpState(interp, state);
    +       }
         }
     
         return traceCode;
     }
     
    @@ -2671,11 +2679,13 @@
                if (code == TCL_ERROR) {
                    goto done;
                }
            }
            /*
    -       * an array trace may have caused the variable to exist
    +       * an array trace may have caused the variable to exist. This section
    +       * and the one similar to it after the variable traces below are
    +       * executed addresses bugs like #3603163 and #3599017
            */
            varPtr2 = TclObjLookupVarEx((Tcl_Interp *) iPtr
                , Tcl_NewStringObj(part1 ,-1)
                , Tcl_NewStringObj(part2 ,-1)
                , flags ,"read" ,/*createPart1*/ 0 ,/*createPart2*/ 0 ,&newArrayPtr
    
    Index: tests/trace.test
    ==================================================================
    --- tests/trace.test
    +++ tests/trace.test
    @@ -2328,10 +2328,22 @@
     } -cleanup {
         namespace delete a
         rename ::x {}
     } -result {:: ::}
     
    +proc set2 args {
    +    set {*}$args
    +}
    +
    +test trace-22.11.$mode {} {
    +    body {} {
    +       trace add execution set2 leave {puts one two three #;} 
    +    } {
    +       set2 a hello
    +    }
    +} {1 {wrong # args: should be "puts ?-nonewline? ?channelId? string"} {}}
    +
     proc factorial {n} {
         if {$n != 1} { return [expr {$n * [factorial [expr {$n -1 }]]}] }
         return 1
     }
    
    
    
  2. login: "pooryorick"
  3. mimetype: "text/plain"
  4. username: "pooryorick"