1# Tests that the stack size is big enough for the application. 2# 3# This file contains a collection of tests for one or more of the Tcl 4# built-in commands. Sourcing this file into Tcl runs the tests and 5# generates output for errors. No output means no errors were found. 6# 7# Copyright © 1998-2000 Ajuba Solutions. 8# 9# See the file "license.terms" for information on usage and redistribution 10# of this file, and for a DISCLAIMER OF ALL WARRANTIES. 11 12if {"::tcltest" ni [namespace children]} { 13 package require tcltest 2.5 14 namespace import -force ::tcltest::* 15} 16 17# Note that a failure in this test may result in a crash of the executable. 18 19test stack-1.1 {maxNestingDepth reached on infinite recursion} -body { 20 # do this in a sub process in case it segfaults 21 exec [interpreter] << { 22 proc recurse {} { recurse } 23 catch { recurse } rv 24 puts $rv 25 } 26} -result {too many nested evaluations (infinite loop?)} 27 28test stack-2.1 {maxNestingDepth reached on infinite recursion} -body { 29 # do this in a sub process in case it segfaults 30 exec [interpreter] << { 31 interp alias {} unknown {} notaknownproc 32 catch { unknown } msg 33 puts $msg 34 } 35} -result {too many nested evaluations (infinite loop?)} 36 37# Make sure that there is enough stack to run regexp even if we're 38# close to the recursion limit. [Bug 947070] [Patch 746378] 39test stack-3.1 {enough room for regexp near recursion limit} -body { 40 # do this in a sub process in case it segfaults 41 exec [interpreter] << { 42 interp recursionlimit {} 10000 43 set depth 0 44 proc a { max } { 45 if { [info level] < $max } { 46 set ::depth [info level] 47 a $max 48 } else { 49 regexp {^ ?} x 50 } 51 } 52 catch { a 10001 } 53 set depth2 $depth 54 puts [list [a $depth] [expr { $depth2 - $depth }]] 55 } 56} -result {1 1} 57 58# cleanup 59::tcltest::cleanupTests 60return 61 62# Local Variables: 63# mode: tcl 64# End: 65