Comment 1 for bug 1187879

Revision history for this message
Lutz Euler (lutz-euler) wrote :

Trying to debug this, I found a way to reliably reproduce the test failure with plain 1.1.8-23:
Build SBCL 1.1.8-23 under x86_64/Linux with "sh make.sh", start it, then paste the following parts of tests/dynamic-extent.impure.lisp into the REPL:

(setq sb-c::*check-consistency* t
      sb-ext:*stack-allocate-dynamic-extent* t)

(defmacro defun-with-dx (name arglist &body body)
  (let ((debug-name (sb-int:symbolicate name "-HIGH-DEBUG"))
        (default-name (sb-int:symbolicate name "-DEFAULT")))
    `(progn
       (defun ,debug-name ,arglist
         (declare (optimize debug))
         ,@body)
       (defun ,default-name ,arglist
        ,@body)
       (defun ,name (&rest args)
         (apply #',debug-name args)
         (apply #',default-name args)))))

(declaim (notinline opaque-identity))
(defun opaque-identity (x)
  x)

(defparameter *bar* nil)
(declaim (inline make-nested-bad make-nested-good))
(defstruct (nested (:constructor make-nested-bad (&key bar &aux (bar (setf *bar* bar))))
                   (:constructor make-nested-good (&key bar)))
  bar)

(defun-with-dx nested-good (y)
  (let ((x (list (list (make-nested-good :bar (list (list (make-nested-good :bar (list y)))))))))
    (declare (dynamic-extent x))
    (true x)))

(defun-with-dx nested-bad (y)
  (let ((x (list (list (make-nested-bad :bar (list (list (make-nested-bad :bar (list y)))))))))
    (declare (dynamic-extent x))
    (unless (equalp (caar x) (make-nested-good :bar *bar*))
      (error "got ~S, wanted ~S" (caar x) (make-nested-good :bar *bar*)))
    (caar x)))

(declaim (notinline true))
(defun true (x)
  (declare (ignore x))
  t)

Then evaluating

(values (nested-bad 42) (make-nested-good :bar *bar*))

gives here:

debugger invoked on a TYPE-ERROR in thread
#<THREAD "main thread" RUNNING {1002B138B3}>:
  The value MAKE-NESTED-GOOD is not of type SB-KERNEL:LAYOUT.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

CORRUPTION WARNING in SBCL pid 5513(tid 140737353926432):
Memory fault at d (pc=0x1000e9dd7c, sp=0x7ffff6d46140)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
(SB-PCL::CACHE-MISS-VALUES #<error printing object>)
0]