Steel Bank Common Lisp

stack-allocated indirect closure variables are not popped

Reported by Nikodemus Siivola on 2008-12-17
2
Affects Status Importance Assigned to Milestone
SBCL
Medium
Alastair Bridgewater

Bug Description

      (defun bug419 (x)
        (multiple-value-call #'list
          (eval '(values 1 2 3))
          (let ((x x))
            (declare (sb-int:truly-dynamic-extent x))
            (flet ((mget (y)
                     (+ x y))
                   (mset (z)
                     (incf x z)))
              (declare (dynamic-extent #'mget #'mset))
              ((lambda (f g) (eval `(progn ,f ,g (values 4 5 6)))) #'mget #'mset)))))

  (ASSERT (EQUAL (BUG419 42) '(1 2 3 4 5 6))) => failure

  Note: as of SBCL 1.0.16.29 this bug no longer affects user code, as
  SB-INT:TRULY-DYNAMIC-EXTENT needs to be used instead of
  DYNAMIC-EXTENT for this to happen. Proper fix for this bug requires
  (Nikodemus thinks) storing the relevant LAMBDA-VARs in a
  :DYNAMIC-EXTENT cleanup, and teaching stack analysis how to deal
  with them.

Changed in sbcl:
importance: Undecided → Medium
status: New → Confirmed
Nikodemus Siivola (nikodemus) wrote :

Since equivalent constructs such as

(defun bug419/good (x)
  (multiple-value-call #'list
    (eval '(values 1 2 3))
    (let ((x (list x)))
      (declare (sb-int:truly-dynamic-extent x))
      (flet ((mget (y)
               (+ (car x) y))
             (mset (z)
               (incf (car x) z)))
        (declare (dynamic-extent #'mget #'mset))
        ((lambda (f g) (eval `(progn ,f ,g (values 4 5 6)))) #'mget #'mset)))))

works fine, an alternative strategy would be to implement DX value cells explicit objects (via a magic source transform, for example.)

Changed in sbcl:
assignee: nobody → Alastair Bridgewater (alastair-bridgewater)

In 1.0.44.16.

Changed in sbcl:
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  Edit
Everyone can see this information.

Other bug subscribers