catching stack overflow, part I...
...defined placeholder %DETECT-STACK-EXHAUSTION
...arranged for it to be called on entry to lambdas when
(OR (> SAFETY (MAX SPEED SPACE)) (= SAFETY 3))
...downgraded SAFETY to 2 (= SPEED) in SBCL's own code, since
SBCL's own code seems to be at little risk of infinite
recursion
DEFUNCT CATEGORIES OF BUGS
IR1-#:
These labels were used for bugs related to the old IR1 interpreter.
- The # values reached 6 before the category was closed down.
\ No newline at end of file
+ The # values reached 6 before the category was closed down.
* new syntactic sugar for the Unix command line: --load foo.bar is now
an alternate notation for --eval '(load "foo.bar")'.
* bug fixes:
+ ?? The system now detects stack overflow and handles it gracefully,
+ at least for (OR (> SAFETY (MAX SPEED SPACE)) (= SAFETY 3))
+ optimization settings. (This is a good thing in general, and
+ its introduction in this version should be particularly timely
+ for anyone whose code fails because of suppression of tail
+ recursion!)
** The system now hunts for the C variable "environ" in a more
devious way, to avoid segfaults when the C library version differs
between compile time and run time. (thanks to Christophe Rhodes)
- ** INTEGER-valued CATCH tags now work. (thanks to Alexey Dejneka)
+ ** INTEGER-valued CATCH tags now work. (thanks to Alexey Dejneka,
+ and also to Christophe Rhodes for porting the fix to non-X86 CPUs)
** The compiler no longer issues bogus style warnings for undefined
classes in the same source file as the DEFCLASSes which defined
them. (thanks to Stig E Sandoe for reporting and Martin Atzmueller
for fixing this)
* several changes related to debugging:
** suppression of tail recursion, as noted above
+ ** stack overflow detection, as noted above
** The default implementation of TRACE has changed. :ENCAPSULATE T
is now the default. (For some time encapsulation has been more
reliable than the breakpoint-based :ENCAPSULATE NIL
("src/code/stubs" :not-host)
+ ("src/code/exhaust" :not-host)
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; compiler (and a few miscellaneous files whose dependencies make it
;;; convenient to stick them here)
(sb-xc:proclaim `(optimize (compilation-speed 1)
(debug ,debug)
(sb!ext:inhibit-warnings 2)
- (safety 3)
+ ;; SAFETY = SPEED (and < 3) should
+ ;; reasonable safety, but might skip
+ ;; some unreasonably expensive stuff.
+ (safety 2)
(space 1)
(speed 2)))))
(compile 'proclaim-target-optimization)
"%ATAN" "%ATAN2" "%ATANH"
"%CALLER-FRAME-AND-PC" "%CHECK-BOUND" "%CLOSURE-FUN"
"%CLOSURE-INDEX-REF" "%COS" "%COS-QUICK"
- "%COSH" "%DEPOSIT-FIELD"
+ "%COSH" "%DEPOSIT-FIELD" "%DETECT-STACK-EXHAUSTION"
"%DOUBLE-FLOAT" "%DPB" "%EXP" "%EXPM1"
"%FIND-POSITION" "%FIND-POSITION-VECTOR-MACRO"
"%FIND-POSITION-IF" "%FIND-POSITION-IF-VECTOR-MACRO"
--- /dev/null
+;;;; detecting and handling exhaustion of memory (stack or heap)
+
+;;;; This software is part of the SBCL system. See the README file for
+;;;; more information.
+;;;;
+;;;; This software is derived from the CMU CL system, which was
+;;;; written at Carnegie Mellon University and released into the
+;;;; public domain. The software is in the public domain and is
+;;;; provided with absolutely no warranty. See the COPYING and CREDITS
+;;;; files for more information.
+
+(in-package "SB!KERNEL")
+
+;;; FIXME: Even though this is only called when (> SAFETY (MAX SPEED SPACE))
+;;; it's still annoyingly wasteful for it to be a full function call.
+;;; It should probably be a VOP calling an assembly routine or something
+;;; like that.
+(defun %detect-stack-exhaustion ()
+ ;; FIXME: Check the stack pointer against *STACK-EXHAUSTION*, and if
+ ;; out of range signal an error (in a context where *S-E* has been
+ ;; rebound to give some space to let error handling code do its
+ ;; thing without new exhaustion problems).
+ (values))
(let ((prefixes
#!+(or linux freebsd) #("" "ldso_stub__")
#!+openbsd #("" "_")))
+ (declare (notinline some)) ; to suppress bug 117 bogowarning
(some (lambda (prefix)
(gethash (concatenate 'string prefix name)
table
(continuation-starts-block cont1)
(link-node-to-previous-continuation bind cont1)
(use-continuation bind cont2)
- (ir1-convert-special-bindings cont2 result body aux-vars aux-vals
- (svars)))
+ (ir1-convert-special-bindings cont2 result
+ (if (policy bind
+ (or (> safety
+ (max speed space))
+ (= safety 3)))
+ ;; (Stuffing this in at IR1 level
+ ;; like this is pretty crude. And
+ ;; it's particularly inefficient
+ ;; to execute it on *every* LAMBDA,
+ ;; including LET-converted LAMBDAs.
+ ;; But when SAFETY is high, it's
+ ;; still arguably an improvement
+ ;; over the old CMU CL approach of
+ ;; doing nothing (proactively
+ ;; waiting for evolution to breed
+ ;; stronger programmers:-). -- WHN)
+ `((%detect-stack-exhaustion)
+ ,@body)
+ body)
+ aux-vars aux-vals (svars)))
(let ((block (continuation-block result)))
(when block
;;; for internal versions, especially for internal versions off the
;;; main CVS branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.7.1.22"
+"0.7.1.23"