1.0.32.35: SB-POSIX:FORK guards against forking with multiple threads
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 20 Nov 2009 11:48:12 +0000 (11:48 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 20 Nov 2009 11:48:12 +0000 (11:48 +0000)
  * It wasn't going to work right in any case, so better to refuse up
    front.

  * Remove invalid FIXME from globaldb.lisp: DO-INFO is also used by
    SB-INTROSPECT.

NEWS
contrib/sb-posix/interface.lisp
src/compiler/globaldb.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 493e7a0..f9f888b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,9 @@ changes relative to sbcl-1.0.32:
        streams after an UNREAD-CHAR.
   * enhancement: SB-INTROSPECT:ALLOCATION-INFORMATION also reports if the
     object is allocated in a boxed region of dynamic space.
+  * enhancement: SB-POSIX:FORK now signals an error if an attempt to
+    fork with multiple Lisp threads running is made, instead of going
+    ahead with unpredictable consequences. (reported by Leslie Polzer)
   * bug fix: uses of slot accessors on specialized method parameters within
     the bodies of SLOT-VALUE-USING-CLASS methods no longer triggers a type
     error while finalizing the class.  This fix may cause classes with slot
index 1da9d8f..d40fd7d 100644 (file)
     (define-call "setup_mach_exceptions" void never-fails)
     (define-call ("posix_fork" :c-name "fork") pid-t minusp)
     (defun fork ()
-      (let ((pid (posix-fork)))
-        (when (= pid 0)
-          (setup-mach-exceptions))
-        pid))
+      (tagbody
+         (sb-thread::with-all-threads-lock
+           (when (cdr sb-thread::*all-threads*)
+             (go :error))
+           (let ((pid (posix-fork)))
+             (when (= pid 0)
+               (setup-mach-exceptions))
+             (return-from fork pid)))
+       :error
+         (error "Cannot fork with multiple threads running.")))
     (export 'fork :sb-posix))
 
   #-mach-exception-handler
index 394e020..6f0bc7a 100644 (file)
 \f
 ;;;; generic interfaces
 
-;;; FIXME: used only in this file, needn't be in runtime
 (defmacro do-info ((env &key (name (gensym)) (class (gensym)) (type (gensym))
                         (type-number (gensym)) (value (gensym)) known-volatile)
                    &body body)
index 3de71c0..7c4bc34 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.32.34"
+"1.0.32.35"