1 ;;;; tests of the system's ability to catch resource exhaustion problems
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
14 #+interpreter
(sb-ext:exit
:code
104)
16 (cl:in-package
:cl-user
)
18 (load "test-util.lisp")
19 (load "assertoid.lisp")
20 (use-package "TEST-UTIL")
21 (use-package "ASSERTOID")
24 ;;; Prior to sbcl-0.7.1.38, doing something like (RECURSE), even in
25 ;;; safe code, would crash the entire Lisp process. Then the soft
26 ;;; stack checking was introduced, which checked (in safe code) for
27 ;;; stack exhaustion at each lambda.
29 ;;; Post 0.7.6.1, this was rewritten to use mprotect()-based stack
30 ;;; protection which does not require lisp code to check anything,
31 ;;; and works at all optimization settings. However, it now signals a
32 ;;; STORAGE-CONDITION instead of an ERROR.
40 ;;; Base-case: detecting exhaustion
41 (with-test (:name
(:exhaust
:basic
) :broken-on
'(and :sunos
:x86-64
))
42 (assert (eq :exhausted
45 (storage-condition (c)
49 ;;; Check that non-local control transfers restore the stack
50 ;;; exhaustion checking after unwinding -- and that previous test
52 (with-test (:name
(:exhaust
:non-local-control
)
53 :broken-on
'(and :sunos
:x86-64
)
55 (let ((exhaust-count 0)
59 (handler-bind ((storage-condition (lambda (c)
61 (if (= *count
* (incf exhaust-count
))
67 (assert (= exhaust-count recurse-count
*count
*))))
69 ;;; Check that we can safely use user-provided restarts to
71 (with-test (:name
(:exhaust
:restarts
)
72 :broken-on
'(and :sunos
:x86-64
)
74 (let ((exhaust-count 0)
77 (handler-bind ((storage-condition (lambda (c)
79 (if (= *count
* (incf exhaust-count
))
81 (invoke-restart (find-restart 'ok
))))))
83 (with-simple-restart (ok "ok")
86 (assert (= exhaust-count recurse-count
*count
*))))
88 (with-test (:name
(:exhaust
:binding-stack
))
90 (symbols (loop repeat
1024 collect
(gensym)))
91 (values (loop repeat
1024 collect nil
)))
93 (labels ((exhaust-binding-stack (i)
95 (exhaust-binding-stack (1+ i
)))))
97 (exhaust-binding-stack 0)
98 (sb-kernel::binding-stack-exhausted
()
102 (with-test (:name
(:exhaust
:alien-stack
)
103 :skipped-on
'(or (not :c-stack-is-control-stack
)))
105 (labels ((exhaust-alien-stack (i)
106 (with-alien ((integer-array (array int
500)))
107 (+ (deref integer-array
0)
108 (exhaust-alien-stack (1+ i
))))))
110 (exhaust-alien-stack 0)
111 (sb-kernel::alien-stack-exhausted
()