|
2026-11-27
| ||
| 15:26 | • Pending ticket [afa8c9f5bb]: Error in an execution trace reports line 1 and lose... artifact: 82c415b0ef user: jan.nijtmans | |
|
2013-03-21
| ||
| 20:19 | • Closed ticket [2438181fff]: Incorrect error reporting in traces plus 6 other... artifact: 490fdbf3cc user: dgp | |
|
2013-02-19
| ||
| 17:59 | • Ticket [2438181fff]: 1 change artifact: 096332dbf9 user: nijtmans | |
| 17:59 | • Ticket [2438181fff]: 1 change artifact: 0fe958c2a8 user: nijtmans | |
| 17:59 | • Ticket [2438181fff]: 4 changes artifact: 08902bf007 user: nijtmans | |
|
2013-02-14
| ||
| 13:05 | • Ticket [2438181fff]: 4 changes artifact: c619c90492 user: pooryorick | |
|
2013-02-13
| ||
| 07:28 | • Ticket [2438181fff]: 4 changes artifact: 42b2f35e03 user: pooryorick | |
| 07:24 | • Ticket [2438181fff]: 4 changes artifact: eec8ec10ad user: pooryorick | |
|
2013-02-12
| ||
| 12:12 | • Ticket [2438181fff]: 4 changes artifact: 0f7c073149 user: pooryorick | |
|
2013-01-08
| ||
| 02:01 | • Ticket [2438181fff]: 1 change artifact: 0f79e18897 user: dgp | |
|
2008-12-17
| ||
| 06:53 | • New ticket [2438181fff]. artifact: 3e91f08799 user: nobody | |
Incorrect error reporting in traces
Closed / Fixed2438181fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 14 years ago
Descriptionplain2008-12-17 06:53:16
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.
Referenced by1
82c415b0efPending ticket [afa8c9f5bb]: Error in an execution trace reports line 1 and loses the traced command's frame in errorInfo plus 7 other changes ticket2026-11-27 15:26:47
dgp Ticket [2438181fff]: 1 change
[History diff]2013-01-08 02:01:35
pooryorickplain2013-02-12 12:12:57
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
pooryorickplain2013-02-13 07:24:05
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
}
pooryorickplain2013-02-13 07:28:40
oops, the following code chunk isn't part of the fix: @@ -2671,11 +2679,13 @@
pooryorickplain2013-02-14 13:05:22
the fix below is also at: https://ynform.org/fossil/tcl/info/45968549a8
nijtmansplain2013-02-19 17:59:36
Proposed fix committed to all branches. Given that the functions TclCheckExecutionTraces and TclCheckInterpTraces and were different in the saving/restoring of the interpreter state, there is little doubt to me that this is the right approach. Don, feel free to evaluate.
nijtmans Ticket [2438181fff]: 1 change
[History diff]2013-02-19 17:59:37
nijtmans Ticket [2438181fff]: 1 change
[History diff]2013-02-19 17:59:50
dgpplain2013-03-21 20:19:34
allow_comments - 1
Log in (anonymous is fine) to add a comment.