--- Begin Message ---
Subject: |
Invalid bytecode from byte compiler |
Date: |
Tue, 5 Mar 2019 17:01:00 +0900 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 |
Invalid bytecode is output and error occurs when executed.
Byte compile the following code.
bug.el
----------------------------------------------------------------
;;; -*- lexical-binding: t; -*-
(let ((a 2))
(print 1)
(setq a 1))
----------------------------------------------------------------
$ emacs --batch -f batch-byte-compile bug.el
bug.elc
----------------------------------------------------------------
;ELC
...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(funcall 2 'print 1)
1
----------------------------------------------------------------
$ emacs --batch -l bug.elc
Invalid function: 2
It occurs in versions 25.2, 26.1 and HEAD.
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#34757: Invalid bytecode from byte compiler |
Date: |
Sat, 27 Jul 2019 17:30:03 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> 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.
I installed this fix for now.
Stefan
--- End Message ---