0.7.1.23:
authorWilliam Harold Newman <william.newman@airmail.net>
Thu, 21 Feb 2002 23:01:25 +0000 (23:01 +0000)
committerWilliam Harold Newman <william.newman@airmail.net>
Thu, 21 Feb 2002 23:01:25 +0000 (23:01 +0000)
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

BUGS
NEWS
build-order.lisp-expr
make-host-2.sh
package-data-list.lisp-expr
src/code/exhaust.lisp [new file with mode: 0644]
src/code/load.lisp
src/compiler/ir1tran.lisp
version.lisp-expr

diff --git a/BUGS b/BUGS
index 7f00c53..bdf4781 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -1322,4 +1322,4 @@ WORKAROUND:
 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.
diff --git a/NEWS b/NEWS
index 7022c2d..63fda87 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1020,16 +1020,24 @@ changes in sbcl-0.7.2 relative to sbcl-0.7.1:
   * 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
index d8f8445..e8b6315 100644 (file)
 
  ("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)
index 59afc86..19a7552 100644 (file)
@@ -58,7 +58,10 @@ $SBCL_XC_HOST <<-'EOF' || exit 1
            (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)
index 581a10e..7b7023a 100644 (file)
@@ -916,7 +916,7 @@ is a good idea, but see SB-SYS re. blurring of boundaries."
              "%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"
diff --git a/src/code/exhaust.lisp b/src/code/exhaust.lisp
new file mode 100644 (file)
index 0000000..50c5bdb
--- /dev/null
@@ -0,0 +1,23 @@
+;;;; 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))
index f74a2bc..c04b5f9 100644 (file)
   (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
index 3151b25..7d7b4be 100644 (file)
          (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
index 493a90c..ec6c88d 100644 (file)
@@ -18,4 +18,4 @@
 ;;; 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"