all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Vibhav Pant <vibhavp@gmail.com>
To: Andreas Politz <politza@hochschule-trier.de>
Cc: 26047@debbugs.gnu.org, Leo Liu <sdl.web@gmail.com>
Subject: bug#26047: 26.0.50; emacs crash by cl-caff2
Date: Fri, 17 Mar 2017 01:15:03 +0530	[thread overview]
Message-ID: <CA+T2Sh1MS8vW5NUBTFWOFOrGJ7MM0ttYA1iUqq0kX2HTo5y0aQ@mail.gmail.com> (raw)
In-Reply-To: <877f3ru2d6.fsf@luca>

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

Could you apply this patch, and see if the issue is fixed?

Thanks,
Vibhav

On Wed, Mar 15, 2017 at 12:12 AM, Andreas Politz
<politza@hochschule-trier.de> wrote:
> Vibhav Pant <vibhavp@gmail.com> writes:
>
>> Yes, I've been investigating for some time.
>
> OK, thank you.
>
> -ap



-- 
Vibhav Pant
vibhavp@gmail.com

[-- Attachment #2: fix-inline.patch --]
[-- Type: text/x-patch, Size: 4503 bytes --]

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 7cbef8e434..da0a24c614 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3140,7 +3140,7 @@ byte-compile-inline-lapcode
   ;; lexical-binding, but it's not true in general, and it's not true for
   ;; code output by bytecomp.el with lexical-binding.
   ;; We also restore the value of `byte-compile-depth' and remove TAG depths
-  ;; accordingly when inlining lapcode containing lap-code, exactly as
+  ;; accordingly when inlining lapcode which uses `byte-switch', exactly as
   ;; documented in `byte-compile-cond-jump-table'.
   (let ((endtag (byte-compile-make-tag))
         last-jump-tag ;; last TAG we have jumped to
@@ -3148,22 +3148,27 @@ byte-compile-inline-lapcode
         last-constant ;; value of the last constant encountered
         last-switch ;; whether the last op encountered was byte-switch
         switch-tags ;; a list of tags that byte-switch could jump to
+        last-tag ;; last TAG that we have output
+        restore-depth ;; if non-nil, `byte-compile-depth' is set to `last-depth'
         ;; a list of tags byte-switch will jump to, if the value doesn't
         ;; match any entry in the hash table
         switch-default-tags)
     (dolist (op lap)
       (cond
        ((eq (car op) 'TAG)
-        (when (or (member op switch-tags) (member op switch-default-tags))
+        (when (or restore-depth
+                  (member op switch-tags)
+                  (member op switch-default-tags))
           ;; This TAG is used in a jump table, this means the last goto
           ;; was to a done/default TAG, and thus it's cddr should be set to nil.
           (when last-jump-tag
             (setcdr (cdr last-jump-tag) nil))
           ;; Also, restore the value of `byte-compile-depth' to what it was
-          ;; before the last goto.
+          ;; before the last goto/return.
           (setq byte-compile-depth last-depth
-                last-jump-tag nil))
-        (byte-compile-out-tag op))
+                last-jump-tag nil
+                restore-depth nil))
+        (byte-compile-out-tag (setq last-tag op)))
        ((memq (car op) byte-goto-ops)
         (setq last-depth byte-compile-depth
               last-jump-tag (cdr op))
@@ -3176,7 +3181,15 @@ byte-compile-inline-lapcode
           (setq byte-compile-depth last-depth
                 last-switch nil)))
        ((eq (car op) 'byte-return)
-        (byte-compile-discard (- byte-compile-depth end-depth) t)
+        ;; the byte optimizer replaces some goto's with returns,
+        ;; we check whether the goto replaced was a jump to a
+        ;; switch DONETAG, and set `restore-depth' and
+        ;; `last-depth' accordingly
+        (if (member last-tag switch-tags)
+            (progn (setq last-depth byte-compile-depth
+                         restore-depth t)
+                   (byte-compile-discard 1 t))
+          (byte-compile-discard (- byte-compile-depth end-depth) t))
         (byte-compile-goto 'byte-goto endtag))
        (t
         (when (eq (car op) 'byte-switch)
@@ -4031,6 +4044,7 @@ byte-compile-cond-jump-table-info
 The condition for each clause is of the form (TEST VAR VALUE).
 VAR is a variable.
 TEST and VAR are the same throughout all conditions.
+TEST is either eq, eql or equal.
 VALUE satisfies `macroexp-const-p'.
 
 Return a list of the form ((TEST . VAR)  ((VALUE BODY) ...))"
@@ -4082,7 +4096,7 @@ byte-compile-cond-jump-table
             donetag (byte-compile-make-tag))
       ;; The structure of byte-switch code:
       ;;
-      ;; varref var
+      ;; varref var/stack-ref <n>
       ;; constant #s(hash-table purecopy t data (val1 (TAG1) val2 (TAG2)))
       ;; switch
       ;; goto DEFAULT-TAG
@@ -4092,9 +4106,9 @@ byte-compile-cond-jump-table
       ;; TAG2
       ;; <clause body>
       ;; goto DONETAG
-      ;; DEFAULT-TAG
+      ;; DEFAULT-TAG:
       ;; <body for `t' clause, if any (else `constant nil')>
-      ;; DONETAG
+      ;; DONETAG:
 
       (byte-compile-variable-ref var)
       (byte-compile-push-constant jump-table)
@@ -4114,6 +4128,8 @@ byte-compile-cond-jump-table
               cases (butlast cases 1)))
 
       (dolist (case cases)
+        ;; TODO: Perhaps use a new tag type (SWITCH-TAG) for this, so we can
+        ;; recognize and deal with switch bytecode/lapcode more easily.
         (setq tag (byte-compile-make-tag)
               test-obj (nth 0 case)
               body (nth 1 case))

  reply	other threads:[~2017-03-16 19:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10 10:01 bug#26047: 26.0.50; emacs crash by cl-caff2 Leo Liu
2017-03-10 20:56 ` Andreas Politz
2017-03-14 18:07   ` Andreas Politz
2017-03-14 18:18     ` Vibhav Pant
2017-03-14 18:42       ` Andreas Politz
2017-03-16 19:45         ` Vibhav Pant [this message]
2017-03-17 10:17           ` Andreas Politz
2017-03-17 11:39             ` Vibhav Pant
2017-03-17 15:44               ` Andreas Politz
2017-05-18  3:19                 ` npostavs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+T2Sh1MS8vW5NUBTFWOFOrGJ7MM0ttYA1iUqq0kX2HTo5y0aQ@mail.gmail.com \
    --to=vibhavp@gmail.com \
    --cc=26047@debbugs.gnu.org \
    --cc=politza@hochschule-trier.de \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.