summaryrefslogtreecommitdiffstats
path: root/tests/compile.test
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2010-11-03 00:58:04 (GMT)
committerKevin B Kenny <kennykb@acm.org>2010-11-03 00:58:04 (GMT)
commitfddfd6f3b5579bb251e16f894613dd1660bd60da (patch)
tree0c43533930e06d21c62cd9b2236c2e2bdf19a27b /tests/compile.test
parentb2694cb09fefbce3de045cb20db90eda56abfb8d (diff)
downloadtcl-fddfd6f3b5579bb251e16f894613dd1660bd60da.zip
tcl-fddfd6f3b5579bb251e16f894613dd1660bd60da.tar.gz
tcl-fddfd6f3b5579bb251e16f894613dd1660bd60da.tar.bz2
* generic/tclCompCmds.c (TclCompileCatchCmd):
* tests/compile.test (compile-3,6): Reworked the compilation of the [catch] command so as to avoid placing any code that might throw an exception (specifically, any initial substitutions or any stores to result or options variables) between the BEGIN_CATCH and END_CATCH but outside the exception range. Added a test case that panics on a stack smash if the change is not made. [Bug #3098302]
Diffstat (limited to 'tests/compile.test')
-rw-r--r--tests/compile.test32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/compile.test b/tests/compile.test
index 57a1a3c..de77438 100644
--- a/tests/compile.test
+++ b/tests/compile.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: compile.test,v 1.48.2.2 2009/10/29 17:21:18 dgp Exp $
+# RCS: @(#) $Id: compile.test,v 1.48.2.3 2010/11/03 00:58:04 kennykb Exp $
package require tcltest 2
namespace import -force ::tcltest::*
@@ -128,6 +128,36 @@ test compile-3.5 {TclCompileCatchCmd: recover from error, [Bug 705406]} {
}
list [catch foo msg] $msg
} {0 1}
+test compile-3.6 {TclCompileCatchCmd: error in storing result [Bug 3098302]} {*}{
+ -setup {
+ namespace eval catchtest {
+ variable result1 {}
+ }
+ trace add variable catchtest::result1 write catchtest::failtrace
+ proc catchtest::failtrace {n1 n2 op} {
+ return -code error "trace on $n1 fails by request"
+ }
+ }
+ -body {
+ proc catchtest::x {} {
+ variable result1
+ set count 0
+ for {set i 0} {$i < 10} {incr i} {
+ set status2 [catch {
+ set status1 [catch {
+ return -code error -level 0 "original failure"
+ } result1 options1]
+ } result2 options2]
+ incr count
+ }
+ list $count $result2
+ }
+ catchtest::x
+ }
+ -result {10 {can't set "result1": trace on result1 fails by request}}
+ -cleanup {namespace delete catchtest}
+}
+
test compile-4.1 {TclCompileForCmd: command substituted test expression} {
set i 0