Update of /cvsroot/sbcl/sbcl/src/code
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv17254/src/code
Modified Files:
cold-init.lisp early-impl.lisp signal.lisp
target-hash-table.lisp target-thread.lisp toplevel.lisp
Log Message:
1.0.4.30: make WITH-SPINLOCK-AND-WITHOUT-GCING inhibit interrupts as well
* Previously we could catch an interrupt while GC was inhibited, and
hence any locks the interrupt handler was using could not know if
they were being used with GC enabled or not => GC deadlocks.
* Since this was detected by the runtime warning in WITH-INTERRUPTS
about re-enabling interrupts while GC is inhibited keep it around
in case we have more places this can happen.
* Make MAYBE-HANDLE-PENDING-GC check for pending interrupts as well.
* While we're at it, make WITH-SPINLOCK slightly safer: don't release
locks we didn't obtain, and make us grab the lock inside the UWP.
...not 100% given in the presence of asynch unwinds, but better.
* Also move *INTERRUPTS-ENABLED* and *INTERRUPT-PENDING* to SB-SYS.
* Whitespace in WITHOUT-INTERRUPTS.
Index: cold-init.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/cold-init.lisp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- cold-init.lisp 17 Nov 2006 02:15:47 -0000 1.69
+++ cold-init.lisp 6 Apr 2007 09:58:08 -0000 1.70
@@ -96,8 +96,8 @@
*gc-inhibit* t
*gc-pending* nil
#!+sb-thread *stop-for-gc-pending* #!+sb-thread nil
- sb!unix::*interrupts-enabled* t
- sb!unix::*interrupt-pending* nil
+ *interrupts-enabled* t
+ *interrupt-pending* nil
*break-on-signals* nil
*maximum-error-depth* 10
*current-error-depth* 0
Index: early-impl.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/early-impl.lisp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- early-impl.lisp 17 Nov 2006 02:15:47 -0000 1.19
+++ early-impl.lisp 6 Apr 2007 09:58:08 -0000 1.20
@@ -33,8 +33,8 @@
;; pseudo-atomicity too, but they handle it without
;; messing with special variables.)
#!+(or x86 x86-64) *pseudo-atomic-bits*
- sb!unix::*interrupts-enabled*
- sb!unix::*interrupt-pending*
+ *interrupts-enabled*
+ *interrupt-pending*
*free-interrupt-context-index*
sb!vm::*allocation-pointer*
sb!vm::*binding-stack-pointer*
Index: signal.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/signal.lisp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- signal.lisp 26 Mar 2007 10:30:30 -0000 1.17
+++ signal.lisp 6 Apr 2007 09:58:08 -0000 1.18
@@ -49,23 +49,23 @@
other threads."
(let ((name (gensym "WITHOUT-INTERRUPTS-BODY-")))
`(flet ((,name () ,@body))
- (if *interrupts-enabled*
- (unwind-protect
- (let ((*interrupts-enabled* nil))
- (,name))
- ;; If we were interrupted in the protected section, then
- ;; the interrupts are still blocked and it remains so
- ;; until the pending interrupt is handled.
- ;;
- ;; If we were not interrupted in the protected section,
- ;; but here, then even if the interrupt handler enters
- ;; another WITHOUT-INTERRUPTS, the pending interrupt will
- ;; be handled immediately upon exit from said
- ;; WITHOUT-INTERRUPTS, so it is as if nothing has
- ;; happened.
- (when *interrupt-pending*
- (receive-pending-interrupt)))
- (,name)))))
+ (if *interrupts-enabled*
+ (unwind-protect
+ (let ((*interrupts-enabled* nil))
+ (,name))
+ ;; If we were interrupted in the protected section, then
+ ;; the interrupts are still blocked and it remains so
+ ;; until the pending interrupt is handled.
+ ;;
+ ;; If we were not interrupted in the protected section,
+ ;; but here, then even if the interrupt handler enters
+ ;; another WITHOUT-INTERRUPTS, the pending interrupt will
+ ;; be handled immediately upon exit from said
+ ;; WITHOUT-INTERRUPTS, so it is as if nothing has
+ ;; happened.
+ (when *interrupt-pending*
+ (receive-pending-interrupt)))
+ (,name)))))
(sb!xc:defmacro with-interrupts (&body body)
#!+sb-doc
Index: target-hash-table.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/target-hash-table.lisp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- target-hash-table.lisp 31 Mar 2007 10:12:16 -0000 1.31
+++ target-hash-table.lisp 6 Apr 2007 09:58:08 -0000 1.32
@@ -21,8 +21,10 @@
(defmacro with-spinlock-and-without-gcing ((spinlock) &body body)
#!-sb-thread
(declare (ignore spinlock))
- (with-unique-names (old-gc-inhibit)
+ (with-unique-names (old-gc-inhibit old-interrupts-enabled)
`(let ((,old-gc-inhibit *gc-inhibit*)
+ (,old-interrupts-enabled *interrupts-enabled*)
+ (*interrupts-enabled* nil)
(*gc-inhibit* t))
(unwind-protect
(progn
@@ -31,8 +33,10 @@
,@body)
#!+sb-thread
(sb!thread::release-spinlock ,spinlock)
- (let ((*gc-inhibit* ,old-gc-inhibit))
- ;; the test is racy, but it can err only on the overeager side
+ (let ((*interrupts-enabled* ,old-interrupts-enabled)
+ (*gc-inhibit* ,old-gc-inhibit))
+ ;; the test is racy, but it can err only on the overeager
+ ;; side
(sb!kernel::maybe-handle-pending-gc))))))
(eval-when (:compile-toplevel :load-toplevel :execute)
Index: target-thread.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/target-thread.lisp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- target-thread.lisp 26 Mar 2007 15:30:07 -0000 1.65
+++ target-thread.lisp 6 Apr 2007 09:58:08 -0000 1.66
@@ -208,12 +208,15 @@
(sb!vm::%instance-set spinlock 2 0))
(defmacro with-spinlock ((spinlock) &body body)
- (sb!int:with-unique-names (lock)
- `(let ((,lock ,spinlock))
- (get-spinlock ,lock)
+ (sb!int:with-unique-names (lock got-it)
+ `(let ((,lock ,spinlock)
+ (,got-it nil))
(unwind-protect
- (progn ,@body)
- (release-spinlock ,lock)))))
+ (progn
+ (setf ,got-it (get-spinlock ,lock))
+ (locally ,@body))
+ (when ,got-it
+ (release-spinlock ,lock))))))
;;;; mutexes
Index: toplevel.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/code/toplevel.lisp,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- toplevel.lisp 26 Oct 2006 16:07:54 -0000 1.92
+++ toplevel.lisp 6 Apr 2007 09:58:09 -0000 1.93
@@ -26,8 +26,8 @@
;;; FIXME: These could be converted to DEFVARs.
(declaim (special #!+(or x86 x86-64) *pseudo-atomic-bits*
- sb!unix::*interrupts-enabled*
- sb!unix::*interrupt-pending*
+ *interrupts-enabled*
+ *interrupt-pending*
*type-system-initialized*))
(defvar *cold-init-complete-p*)
|