master: Remove another misuse of (DECLARE SPECIAL) for #+tls-load-indirect

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  2d87e918aa7e7685dc3e87d21c1547bc1d74c201 (commit)
      from  01126243ca6898febc509c0e0836d7b1106515ef (commit)

- Log -----------------------------------------------------------------
commit 2d87e918aa7e7685dc3e87d21c1547bc1d74c201
Author: Douglas Katzman <[email protected]>
Date:   Tue Apr 7 19:40:23 2026 -0400

    Remove another misuse of (DECLARE SPECIAL) for #+tls-load-indirect
    
    Apart from it generally being considered suboptimal style to need local
    special declarations, is it actually harmful for DEFINE-THREAD-LOCAL.
    SPECIAL says that it has an indirection word, while thread-local says
    it _never_ has. I didn't figure out why this wasn't crashing. Probably was,
    and some test reported success because after all it's a heap exhaustion.
---
 src/code/interr.lisp       | 7 ++++---
 src/code/target-error.lisp | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/code/interr.lisp b/src/code/interr.lisp
index da49b8c42..759374965 100644
--- a/src/code/interr.lisp
+++ b/src/code/interr.lisp
@@ -761,11 +761,12 @@
 ;;; that we don't need to allocate it when running out of
 ;;; memory. Similarly we pass the amounts in special variables as
 ;;; there may be multiple threads running into trouble at the same
-;;; time. The condition is created by GC-REINIT.
+;;; time.
+;;; (Why not allocate the condition on the control stack? Well, we can't,
+;;; at least currently. An ad-hoc technique to do so wouldn't be out of
+;;; the question, and might look more elegant)
 (define-load-time-global *heap-exhausted-error-condition*
   (make-condition 'heap-exhausted-error))
-(sb-impl:define-thread-local *heap-exhausted-error-available-bytes*)
-(sb-impl:define-thread-local *heap-exhausted-error-requested-bytes*)
 
 (defun heap-exhausted-error (available requested)
   ;; Double word aligned bytes, can be passed as fixnums to avoid
diff --git a/src/code/target-error.lisp b/src/code/target-error.lisp
index e4333c41b..a03fe3c9c 100644
--- a/src/code/target-error.lisp
+++ b/src/code/target-error.lisp
@@ -2365,13 +2365,13 @@ PROCEED WITH CAUTION."))))
 
 PROCEED WITH CAUTION."))))
 
+(sb-impl:define-thread-local *heap-exhausted-error-available-bytes*)
+(sb-impl:define-thread-local *heap-exhausted-error-requested-bytes*)
 (define-condition heap-exhausted-error (storage-condition)
   ()
   (:report
    (lambda (condition stream)
      (declare (ignore condition))
-     (declare (special *heap-exhausted-error-available-bytes*
-                       *heap-exhausted-error-requested-bytes*))
      ;; See comments in interr.lisp -- there is a method to this madness.
      (if (and (boundp '*heap-exhausted-error-available-bytes*)
               (boundp '*heap-exhausted-error-requested-bytes*))

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.