GNU bug report logs - #50720
unnamed &rest broken

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Mattias Engdegård <mattiase@HIDDEN>; merged with #50268; dated Tue, 21 Sep 2021 11:17:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Merged 50268 50720. Request was from Andrea Corallo <akrl@HIDDEN> to control <at> Full text available.

Message received at submit <at>

Received: (at submit) by; 21 Sep 2021 11:16:07 +0000
From debbugs-submit-bounces <at> Tue Sep 21 07:16:07 2021
Received: from localhost ([]:45073
	by with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at>>)
	id 1mSdks-0001Rt-Rp
	for submit <at>; Tue, 21 Sep 2021 07:16:07 -0400
Received: from ([]:34906)
 by with esmtp (Exim 4.84_2)
 (envelope-from <mattiase@HIDDEN>) id 1mSdkr-0001Rm-Oc
 for submit <at>; Tue, 21 Sep 2021 07:16:06 -0400
Received: from ([2001:470:142:3::10]:42968)
 by with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mattiase@HIDDEN>) id 1mSdkr-0005Rv-JI
 for bug-gnu-emacs@HIDDEN; Tue, 21 Sep 2021 07:16:05 -0400
Received: from ([]:56446)
 by with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mattiase@HIDDEN>) id 1mSdko-0004dP-TT
 for bug-gnu-emacs@HIDDEN; Tue, 21 Sep 2021 07:16:05 -0400
X-Authenticated-User: mattiase@HIDDEN
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;;
 s=maildub; t=1632222956;
Feedback-ID: mattiase@HIDDEN
Received: from stanniol.lan (
 []) (authenticated bits=0)
 by (8.14.9/8.13.1) with ESMTP id 18LBFskC021467
 for <bug-gnu-emacs@HIDDEN>; Tue, 21 Sep 2021 11:15:56 +0000
From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= <mattiase@HIDDEN>
Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\))
Subject: unnamed &rest broken
Message-Id: <BAE8262C-A0B6-4F48-9641-9C2E836FDA36@HIDDEN>
Date: Tue, 21 Sep 2021 13:15:54 +0200
To: bug-gnu-emacs@HIDDEN
X-Mailer: Apple Mail (2.3445.104.21)
X-CTCH-RefID: str=0001.0A742F23.6149BEEC.0074, ss=1, re=0.000, recu=0.000,
 reip=0.000, cl=1, cld=1, fgs=0
X-CTCH-VOD: Unknown
X-CTCH-Spam: Unknown
X-CTCH-Score: 0.000
X-CTCH-Flags: 0
X-CTCH-ScoreCust: 0.000
X-CSC: 0
X-CHA: v=2.4 cv=ReDzt3hv c=1 sm=1 tr=0 ts=6149beec
 a=von4qPfY+hyqc0zmWf0tYQ==:117 a=von4qPfY+hyqc0zmWf0tYQ==:17
 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=vtB9HbqcwF9x0TkvSvEA:9
X-Origin-Country: SE
Received-SPF: softfail client-ip=; envelope-from=mattiase@HIDDEN;
X-Spam_score_int: -11
X-Spam_score: -1.2
X-Spam_bar: -
X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at>
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <>
List-Unsubscribe: <>, 
 <mailto:debbugs-submit-request <at>>
List-Archive: <>
List-Post: <mailto:debbugs-submit <at>>
List-Help: <mailto:debbugs-submit-request <at>>
List-Subscribe: <>, 
 <mailto:debbugs-submit-request <at>>
Errors-To: debbugs-submit-bounces <at>
Sender: "Debbugs-submit" <debbugs-submit-bounces <at>>
X-Spam-Score: -2.3 (--)

The interpreter and compiler allow &rest to be used without a variable =
name following but the generated byte code is completely broken:

(funcall (byte-compile (lambda (&rest) 'ta)))

crashes, and

(defun boo (a &rest)
  (if a a (list 1 2 3 4)))

(boo 'hiss)
=3D> hiss        ; interpreted
=3D> (1 2 3 4)   ; compiled

The reason is that the compiler generates code from the argument =
variable list but the byte-code interpreter will only look at the =
signature code which was generated from the actual signature:

(byte-compile (lambda (&rest) 'ta))
=3D> #[128 "\300\207" [ta] 1 "..."]

The 128 indicates zero positional parameters and a &rest argument, and =
the 1 is the maximum stack size required which is wrong; 2 stack slots =
are needed and that's what we get if naming the argument:

(byte-compile (lambda (&rest _r) 'ta))
=3D> #[128 "\300\207" [ta] 2 "..."]

In the `boo` case above, it is clear that the compiler doesn't expect =
any &rest param to have been pushed at all so the stack offsets are =

Now, either we fix this bug or we stop pretending that unnamed &rest =
arguments work at all and signal an error, because it's clear from the =
above that they can't have seen much use.

Acknowledgement sent to Mattias Engdegård <mattiase@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#50720; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 21 Sep 2021 16:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.