Incorrect number of return values

Bug #1489590 reported by Ilya Perminov on 2015-08-27
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
High
Unassigned

Bug Description

The following code returns two values instead of one:
(labels ((foo ()
                    (declare (optimize speed))
                    (sb-ext:get-time-of-day)))
           (multiple-value-list (multiple-value-prog1
                                  (apply #'values (list 1))
                                  (foo))))

SBCL 1.2.14, Linux x86_64.

Stas Boukarev (stassats) on 2015-08-27
Changed in sbcl:
status: New → Triaged
importance: Undecided → High
Attila Lendvai (attila-lendvai) wrote :

it seems to be a recent regression.

CL-USER> (labels ((foo ()
                    (declare (optimize speed))
                    (sb-ext:get-time-of-day)))
           (multiple-value-list (multiple-value-prog1
                                    (apply #'values (list 1))
                                  (foo))))
(1)
CL-USER> (lisp-implementation-version)
"1.2.13.90.hu.dwim.2-43e2c8b"

Jan Moringen (scymtym) wrote :

Happens on x86_64 but not x86.

Stas Boukarev (stassats) wrote :

It computes the number of saved values using RBX-RSP, but RSP is double-word aligned for alien calls. Saving an odd number of values in multiple-value-prog1 misaligned the stack, which gets aligned in alloc-number-stack-space and throws off the number of saved values.

Stas Boukarev (stassats) wrote :

Here's a patch that preserves the stack pointer not only on x86, but on x86-64 too. Will be committed after the freeze.

Stas Boukarev (stassats) wrote :

In bfcfd35061afa2709fee47c4e09c3dcc40b2147d.

Changed in sbcl:
status: Triaged → 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

Patches