summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2019-08-29 20:28:47 (GMT)
committersebres <sebres@users.sourceforge.net>2019-08-29 20:28:47 (GMT)
commitee6b2e34559aa9915b480794418f1db489d723a8 (patch)
treedade39db94375f9727e8b657999a439fcc36bc39
parentac370c9a7305ebde8a9d3439fa5260e925d3bba3 (diff)
downloadtcl-ee6b2e34559aa9915b480794418f1db489d723a8.zip
tcl-ee6b2e34559aa9915b480794418f1db489d723a8.tar.gz
tcl-ee6b2e34559aa9915b480794418f1db489d723a8.tar.bz2
add test cases covering nested compilation bug [fec0c17d39] (8.5 is not affected at the moment by nested count under 2500)
-rw-r--r--tests/compile.test31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/compile.test b/tests/compile.test
index 7646c12..c9f1b71 100644
--- a/tests/compile.test
+++ b/tests/compile.test
@@ -422,6 +422,37 @@ test compile-13.1 {testing underestimate of maxStackSize in list cmd} {exec} {
list [catch {exec [interpreter] << $script} msg] $msg
} {0 OK}
+# Tests of nested compile (body in body compilation), should not generate stack overflow
+# (with abnormal program termination), bug [fec0c17d39]:
+test compile-13.2 {TclCompileScript: testing nested scripts compilation} -setup {
+ set i [interp create]
+ interp recursionlimit $i [expr {10000+50}]
+ $i eval {proc gencode {nr {cmd eval} {nl 0}} {
+ set code ""
+ set e ""; if {$nl} {set e "\n"}
+ for {set i 0} {$i < $nr} {incr i} {
+ append code "$cmd \{$e"
+ }
+ append code "lappend result 1$e"
+ for {set i 0} {$i < $nr} {incr i} {
+ append code "\}$e"
+ }
+ #puts [format "%% %.40s ... %d bytes" $code [string length $code]]
+ return $code
+ }}
+} -body {
+ # Test different compilation variants (instructions evalStk, invokeStk, etc),
+ # with 2000 nested scripts (bodies). If you get SO/SF exceptions on some low-stack
+ # boxes or systems, please don't decrease it (either provide a constraint)
+ $i eval {foreach cmd {eval "if 1" catch} {
+ set c [gencode 2000 $cmd]
+ if 1 $c
+ }}
+ $i eval {set result}
+} -result {1 1 1} -cleanup {
+ interp delete $i
+}
+
# Tests compile-14.* for [Bug 599788] [Bug 0c043a175a47da8c2342]
test compile-14.1 {testing errors in element name; segfault?} {} {
catch {set a([error])} msg1