Re: master: Remove another special case for SXHASH and fix a known bug

Stas Boukarev <[email protected]> Mon, 16 Mar 2026 14:07:57 +0300
Newsgroups gmane.lisp.steel-bank.cvs,gmane.lisp.steel-bank.devel
Message-ID <CAF63=12XsnvEA4SnRp=EOwiEJJeLt5Ksy9seJ=D_JiBGuAfZUg@mail.gmail.com>
With mark-region-gc:
::: Running :LAZY-HASH-SLOT-INSTANCE-LENGTH-INVARIANT
::: UNEXPECTED-FAILURE :LAZY-HASH-SLOT-INSTANCE-LENGTH-INVARIANT
due to SIMPLE-ERROR:
"The assertion (/= (SB-KERNEL:GET-LISP-OBJ-ADDRESS *OBJ1*) *ADDR1*)
failed with (SB-KERNEL:GET-LISP-OBJ-ADDRESS *OBJ1*) = 481131491939,
*ADDR1* = 481131491939."

On Mon, Mar 16, 2026 at 8:12 AM snuglas via Sbcl-commits
<[email protected]> wrote:
>
> The branch "master" has been updated in SBCL:
>        via  45dc509ce302b273312bebfe279a60f098367e20 (commit)
>       from  3fa9948ca8aca251c79bb4b2f8fd5b9daff6406f (commit)
>
> - Log -----------------------------------------------------------------
> commit 45dc509ce302b273312bebfe279a60f098367e20
> Author: Douglas Katzman <[email protected]>
> Date:   Mon Mar 16 00:58:32 2026 -0400
>
>     Remove another special case for SXHASH and fix a known bug
>
>     Don't use layout-clos-hash for sxhash of layouts.
>     Happily the comment in %INSTANCE-SXHASH about LAYOUT was wrong-
>     BITMAP-NWORDS stays the same when a stable hash slot is added by GC.
> ---
>  src/code/target-sxhash.lisp  | 8 --------
>  tests/hash.pure.lisp         | 9 ---------
>  tests/stablehash.impure.lisp | 7 +++++++
>  3 files changed, 7 insertions(+), 17 deletions(-)
>
> diff --git a/src/code/target-sxhash.lisp b/src/code/target-sxhash.lisp
> index 437e76f2e..a2abf5f83 100644
> --- a/src/code/target-sxhash.lisp
> +++ b/src/code/target-sxhash.lisp
> @@ -81,14 +81,6 @@
>  ;;;
>  (declaim (inline %instance-sxhash))
>  (defun %instance-sxhash (instance header-word)
> -  ;; LAYOUT must not acquire an extra slot for the stable hash,
> -  ;; because the bitmap length is derived from the instance length.
> -  ;; It would probably be simple to eliminate this as a special case
> -  ;; by ensuring that instances of LAYOUT commence life with a trailing
> -  ;; hash slot and the SB-VM:HASH-SLOT-PRESENT-FLAG set.
> -  (when (typep instance 'layout)
> -    ;; This might be wrong if the clos-hash was clobbered to 0
> -    (return-from %instance-sxhash (layout-clos-hash instance)))
>    ;; Non-simple cases: no hash slot, and either unhashed or hashed-not-moved.
>    (let* ((addr (sb-c::if-vop-existsp (:named sb-vm::set-instance-hashed-return-address)
>                   (if (logbitp sb-vm:stable-hash-required-flag header-word)
> diff --git a/tests/hash.pure.lisp b/tests/hash.pure.lisp
> index 2bb99edac..7b8ecad6c 100644
> --- a/tests/hash.pure.lisp
> +++ b/tests/hash.pure.lisp
> @@ -360,15 +360,6 @@
>    (test-this-object 'equalp (constantly 5))
>    (test-this-object 'equal (sb-sys:int-sap 0)))
>
> -;;; I don't like that we call SXHASH on layouts, but there was a horrible
> -;;; regression in which we returned (SXHASH (LAYOUT-OF X)) if X was a layout,
> -;;; which essentially meant that all layouts hashed to LAYOUT's hash.
> -;;; This affected the performance of TYPECASE.
> -(with-test (:name :sxhash-on-layout)
> -  (dolist (x '(pathname cons array))
> -    (let ((l (sb-kernel:find-layout x)))
> -      (assert (= (sxhash l) (sb-kernel:layout-clos-hash l))))))
> -
>  (with-test (:name :equalp-table-fixnum-equal-to-float)
>    (let ((table (make-hash-table :test #'equalp)))
>      (assert (eql (setf (gethash 3d0 table) 1)
> diff --git a/tests/stablehash.impure.lisp b/tests/stablehash.impure.lisp
> new file mode 100644
> index 000000000..b93b1291c
> --- /dev/null
> +++ b/tests/stablehash.impure.lisp
> @@ -0,0 +1,7 @@
> +(defclass foo () (a))
> +(defvar *x* (make-instance 'foo))
> +(assert (/= 0 (sxhash (sb-kernel:%instance-layout *x*))))
> +(defclass foo () (a b c))
> +(with-test (:name :obsolete-layout-sxhash-stability)
> +  (assert (= 0 (sb-kernel:layout-clos-hash (sb-kernel:%instance-layout *x*))))
> +  (assert (/= 0 (sxhash (sb-kernel:%instance-layout *x*)))))
>
> -----------------------------------------------------------------------
>
>
> hooks/post-receive
> --
> SBCL
>
>
> _______________________________________________
> Sbcl-commits mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sbcl-commits


_______________________________________________
Sbcl-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-commits