From 15ea576825e88e331bf03f5634a2a2dd1a0cdc10 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Fri, 20 Nov 2009 11:48:12 +0000 Subject: [PATCH] 1.0.32.35: SB-POSIX:FORK guards against forking with multiple threads * 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 | 3 +++ contrib/sb-posix/interface.lisp | 14 ++++++++++---- src/compiler/globaldb.lisp | 1 - version.lisp-expr | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 493e7a0..f9f888b 100644 --- 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 diff --git a/contrib/sb-posix/interface.lisp b/contrib/sb-posix/interface.lisp index 1da9d8f..d40fd7d 100644 --- a/contrib/sb-posix/interface.lisp +++ b/contrib/sb-posix/interface.lisp @@ -281,10 +281,16 @@ (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 diff --git a/src/compiler/globaldb.lisp b/src/compiler/globaldb.lisp index 394e020..6f0bc7a 100644 --- a/src/compiler/globaldb.lisp +++ b/src/compiler/globaldb.lisp @@ -344,7 +344,6 @@ ;;;; 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) diff --git a/version.lisp-expr b/version.lisp-expr index 3de71c0..7c4bc34 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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" -- 1.7.10.4