From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#34757: Invalid bytecode from byte compiler Date: Fri, 15 Mar 2019 10:08:12 +0200 Message-ID: <838sxg1rwz.fsf@gnu.org> References: Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="186130"; mail-complaints-to="usenet@blaine.gmane.org" Cc: chuntaro@sakura-games.jp, 34757@debbugs.gnu.org To: Pip Cet , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 15 09:09:19 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4htz-000mHs-RR for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Mar 2019 09:09:15 +0100 Original-Received: from localhost ([127.0.0.1]:51526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4hty-0005Sq-Pz for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Mar 2019 04:09:14 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:39845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4htn-0005Rd-7q for bug-gnu-emacs@gnu.org; Fri, 15 Mar 2019 04:09:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4htm-0002hm-3P for bug-gnu-emacs@gnu.org; Fri, 15 Mar 2019 04:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59040) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h4htl-0002ha-Qy for bug-gnu-emacs@gnu.org; Fri, 15 Mar 2019 04:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h4htl-0001MI-Jh for bug-gnu-emacs@gnu.org; Fri, 15 Mar 2019 04:09:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Mar 2019 08:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34757 X-GNU-PR-Package: emacs Original-Received: via spool by 34757-submit@debbugs.gnu.org id=B34757.15526373205188 (code B ref 34757); Fri, 15 Mar 2019 08:09:01 +0000 Original-Received: (at 34757) by debbugs.gnu.org; 15 Mar 2019 08:08:40 +0000 Original-Received: from localhost ([127.0.0.1]:44350 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h4htN-0001LZ-So for submit@debbugs.gnu.org; Fri, 15 Mar 2019 04:08:40 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:53631) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h4htL-0001LN-W5 for 34757@debbugs.gnu.org; Fri, 15 Mar 2019 04:08:36 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:52098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4htG-0002Mq-2R; Fri, 15 Mar 2019 04:08:30 -0400 Original-Received: from [176.228.60.248] (port=2093 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h4htF-0000sz-8S; Fri, 15 Mar 2019 04:08:29 -0400 In-reply-to: (message from Pip Cet on Fri, 8 Mar 2019 21:13:37 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:156375 Archived-At: > From: Pip Cet > Date: Fri, 8 Mar 2019 21:13:37 +0000 > Cc: 34757@debbugs.gnu.org > > On Tue, Mar 5, 2019 at 3:30 PM chuntaro wrote: > > > > Invalid bytecode is output and error occurs when executed. > > If I'm looking at this correctly, the problem is that the byte code > which is generated in an intermediate step: > > 0 constant 2 > 1 constant print > 2 constant 1 > 3 call 1 > 4 discard > 5 constant 3 > 6 return > > is considered a "trivial function" by byte-compile-out-toplevel, which > assumes that all values on the stack are used by the call. > > We could fix byte-compile-out-toplevel to properly analyze how many > stack arguments the call takes, but this patch simply treats forms > like this as nontrivial: > > diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el > index 0b8f8824b4c..4e54e08ce14 100644 > --- a/lisp/emacs-lisp/bytecomp.el > +++ b/lisp/emacs-lisp/bytecomp.el > @@ -3025,6 +3025,7 @@ byte-compile-out-toplevel > (or (null (cdr rest)) > (and (memq output-type '(file progn t)) > (cdr (cdr rest)) > + (eql (length body) (cdr (car rest))) > (eq (car (nth 1 rest)) 'byte-discard) > (progn (setq rest (cdr rest)) t)))) > (setq maycall nil) ; Only allow one real function call. Stefan, any comments?