From: SourceForge.net <no...@so...> - 2013-02-13 00:28:41
|
Bugs item #2438181, was opened at 2008-12-16 22:53 Message generated for change (Comment added) made by pooryorick You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=2438181&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 46. Traces Group: obsolete: 8.5.5 Status: Open Resolution: None Priority: 9 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Don Porter (dgp) Summary: Incorrect error reporting in traces Initial Comment: This script: #----------- set pbody "set comms \[list [info commands]\]" append pbody { set pname [lindex $pstr 1] if {[lsearch -exact $comms $pname]!=-1} { puts "$pname already exists" return } puts "Setting trace on: $pname" trace add execution $pname enter my_report2 puts "Trace set" } #This is an error I made: proc my_report {pstr op} $pbody #This was intended, btw...: #proc my_report {pstr args} $pbody proc my_report2 {commstr args} { set pname [lindex $commstr 0] puts "<DEBUG> $pname" } trace add execution proc leave my_report #Testing: rename gets _gets proc gets {a b} { puts "A new gets" } proc exp {a b} { puts $a puts $b } exp 1 2 gets 5 6 #----------- Correctly reports in tclkit8.4.19: ----- wrong # args: should be "my_report pstr op" while executing "proc gets {a b} { puts "A new gets" }" (file "bug.tcl" line 29) ----- But both tcl 8.5.2 and 8.6a3 report: ----- while executing "proc gets {a b} { puts "A new gets" }" (file "bug.tcl" line 29) ----- As you see, error description is missing. ---------------------------------------------------------------------- Comment By: Poor Yorick (pooryorick) Date: 2013-02-12 16:28 Message: oops, the following code chunk isn't part of the fix: @@ -2671,11 +2679,13 @@ ---------------------------------------------------------------------- Comment By: Poor Yorick (pooryorick) Date: 2013-02-12 16:24 Message: 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 } ---------------------------------------------------------------------- Comment By: Poor Yorick (pooryorick) Date: 2013-02-11 21:12 Message: Here's a more concise snippet that illustrates the problem, and takes it further by illustrating that the interpreter result for the set command remains in effect and is reported as the error: trace add execution set leave { puts one two three ;#} puts "hmm..." set a hello ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=2438181&group_id=10894 |