master: Remove a hack from src/code/signal
snuglas via Sbcl-commits <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via 526c5fca64c6346c89b574b5cb9d714ca6f77f56 (commit)
from aab1a9d230c5ed1cd09477e6176790a1b8f54053 (commit)
- Log -----------------------------------------------------------------
commit 526c5fca64c6346c89b574b5cb9d714ca6f77f56
Author: Douglas Katzman <[email protected]>
Date: Thu Apr 9 13:31:42 2026 -0400
Remove a hack from src/code/signal
We should not set the (INFO :variable :always-bound symbol) property through
ad-hoc techniques. The code and comments pre-date other approaches such as
DEFINE-THREAD-LOCAL. However, that's actually not enough to get
*UNBLOCK-DEFERRABLES-ON-ENABLING-INTERRUPTS-P* to work, because in addition to
the issue cited at the call to INIT-MAIN-THREAD in src/code/cold-init, there
is a problem that always-thread-local specials initialized from Lisp are set
later than the ones intialized in alloc_thread_struct. So entirely-from-lisp
assignment wasn't enough for *UNBLOCK-DEFERRABLES-ON-ENABLING-INTERRUPTS-P*.
---
src/code/cold-init.lisp | 9 +++++++--
src/code/signal.lisp | 15 ++-------------
src/compiler/generic/parms.lisp | 5 +++++
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/code/cold-init.lisp b/src/code/cold-init.lisp
index 387ef62eb..61c5f500f 100644
--- a/src/code/cold-init.lisp
+++ b/src/code/cold-init.lisp
@@ -136,7 +136,6 @@
*trace-output* stream))
(show-and-call !signal-function-cold-init)
(show-and-call !printer-control-init) ; needed before first instance of FORMAT or WRITE-STRING
- (setq sb-unix::*unblock-deferrables-on-enabling-interrupts-p* nil) ; needed by LOAD-LAYOUT called by CLASSES-INIT
(setq *print-length* 6
*print-level* 3)
(/show "testing '/SHOW" *print-length* *print-level*) ; show anything
@@ -159,7 +158,13 @@
(show-and-call !function-names-init)
(show-and-call !pathname-cold-init)
- ;; And now *CURRENT-THREAD*
+ ;; There is a very subtle (and slightly undiscoverable) chicken-and-egg situation
+ ;; which could occur when calling INIT-MAIN-THREAD during cold-init but presumably
+ ;; not after the core is produced: anything in *THREAD-LOCAL-SPECIALS* must
+ ;; have its initialization form evaluable. This is surely fine for constants
+ ;; but not as clear for *HANDLER-CLUSTERS* which takes its value from
+ ;; **INITIAL-HANDLER-CLUSTERS**. As it happens, we're ok, but that's just one
+ ;; example, so sometimes you have to be careful with DEFINE-THREAD-LOCAL.
(sb-thread::init-main-thread)
(show-and-call !hash-table-cold-init)
diff --git a/src/code/signal.lisp b/src/code/signal.lisp
index 724a49772..af4ee038f 100644
--- a/src/code/signal.lisp
+++ b/src/code/signal.lisp
@@ -65,19 +65,8 @@
;;; would not cut it, as upon leaving WITHOUT-INTERRUPTS the pending
;;; handlers is run with stuff from the function in which this is
;;; still on the stack.
-(defvar *unblock-deferrables-on-enabling-interrupts-p* nil)
-
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (dolist (symbol '(*unblock-deferrables-on-enabling-interrupts-p*
- *interrupts-enabled*
- *interrupt-pending*
- #+sb-safepoint *thruption-pending*
- *allow-with-interrupts*))
- ;; Force these to be always bound despite absence of a compile-time binding.
- ;; (Avoid accidentally installing a value into symbol->value in cold-load)
- ;; Not only are they always bound, 4 of them always have a thread-local value.
- ;; We don't as yet have a way to elide the check for no-tls-value though.
- (setf (info :variable :always-bound symbol) :always-bound)))
+;;; This is defined as a per-thread-c-interface symbol though C never reads it.
+(defvar *unblock-deferrables-on-enabling-interrupts-p*)
(defmacro without-interrupts (&body body)
"Executes BODY with all deferrable interrupts disabled. Deferrable
diff --git a/src/compiler/generic/parms.lisp b/src/compiler/generic/parms.lisp
index 782c483cf..bed4dacb9 100644
--- a/src/compiler/generic/parms.lisp
+++ b/src/compiler/generic/parms.lisp
@@ -179,10 +179,15 @@
;;; - static for efficiency of access but need not be
;;; On #+sb-thread builds, these are not static, because access to them
;;; is via the TLS, not the symbol.
+;;; The default for all these is NIL if unspecified.
(defconstant-eqx per-thread-c-interface-symbols
(hash-cons
'((*free-interrupt-context-index* 0)
(sb-sys:*allow-with-interrupts* t)
+ ;; Being closely related to *INTERRUPTS-ENABLED*, the unblock-mumble var feels
+ ;; right at home here, though is not read from C. The reason it's needed here is
+ ;; that START-LISP uses WITHOUT-INTERRUPTS before INIT-THREAD-LOCAL-STORAGE.
+ sb-unix::*unblock-deferrables-on-enabling-interrupts-p*
(sb-sys:*interrupts-enabled* t)
sb-sys:*interrupt-pending*
#+sb-safepoint sb-sys:*thruption-pending*
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL