1.0.37.44: FIND-PACKAGE and FIND-SYMBOL deadlocks
authorNikodemus Siivola <nikodemus@random-state.net>
Tue, 6 Apr 2010 15:11:02 +0000 (15:11 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Tue, 6 Apr 2010 15:11:02 +0000 (15:11 +0000)
 * Instead of linearizing purely on *PACKAGE-LOCK* split the
   responsibilities:

     1) *PACKAGE-GRAPH-LOCK* is responsible for package->package
     links, and package->symbol links.

     2) The hash-table lock on *PACKAGE-NAMES* is responsible for
     string->package associations. (%NAME and %NICKNAMES slots of
     package objects and the hash-table itself.)

   This is enough to allow FIND-SYMBOL and FIND-PACKAGE to always
   complete in finite time. INTERN, etc, can still block if eg.  the
   *PACKAGE-GRAPH-LOCK* is held by a thread waiting for the debugger,
   etc -- but the reader is at least able to read existing symbols.

 * Additionally, in cases where it is easy, signal some errors while
   *PACKAGE-GRAPH-LOCK* is not held.

NEWS
src/code/defpackage.lisp
src/code/package.lisp
src/code/target-package.lisp
tests/packages.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index f6228a5..0b9501a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,8 @@ changes relative to sbcl-1.0.37:
   * bug fix: allow forward FIND and POSITION on lists to elide checking :END
     against length of the list if the element is found before the specified
     END is reached. (thanks to Alec Berryman, lp#554385)
+  * bug fix: errors signalled during package graph modification no longer
+    block FIND-SYMBOL and FIND-PACKAGE in other threads. (lp#511072)
 
 changes in sbcl-1.0.37 relative to sbcl-1.0.36:
   * enhancement: Backtrace from THROW to uncaught tag on x86oids now shows
index 5df0f16..3e76f63 100644 (file)
            (type (or simple-string null) doc-string)
            #!-sb-package-locks
            (ignore implement lock))
-  (with-packages ()
+  (with-package-graph ()
     (let* ((existing-package (find-package name))
            (use (use-list-packages existing-package use))
            (shadowing-imports (import-list-symbols shadowing-imports))
index 4a9f7ad..e3d5b84 100644 (file)
@@ -370,7 +370,7 @@ of :INHERITED :EXTERNAL :INTERNAL."
                                                            (setf ,',counter nil)))))))))))))
                 ,@body))))))))
 
-(defmacro-mundanely with-packages ((&key) &body forms)
+(defmacro-mundanely with-package-graph ((&key) &body forms)
   `(flet ((thunk () ,@forms))
      (declare (dynamic-extent #'thunk))
-     (call-with-packages #'thunk)))
+     (call-with-package-graph #'thunk)))
index db1234c..fddb492 100644 (file)
 (!cold-init-forms
   (/show0 "entering !PACKAGE-COLD-INIT"))
 \f
+;;;; Thread safety
+;;;;
+;;;; ...this could still use work, but the basic idea is:
+;;;;
+;;;; *PACKAGE-GRAPH-LOCK* is held via WITH-PACKAGE-GRAPH while working on
+;;;; package graph, including package -> package links, and interning and
+;;;; uninterning symbols.
+;;;;
+;;;; Hash-table lock on *PACKAGE-NAMES* is held via WITH-PACKAGE-NAMES while
+;;;; frobbing name -> package associations.
+;;;;
+;;;; There should be no deadlocks due to ordering issues between these two, as
+;;;; the latter is only held over operations guaranteed to terminate in finite
+;;;; time.
+;;;;
+;;;; Errors may be signalled while holding on to the *PACKAGE-GRAPH-LOCK*,
+;;;; which can still lead to pretty damned inconvenient situations -- but
+;;;; since FIND-PACKAGE, FIND-SYMBOL from other threads isn't blocked by this,
+;;;; the situation isn't *quite* hopeless.
+;;;;
+;;;; A better long-term solution seems to be in splitting the granularity of
+;;;; the *PACKAGE-GRAPH-LOCK* down: for interning a per-package lock should be
+;;;; sufficient, though interaction between parallel intern and use-package
+;;;; needs to be considered with some care.
+
+(defvar *package-graph-lock*)
+(!cold-init-forms
+ (setf *package-graph-lock* (sb!thread:make-mutex :name "Package Graph Lock")))
+
+(defun call-with-package-graph (function)
+  (declare (function function))
+  ;; FIXME: Since name conflicts can be signalled while holding the
+  ;; mutex, user code can be run leading to lock ordering problems.
+  ;;
+  ;; This used to be a spinlock, but there it can be held for a long
+  ;; time while the debugger waits for user input.
+  (sb!thread:with-recursive-lock (*package-graph-lock*)
+    (funcall function)))
+
+;;; a map from package names to packages
+(defvar *package-names*)
+(declaim (type hash-table *package-names*))
+(!cold-init-forms
+ (setf *package-names* (make-hash-table :test 'equal :synchronized t)))
+
+(defmacro with-package-names ((names &key) &body body)
+  `(let ((,names *package-names*))
+     (with-locked-hash-table (,names)
+       ,@body)))
+\f
 ;;;; PACKAGE-HASHTABLE stuff
 
 (def!method print-object ((table package-hashtable) stream)
 ;;; core image
 (defconstant +package-hashtable-image-load-factor+ 0.5)
 
-;;; All destructive package modifications are serialized on this lock,
-;;; plus iterations on *PACKAGE-NAMES*.
-(defvar *package-lock*)
-
-(!cold-init-forms
- (setf *package-lock* (sb!thread:make-mutex :name "Package Lock")))
-
-(defun call-with-packages (function)
-  (declare (function function))
-  ;; FIXME: Since name conflicts can be signalled while holding the
-  ;; mutex, user code can be run leading to lock ordering problems.
-  ;;
-  ;; This used to be a spinlock, but there it can be held for a long
-  ;; time while the debugger waits for user input.
-  (sb!thread:with-recursive-lock (*package-lock*)
-    (funcall function)))
-
 ;;; Make a package hashtable having a prime number of entries at least
 ;;; as great as (/ SIZE +PACKAGE-REHASH-THRESHOLD+). If RES is supplied,
 ;;; then it is destructively modified to produce the result. This is
@@ -329,13 +362,6 @@ error if any of PACKAGES is not a valid package designator."
 ;;; FIXME: should be declared of type PACKAGE, with no NIL init form,
 ;;; after I get around to cleaning up DOCUMENTATION
 
-;;; a map from package names to packages
-(defvar *package-names*)
-(declaim (type hash-table *package-names*))
-(!cold-init-forms
- ;; No lock, accesses are synchonized on WITH-PACKAGES.
- (setf *package-names* (make-hash-table :test 'equal)))
-
 ;;; This magical variable is T during initialization so that
 ;;; USE-PACKAGE's of packages that don't yet exist quietly win. Such
 ;;; packages are thrown onto the list *DEFERRED-USE-PACKAGES* so that
@@ -359,31 +385,30 @@ error if any of PACKAGES is not a valid package designator."
    (find-restart-or-control-error 'debootstrap-package condition)))
 
 (defun find-package (package-designator)
-  (with-packages ()
-    (flet ((find-package-from-string (string)
-             (declare (type string string))
-             (let ((packageoid (gethash string *package-names*)))
-              (when (and (null packageoid)
-                         (not *in-package-init*) ; KLUDGE
-                         (let ((mismatch (mismatch "SB!" string)))
-                           (and mismatch (= mismatch 3))))
-                (restart-case
-                    (signal 'bootstrap-package-not-found :name string)
-                  (debootstrap-package ()
-                    (return-from find-package
-                      (if (string= string "SB!XC")
-                          (find-package "COMMON-LISP")
-                          (find-package
-                           (substitute #\- #\! string :count 1)))))))
-              packageoid)))
-     (typecase package-designator
-       (package package-designator)
-       (symbol (find-package-from-string (symbol-name package-designator)))
-       (string (find-package-from-string package-designator))
-       (character (find-package-from-string (string package-designator)))
-       (t (error 'type-error
-                 :datum package-designator
-                 :expected-type '(or character package string symbol)))))))
+  (flet ((find-package-from-string (string)
+           (declare (type string string))
+           (let ((packageoid (gethash string *package-names*)))
+             (when (and (null packageoid)
+                        (not *in-package-init*) ; KLUDGE
+                        (let ((mismatch (mismatch "SB!" string)))
+                          (and mismatch (= mismatch 3))))
+               (restart-case
+                   (signal 'bootstrap-package-not-found :name string)
+                 (debootstrap-package ()
+                   (return-from find-package
+                     (if (string= string "SB!XC")
+                         (find-package "COMMON-LISP")
+                         (find-package
+                          (substitute #\- #\! string :count 1)))))))
+             packageoid)))
+    (typecase package-designator
+      (package package-designator)
+      (symbol (find-package-from-string (symbol-name package-designator)))
+      (string (find-package-from-string package-designator))
+      (character (find-package-from-string (string package-designator)))
+      (t (error 'type-error
+                :datum package-designator
+                :expected-type '(or character package string symbol))))))
 
 ;;; Return a list of packages given a package designator or list of
 ;;; package designators, or die trying.
@@ -535,11 +560,13 @@ error if any of PACKAGES is not a valid package designator."
   (declare (type list nicknames))
   (dolist (n nicknames)
     (let* ((n (package-namify n))
-           (found (gethash n *package-names*)))
-      (cond ((not found)
-             (setf (gethash n *package-names*) package)
-             (push n (package-%nicknames package)))
-            ((eq found package))
+           (found (with-package-names (names)
+                    (or (gethash n names)
+                        (progn
+                          (setf (gethash n names) package)
+                          (push n (package-%nicknames package))
+                          package)))))
+      (cond ((eq found package))
             ((string= (the string (package-%name found)) n)
              (cerror "Ignore this nickname."
                      'simple-package-error
@@ -565,36 +592,41 @@ list. :INTERNAL-SYMBOLS and :EXTERNAL-SYMBOLS are estimates for the number of
 internal and external symbols which will ultimately be present in the package.
 The default value of USE is implementation-dependent, and in this
 implementation it is ~S." *default-package-use-list*)
-  (with-packages ()
-    ;; Check for package name conflicts in name and nicknames, then
-    ;; make the package.
-    (when (find-package name)
-      ;; ANSI specifies that this error is correctable.
-      (cerror "Clobber existing package."
-              "A package named ~S already exists" name))
-    (let* ((name (package-namify name))
-           (package (internal-make-package
-                     :%name name
-                     :internal-symbols (make-or-remake-package-hashtable
-                                        internal-symbols)
-                     :external-symbols (make-or-remake-package-hashtable
-                                        external-symbols))))
-
-      ;; Do a USE-PACKAGE for each thing in the USE list so that checking for
-      ;; conflicting exports among used packages is done.
-      (if *in-package-init*
-          (push (list use package) *!deferred-use-packages*)
-          (use-package use package))
-
-      ;; FIXME: ENTER-NEW-NICKNAMES can fail (ERROR) if nicknames are illegal,
-      ;; which would leave us with possibly-bad side effects from the earlier
-      ;; USE-PACKAGE (e.g. this package on the used-by lists of other packages,
-      ;; but not in *PACKAGE-NAMES*, and possibly import side effects too?).
-      ;; Perhaps this can be solved by just moving ENTER-NEW-NICKNAMES before
-      ;; USE-PACKAGE, but I need to check what kinds of errors can be caused by
-      ;; USE-PACKAGE, too.
-      (%enter-new-nicknames package nicknames)
-      (setf (gethash name *package-names*) package))))
+  (prog (clobber)
+   :restart
+     (when (find-package name)
+       ;; ANSI specifies that this error is correctable.
+       (cerror "Clobber existing package."
+               "A package named ~S already exists" name)
+       (setf clobber t))
+     (with-packages ()
+       ;; Check for race, signal the error outside the lock.
+       (when (and (not clobber) (find-package name))
+         (go :restart))
+       (let* ((name (package-namify name))
+              (package (internal-make-package
+                        :%name name
+                        :internal-symbols (make-or-remake-package-hashtable
+                                           internal-symbols)
+                        :external-symbols (make-or-remake-package-hashtable
+                                           external-symbols))))
+
+         ;; Do a USE-PACKAGE for each thing in the USE list so that checking for
+         ;; conflicting exports among used packages is done.
+         (if *in-package-init*
+             (push (list use package) *!deferred-use-packages*)
+             (use-package use package))
+
+         ;; FIXME: ENTER-NEW-NICKNAMES can fail (ERROR) if nicknames are illegal,
+         ;; which would leave us with possibly-bad side effects from the earlier
+         ;; USE-PACKAGE (e.g. this package on the used-by lists of other packages,
+         ;; but not in *PACKAGE-NAMES*, and possibly import side effects too?).
+         ;; Perhaps this can be solved by just moving ENTER-NEW-NICKNAMES before
+         ;; USE-PACKAGE, but I need to check what kinds of errors can be caused by
+         ;; USE-PACKAGE, too.
+         (%enter-new-nicknames package nicknames)
+         (return (setf (gethash name *package-names*) package))))
+     (bug "never")))
 
 ;;; Change the name if we can, blast any old nicknames and then
 ;;; add in any new ones.
@@ -605,106 +637,114 @@ implementation it is ~S." *default-package-use-list*)
 ;;; the package name if NAME is the same package that's referred to by PACKAGE.
 ;;; If it's a *different* package, we should probably signal an error.
 ;;; (perhaps (ERROR 'ANSI-WEIRDNESS ..):-)
-(defun rename-package (package name &optional (nicknames ()))
+(defun rename-package (package-designator name &optional (nicknames ()))
   #!+sb-doc
   "Changes the name and nicknames for a package."
-  (with-packages ()
-    (let* ((package (find-undeleted-package-or-lose package))
-           (name (package-namify name))
-           (found (find-package name))
-           (nicks (mapcar #'string nicknames)))
-      (unless (or (not found) (eq found package))
-        (error 'simple-package-error
-               :package name
-               :format-control "A package named ~S already exists."
-               :format-arguments (list name)))
-      (with-single-package-locked-error ()
-        (unless (and (string= name (package-name package))
-                     (null (set-difference nicks (package-nicknames package)
-                                           :test #'string=)))
-          (assert-package-unlocked package "rename as ~A~@[ with nickname~P ~
+  (tagbody :restart
+     (let* ((package (find-undeleted-package-or-lose package-designator))
+            (name (package-namify name))
+            (found (find-package name))
+            (nicks (mapcar #'string nicknames)))
+       (unless (or (not found) (eq found package))
+         (error 'simple-package-error
+                :package name
+                :format-control "A package named ~S already exists."
+                :format-arguments (list name)))
+       (with-single-package-locked-error ()
+         (unless (and (string= name (package-name package))
+                      (null (set-difference nicks (package-nicknames package)
+                                            :test #'string=)))
+           (assert-package-unlocked package "rename as ~A~@[ with nickname~P ~
                                            ~{~A~^, ~}~]"
-                                   name (length nicks) nicks))
-        ;; do the renaming
-        (remhash (package-%name package) *package-names*)
-        (dolist (n (package-%nicknames package))
-          (remhash n *package-names*))
-        (setf (package-%name package) name
-              (gethash name *package-names*) package
-              (package-%nicknames package) ())
-        (%enter-new-nicknames package nicknames))
-      package)))
+                                    name (length nicks) nicks))
+         (with-package-names (names)
+           ;; Check for race conditions now that we have the lock.
+           (unless (eq package (find-package package-designator))
+             (go :restart))
+           ;; Do the renaming.
+           (remhash (package-%name package) names)
+           (dolist (n (package-%nicknames package))
+             (remhash n names))
+           (setf (package-%name package) name
+                 (gethash name names) package
+                 (package-%nicknames package) ()))
+         (%enter-new-nicknames package nicknames))
+       package)))
 
 (defun delete-package (package-designator)
   #!+sb-doc
   "Delete the package designated by PACKAGE-DESIGNATOR from the package
   system data structures."
-  (with-packages ()
-    (let ((package (if (packagep package-designator)
-                       package-designator
-                       (find-package package-designator))))
-      (cond ((not package)
-             ;; This continuable error is required by ANSI.
-             (cerror
-              "Return ~S."
-              (make-condition
-               'simple-package-error
-               :package package-designator
-               :format-control "There is no package named ~S."
-               :format-arguments (list package-designator))
-              nil))
-            ((not (package-name package)) ; already deleted
-             nil)
-            (t
-             (with-single-package-locked-error
-                 (:package package "deleting package ~A" package)
-               (let ((use-list (package-used-by-list package)))
-                 (when use-list
-                   ;; This continuable error is specified by ANSI.
-                   (cerror
-                    "Remove dependency in other packages."
-                    (make-condition
-                     'simple-package-error
-                     :package package
-                     :format-control
-                     "~@<Package ~S is used by package~P:~2I~_~S~@:>"
-                     :format-arguments (list (package-name package)
-                                             (length use-list)
-                                             (mapcar #'package-name use-list))))
-                   (dolist (p use-list)
-                     (unuse-package package p))))
-               (dolist (used (package-use-list package))
-                 (unuse-package used package))
-               (do-symbols (sym package)
-                 (unintern sym package))
-               (remhash (package-name package) *package-names*)
-               (dolist (nick (package-nicknames package))
-                 (remhash nick *package-names*))
-               (setf (package-%name package) nil
-                     ;; Setting PACKAGE-%NAME to NIL is required in order to
-                     ;; make PACKAGE-NAME return NIL for a deleted package as
-                     ;; ANSI requires. Setting the other slots to NIL
-                     ;; and blowing away the PACKAGE-HASHTABLES is just done
-                     ;; for tidiness and to help the GC.
-                     (package-%nicknames package) nil
-                     (package-%use-list package) nil
-                     (package-tables package) nil
-                     (package-%shadowing-symbols package) nil
-                     (package-internal-symbols package)
-                     (make-or-remake-package-hashtable 0)
-                     (package-external-symbols package)
-                     (make-or-remake-package-hashtable 0))
-               t))))))
+  (tagbody :restart
+     (let ((package (find-package package-designator)))
+       (cond ((not package)
+              ;; This continuable error is required by ANSI.
+              (cerror
+               "Return ~S."
+               (make-condition
+                'simple-package-error
+                :package package-designator
+                :format-control "There is no package named ~S."
+                :format-arguments (list package-designator))
+               (return-from delete-package nil)))
+             ((not (package-name package)) ; already deleted
+              (return-from delete-package nil))
+             (t
+              (with-single-package-locked-error
+                  (:package package "deleting package ~A" package)
+                (let ((use-list (package-used-by-list package)))
+                  (when use-list
+                    ;; This continuable error is specified by ANSI.
+                    (cerror
+                     "Remove dependency in other packages."
+                     (make-condition
+                      'simple-package-error
+                      :package package
+                      :format-control
+                      "~@<Package ~S is used by package~P:~2I~_~S~@:>"
+                      :format-arguments (list (package-name package)
+                                              (length use-list)
+                                              (mapcar #'package-name use-list))))
+                    (dolist (p use-list)
+                      (unuse-package package p))))
+                (with-package-graph ()
+                  ;; Check for races, restart if necessary.
+                  (let ((package2 (find-package package-designator)))
+                    (when (or (neq package package2) (package-used-by-list package2))
+                      (go :restart)))
+                  (dolist (used (package-use-list package))
+                    (unuse-package used package))
+                  (do-symbols (sym package)
+                    (unintern sym package))
+                  (with-package-names (names)
+                    (remhash (package-name package) names)
+                    (dolist (nick (package-nicknames package))
+                      (remhash nick names))
+                    (setf (package-%name package) nil
+                          ;; Setting PACKAGE-%NAME to NIL is required in order to
+                          ;; make PACKAGE-NAME return NIL for a deleted package as
+                          ;; ANSI requires. Setting the other slots to NIL
+                          ;; and blowing away the PACKAGE-HASHTABLES is just done
+                          ;; for tidiness and to help the GC.
+                          (package-%nicknames package) nil))
+                  (setf (package-%use-list package) nil
+                        (package-tables package) nil
+                        (package-%shadowing-symbols package) nil
+                        (package-internal-symbols package)
+                        (make-or-remake-package-hashtable 0)
+                        (package-external-symbols package)
+                        (make-or-remake-package-hashtable 0)))
+                (return-from delete-package t)))))))
 
 (defun list-all-packages ()
   #!+sb-doc
   "Return a list of all existing packages."
   (let ((res ()))
-    (with-packages ()
+    (with-package-names (names)
       (maphash (lambda (k v)
                  (declare (ignore k))
                  (pushnew v res))
-               *package-names*))
+               names))
     res))
 \f
 (defun intern (name &optional (package (sane-package)))
@@ -748,7 +788,7 @@ implementation it is ~S." *default-package-use-list*)
            ;; symbol already interned, handled by the first leg of the
            ;; COND, but in case another thread is interning in
            ;; parallel we need to check after grabbing the lock.
-           (with-packages ()
+           (with-package-graph ()
              (setf (values symbol where) (find-symbol* name length package))
              (if where
                  (values symbol where)
@@ -759,8 +799,8 @@ implementation it is ~S." *default-package-use-list*)
                        (%set-symbol-package symbol package)
                        (cond
                          ((eq package *keyword-package*)
-                          (add-symbol (package-external-symbols package) symbol)
-                          (%set-symbol-value symbol symbol))
+                          (%set-symbol-value symbol symbol)
+                          (add-symbol (package-external-symbols package) symbol))
                          (t
                           (add-symbol (package-internal-symbols package) symbol)))
                        (values symbol nil))))))))))
@@ -902,7 +942,7 @@ implementation it is ~S." *default-package-use-list*)
   "Makes SYMBOL no longer present in PACKAGE. If SYMBOL was present then T is
 returned, otherwise NIL. If PACKAGE is SYMBOL's home package, then it is made
 uninterned."
-  (with-packages ()
+  (with-package-graph ()
     (let* ((package (find-undeleted-package-or-lose package))
            (name (symbol-name symbol))
            (shadowing-symbols (package-%shadowing-symbols package)))
@@ -973,11 +1013,12 @@ uninterned."
 (defun export (symbols &optional (package (sane-package)))
   #!+sb-doc
   "Exports SYMBOLS from PACKAGE, checking that no name conflicts result."
-  (with-packages ()
+  (with-package-graph ()
     (let ((package (find-undeleted-package-or-lose package))
+          (symbols (symbol-listify symbols))
           (syms ()))
       ;; Punt any symbols that are already external.
-      (dolist (sym (symbol-listify symbols))
+      (dolist (sym symbols)
         (multiple-value-bind (s w)
             (find-external-symbol (symbol-name sym) package)
           (declare (ignore s))
@@ -1033,10 +1074,11 @@ uninterned."
 (defun unexport (symbols &optional (package (sane-package)))
   #!+sb-doc
   "Makes SYMBOLS no longer exported from PACKAGE."
-  (with-packages ()
+  (with-package-graph ()
     (let ((package (find-undeleted-package-or-lose package))
+          (symbols (symbol-listify symbols))
           (syms ()))
-      (dolist (sym (symbol-listify symbols))
+      (dolist (sym symbols)
         (multiple-value-bind (s w) (find-symbol (symbol-name sym) package)
           (cond ((or (not w) (not (eq s sym)))
                  (error 'simple-package-error
@@ -1062,7 +1104,7 @@ uninterned."
   "Make SYMBOLS accessible as internal symbols in PACKAGE. If a symbol is
 already accessible then it has no effect. If a name conflict would result from
 the importation, then a correctable error is signalled."
-  (with-packages ()
+  (with-package-graph ()
     (let* ((package (find-undeleted-package-or-lose package))
            (symbols (symbol-listify symbols))
            (homeless (remove-if #'symbol-package symbols))
@@ -1098,7 +1140,7 @@ the importation, then a correctable error is signalled."
   #!+sb-doc
   "Import SYMBOLS into package, disregarding any name conflict. If
   a symbol of the same name is present, then it is uninterned."
-  (with-packages ()
+  (with-package-graph ()
     (let* ((package (find-undeleted-package-or-lose package))
            (internal (package-internal-symbols package))
            (symbols (symbol-listify symbols))
@@ -1128,7 +1170,7 @@ the importation, then a correctable error is signalled."
 specified SYMBOLS. If a symbol with the given name is already present in
 PACKAGE, then the existing symbol is placed in the shadowing symbols list if
 it is not already present."
-  (with-packages ()
+  (with-package-graph ()
     (let* ((package (find-undeleted-package-or-lose package))
            (internal (package-internal-symbols package))
            (symbols (string-listify symbols))
@@ -1157,7 +1199,7 @@ it is not already present."
   "Add all the PACKAGES-TO-USE to the use list for PACKAGE so that the
 external symbols of the used packages are accessible as internal symbols in
 PACKAGE."
-  (with-packages ()
+  (with-package-graph ()
     (let ((packages (package-listify packages-to-use))
           (package (find-undeleted-package-or-lose package)))
 
@@ -1216,7 +1258,7 @@ PACKAGE."
 (defun unuse-package (packages-to-unuse &optional (package (sane-package)))
   #!+sb-doc
   "Remove PACKAGES-TO-UNUSE from the USE list for PACKAGE."
-  (with-packages ()
+  (with-package-graph ()
     (let ((package (find-undeleted-package-or-lose package))
           (packages (package-listify packages-to-unuse)))
       (with-single-package-locked-error ()
@@ -1238,12 +1280,12 @@ PACKAGE."
   "Return a list of all symbols in the system having the specified name."
   (let ((string (string string-or-symbol))
         (res ()))
-    (with-packages ()
+    (with-package-names (names)
       (maphash (lambda (k v)
                  (declare (ignore k))
                  (multiple-value-bind (s w) (find-symbol string v)
                    (when w (pushnew s res))))
-               *package-names*))
+               names))
     res))
 \f
 ;;;; APROPOS and APROPOS-LIST
index 0a477b3..b2421b2 100644 (file)
@@ -267,3 +267,16 @@ if a restart was invoked."
                 ((and simple-condition program-error) (c)
                   (assert (equal (list :foo) (simple-condition-format-arguments c)))
                   :good)))))
+
+;;; MAKE-PACKAGE error in another thread blocking FIND-PACKAGE & FIND-SYMBOL
+#+sb-thread
+(with-test (:name :bug-511072)
+  (let* ((p (make-package :bug-511072))
+         (sem (sb-thread:make-semaphore))
+         (t2 (sb-thread:make-thread (lambda ()
+                                      (handler-bind ((error (lambda (c)
+                                                              (sb-thread:signal-semaphore sem)
+                                                              (signal c))))
+                                        (make-package :bug-511072))))))
+    (sb-thread:wait-on-semaphore sem)
+    (assert (eq 'cons (read-from-string "CL:CONS")))))
index eefb885..636b3eb 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.37.43"
+"1.0.37.44"