diff options
author | Andy Wingo <wingo@pobox.com> | 2014-03-15 18:56:18 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2014-03-15 18:56:18 +0100 |
commit | 4189a5c0bd4c235c383b043bef69dc66a7ef64d0 (patch) | |
tree | 532118cd442451a66df1011328d0c0270bcb6e1a /test-suite/standalone/test-stack-overflow | |
parent | f764e2590fa1dbcafc5f188e1acc085e6fc6337b (diff) | |
download | guile-4189a5c0bd4c235c383b043bef69dc66a7ef64d0.tar.gz |
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.
Diffstat (limited to 'test-suite/standalone/test-stack-overflow')
-rwxr-xr-x | test-suite/standalone/test-stack-overflow | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test-suite/standalone/test-stack-overflow b/test-suite/standalone/test-stack-overflow new file mode 100755 index 000000000..5a0b77799 --- /dev/null +++ b/test-suite/standalone/test-stack-overflow @@ -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: |