mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 07:30:32 +02:00
Add stack overflow test
* libguile/throw.c (throw_without_pre_unwind): Newline after the unwind-only warning. * test-suite/standalone/Makefile.am: * test-suite/standalone/test-stack-overflow: New test to handle mmap/malloc failure.
This commit is contained in:
parent
f764e2590f
commit
4189a5c0bd
3 changed files with 43 additions and 2 deletions
38
test-suite/standalone/test-stack-overflow
Executable file
38
test-suite/standalone/test-stack-overflow
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
exec guile -q -s "$0" "$@"
|
||||
!#
|
||||
|
||||
(unless (defined? 'setrlimit)
|
||||
;; Without an rlimit, this test can take down your system, as it
|
||||
;; consumes all of your memory in stack space. That doesn't seem like
|
||||
;; something we should run as part of an automated test suite.
|
||||
(exit 0))
|
||||
|
||||
;; 100 MB.
|
||||
(define *limit* (* 100 1024 1024))
|
||||
|
||||
(call-with-values (lambda () (getrlimit 'as))
|
||||
(lambda (soft hard)
|
||||
(unless (and soft (< soft *limit*))
|
||||
(setrlimit 'as (if hard (min *limit* hard) *limit*) hard))))
|
||||
|
||||
(define (test)
|
||||
(catch 'stack-overflow
|
||||
(lambda ()
|
||||
(let lp ()
|
||||
(lp)
|
||||
(error "should not be reached")))
|
||||
(lambda _
|
||||
#t)))
|
||||
|
||||
;; Run the test a few times. The stack will only be enlarged and
|
||||
;; relocated on the first one.
|
||||
(test)
|
||||
(test)
|
||||
(test)
|
||||
(test)
|
||||
(test)
|
||||
|
||||
;; Local Variables:
|
||||
;; mode: scheme
|
||||
;; End:
|
Loading…
Add table
Add a link
Reference in a new issue