master: Mix package-id into fun-name hashes
snuglas via Sbcl-commits <[email protected]> Tue, 09 Jun 2026 19:23:54 +0000
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via 2df3f8071bfcf85721104e58efad6d38e9c2b912 (commit)
from 4336f7a1a4f15b2e83bc6b0b711f2eb66fad502d (commit)
- Log -----------------------------------------------------------------
commit 2df3f8071bfcf85721104e58efad6d38e9c2b912
Author: Douglas Katzman <[email protected]>
Date: Tue Jun 9 15:18:11 2026 -0400
Mix package-id into fun-name hashes
Indeed 32-bit x86 was observed to lack adequate randomization
---
src/compiler/early-c.lisp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/compiler/early-c.lisp b/src/compiler/early-c.lisp
index d6de83dee..5d986d08e 100644
--- a/src/compiler/early-c.lisp
+++ b/src/compiler/early-c.lisp
@@ -211,11 +211,14 @@ possible.")
;; SXHASH requires symbols whose print-names are the same to hash the same.
;; That's not a requirement of the fun-name-hashset, so use SYMBOL-HASH here
;; which contains 10 pseudorandom bits if 64-bit word size, fewer if 32-bit.
- ;; If someone using 32-bit SBCL complains, we can mix in PACKAGE-ID too.
+ ;; And mix in PACKAGE-ID for even more pseudorandness. It's stable across
+ ;; rename-package. User code which treats packages and their symbols as dynamically
+ ;; modifiable at compile-time is pretty irresponsible, so this seems fine to me
+ ;; even if it were not stable across renames.
#-sb-xc-host
(named-let recurse ((x list))
(typecase x
- (symbol (symbol-hash x))
+ (symbol (mix (symbol-hash x) (symbol-package-id x)))
;; sure this could be made iterative, but the lists in question are short
(cons (mix (recurse (car x)) (recurse (cdr x))))
(t (sxhash x))))) ; nonstandard function name, oh well (string?)
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL