Invalid substructure coalescing in COMPILE-FILE?

Bug #2025086 reported by Jan Moringen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

For a file bla.lisp with content

  (defun x ()
    (rest '(a (&rest x . #1=(&rest y)) #1# a)))

  (defun y ()
    (rest '(b (&rest x . #1=(&rest y)) #1# b)))

  (defun z ()
    (rest '(c (&rest x . #1=(&rest y)) #1# c)))

  (let ((x (x)) (y (y)) (z (z)))
    (format t "~3S ~S [~X] ~S [~X]~@
               ~3S ~S [~X] ~S [~X]~@
               ~3S ~S [~X] ~S [~X]~%"
            (eq (cddr (car x)) (cadr x)) (car x) (sb-kernel:get-lisp-obj-address (car x)) (cadr x) (sb-kernel:get-lisp-obj-address (cadr x))
            (eq (cddr (car y)) (cadr y)) (car y) (sb-kernel:get-lisp-obj-address (car y)) (cadr y) (sb-kernel:get-lisp-obj-address (cadr y))
            (eq (cddr (car z)) (cadr z)) (car z) (sb-kernel:get-lisp-obj-address (car z)) (cadr z) (sb-kernel:get-lisp-obj-address (cadr z))))

when I execute (I tried two newer SBCL versions as well, with the same result)

  > uname -a
  Linux al 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux
  > sbcl --version
  SBCL 2.2.9.debian
  > sbcl --noinform --no-userinit --eval '(print *features*)' --quit
  (:X86-64 :GENCGC :64-BIT :ANSI-CL :COMMON-LISP :ELF :IEEE-FLOATING-POINT :LINUX
   :LITTLE-ENDIAN :PACKAGE-LOCAL-NICKNAMES :SB-CORE-COMPRESSION :SB-LDB
   :SB-PACKAGE-LOCKS :SB-THREAD :SB-UNICODE :SBCL :UNIX)
  > sbcl --noinform --no-userinit --eval '(progn (compile-file "/tmp/bla.lisp") (load "/tmp/bla.fasl"))' --quit
  ; compiling file "/tmp/bla.lisp" (written 26 JUN 2023 08:43:19 PM):

  ; wrote /tmp/bla.fasl
  ; compilation finished in 0:00:00.008
  T (&REST X &REST Y) [1001565447] (&REST Y) [1001565427]
  NIL (&REST X &REST Y) [1001565447] (&REST Y) [10015654A7]
  NIL (&REST X &REST Y) [1001565447] (&REST Y) [10015654A7]

I expect all three EQ calls to return true. Instead, only the first call returns true. It is also surprising that the return values are different between the three calls.

I believe this behavior violates "The file compiler is required to preserve eqlness of substructures within a file. Preserving eqlness means that subobjects that are the same in the source code must be the same in the corresponding compiled code." in https://novaspec.org/cl/3_2_Compilation#sec_3_2_4_4.

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Confirmed
assignee: nobody → Stas Boukarev (stassats)
Stas Boukarev (stassats)
Changed in sbcl:
assignee: Stas Boukarev (stassats) → nobody
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.