error in convert-mv-call

Bug #392203 reported by Nikodemus Siivola
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Medium
Unassigned

Bug Description

(flet ((k (&rest x) (declare (ignore x)) 0)) (multiple-value-call #'k #'k))

fails with

  failed AVER: (NOT (FUNCTIONAL-ENTRY-FUN FUN))

Repored by Larry D'Anna on sbcl-devel, along with the following diagnosis and fix:

Fix convert-mv-call so it doesn't crash on the following input

(flet ((k (&rest x) (declare (ignore x)) 0)) (multiple-value-call #'k #'k))

Specifically, so it doesn't trigger (aver (not (functional-entry-fun fun))).

This aver was inserted in version 0.8.5.5 by Alexey Dejneka.

> 0.8.5.5:
> * Fix bug reported by Brian Downing: do not perform
> MV-LET-convertion, if the last optional entry has
> references.

Ever since Spice Lisp, convert-mv-call had returned without doing anything if
(functional-entry-fun fun) is not null, ie if fun possesses a XEP. 0.8.5.5
replaces this criterion with "if the last optional entry has references", and
signals an error if the last optional entry has no references and the XEP
exists.

I can't know exactly what Alexy was thinking when he put the aver in, but I can
guess: If the XEP exists it should contain a reference to the last entry point,
so if the last entry point has no refs and a XEP exists something went wrong.
However, if the number of required + optional arguments is 0, then XEP doesn't
need the "last" entry point, it can always use the "more" entry point instead,
which is exactly what seems to have happened in this case.

This patch combines the two conditions. convert-mv-call will return without
action if *either* a XEP exists, *or* the last optional entry has references.
---
 src/compiler/locall.lisp | 4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 run-sbcl.sh

diff --git a/run-sbcl.sh b/run-sbcl.sh
old mode 100644
new mode 100755
diff --git a/src/compiler/locall.lisp b/src/compiler/locall.lisp
index ed3e34f..e3a8245 100644
--- a/src/compiler/locall.lisp
+++ b/src/compiler/locall.lisp
@@ -533,13 +533,13 @@
  (declare (type ref ref) (type mv-combination call) (type functional fun))
  (when (and (looks-like-an-mv-bind fun)
             (singleton-p (leaf-refs fun))
- (singleton-p (basic-combination-args call)))
+ (singleton-p (basic-combination-args call))
+ (not (functional-entry-fun fun)))
    (let* ((*current-component* (node-component ref))
           (ep (optional-dispatch-entry-point-fun
                fun (optional-dispatch-max-args fun))))
      (when (null (leaf-refs ep))
        (aver (= (optional-dispatch-min-args fun) 0))
- (aver (not (functional-entry-fun fun)))
        (setf (basic-combination-kind call) :local)
        (sset-adjoin ep (lambda-calls-or-closes (node-home-lambda call)))
        (merge-tail-sets call ep)

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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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