Subject: Re: bug#26047: 26.0.50; emacs crash by cl-caff2

From: Vibhav Pant <[email-masked]>
Date: Tue, 14 Mar 2017 23:48:44 +0530

Yes, I've been investigating for some time. For now, a workaround
would be to set byte-compile-cond-use-jump-table to nil before
compiling.

Thanks,
Vibhav

On Tue, Mar 14, 2017 at 11:37 PM, Andreas Politz
<[email-masked]> wrote:
>
> Using git bisect, I narrowed the cause of this down to the following
> list of commits, all of which deal with handling byte-code and have a
> single author.
>
> ----
> commit 19cb3985a3795539b51d70625904e95a6e581eef
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 26 01:00:41 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el:Use correct size for switch jump-table
> commit 4e6140b28324a9a63d54084c920206d00aed094e
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 26 01:02:16 2017 +0530
>
>     * lisp/emacs-lisp/disass.el: Display jump tables for switch.
> commit c52a9b6ddd9166571e6bc8bb9426b0267874f9fa
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 26 00:58:36 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el: Simplify b-c-cond-valid-obj2-p
> commit 6a82d19db18f8480342cc4c1a0ad76c75df41941
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 26 14:28:23 2017 +0530
>
>     * lisp/emacs-lisp/disass.el: Fix spacing while showing jump tables
> commit 8189b97e5ca12aff8ea34617431a868010643b5b
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 26 00:57:10 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el: Fix byte-switch codegen with symbols.
> commit 0d3c57dcf3187864c0b6fd6115ee80ad33faf553
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 26 00:54:59 2017 +0530
>
>     * lisp/emacs-lisp/byte-opt.el: Add support for decompiling switch
>
>     * lisp/emacs-lisp/byte-opt.el: (byte-decompile-bytecode-1) When the
>       constant encountered precedes a byte-switch op, replace all the
>       addresses in the jump table with tags.
> commit a7e4870f165e9fd36d5cfcabb19b215b94373602
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 26 14:31:16 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el: Use correct function to push nil
>
>     * lisp/emacs-lisp/bytecomp.el: (byte-compile-cond-jump-table) Use
>       byte-compile-constant instead of byte-compile-form to push nil.
> commit 23a130ee0d61fc39cee157921679809017a02b39
> Author: Vibhav Pant <[email-masked]>
> Date:   Sat Jan 21 11:37:20 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el: Remove unused debugging statements.
> commit 25d38a06eceb0853190a2d9acf53d85686f524bd
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 26 23:03:02 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el:(bc-cond-jump-table-info)add docstring
> commit bf7f7c0d82a56ed1b76358657e74ca2833b19fe2
> Merge: 25d38a06ec 9c4dfdd1af
> Author: Vibhav Pant <[email-masked]>
> Date:   Mon Jan 30 18:35:43 2017 +0530
>
>     Merge remote-tracking branch 'origin/master' into feature/byte-switch
> commit fbe6b90b0ced594cf74d5fd0dc9a32666f0d7d38
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 19 23:13:53 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el: Fix errors with matching quoted forms
>
>     * lisp/emacs-lisp/bytecomp.el: (byte-compile-cond-jump-table-info)
>       eval obj2 to avoid quoted forms being stored as is.
> commit 5f3379b33866ff7dc16856b6c29712eae860af0e
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 19 23:13:13 2017 +0530
>
>     lisp/emacs-lisp/bytecomp.el: Use byte-switch only for quoted symbols
> commit f441451658ecb8d0d8ba386d9fd3eebf3b17d549
> Author: Vibhav Pant <[email-masked]>
> Date:   Mon Jan 30 19:22:09 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el: Create jump tables with :purecopy t
> commit 46193d5209780d21b848374d8c377fb6c8896d1b
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 19 23:12:09 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el: Add default-case for last cond clause.
>
>     * lisp/emacs-lisp/bytecomp.el: (byte-compile-cond-jump-table) Add
>     default-case for last cond clause.
> commit bfa88520136dd6b187ba101e6db5a5f8f0d5e874
> Author: Vibhav Pant <[email-masked]>
> Date:   Wed Feb 1 18:15:59 2017 +0530
>
>     Use maphash instead of cl-loop.
>
>     * lisp/emacs-lisp/bytecomp.el: (byte-compile-lapcode) Use maphash
>       instead of cl-loop
> commit 522f16dac945eee351cefb066af40f0d1a683f38
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 19 18:35:46 2017 +0530
>
>     Add type checking for Bswitch, when enabled at compile time.
>
>     * src/bytecode.c: (exec_byte_code) If BYTE_CODE_SAFE is enabled at
>       compile time, use CHECK_TYPE to verify that the jump table is a hash table.
> commit de456d1e4a1d7e34be6d040e0d8a04c42b14e62e
> Author: Vibhav Pant <[email-masked]>
> Date:   Fri Feb 3 23:23:28 2017 +0530
>
>     Revert "Use maphash instead of cl-loop."
>
>     This reverts commit bfa88520136dd6b187ba101e6db5a5f8f0d5e874.
> commit 1fcbd352f8116aca1ecdb62e84f3d86b89bc446f
> Author: Vibhav Pant <[email-masked]>
> Date:   Thu Jan 19 18:02:40 2017 +0530
>
>     Use byte-switch for all symbols.
>
>     * lisp/emacs-lisp/bytecomp.el: (byte-compile-cond-valid-obj2-p) Return
>       t for all symbols (instead for just keywords)
> commit 44c95c58b26b7b9d75965a83930ec3d77ffae28f
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Feb 5 15:37:43 2017 +0530
>
>     bytecomp.el: Don't store non-keyword symbols in jump-tables.
>
>     * lisp/emacs-lisp/bytecomp.el (byte-compile-cond-valid-obj2-p) return
>       nil when OBJ is a non-keyword symbol (i.e a variable), as the jump
>       table can only be used when comparing variables with constant values.
> commit 086c4eaf9d4ecc5074088115fa01c0b2fb061246
> Author: Vibhav Pant <[email-masked]>
> Date:   Wed Jan 18 22:40:50 2017 +0530
>
>     * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch
>
>     Fgethash type checks the provided table object, which is unnecessary
>     for compiled bytecode.
> commit 84eef501554324b22c7a838aabed77aa79315121
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Feb 5 18:49:24 2017 +0530
>
>     byte-opt.el: Replace jump tables while decompiling correctly.
>
>     * lisp/emacs-lisp/byte-opt.el (byte-decompile-bytecode-1):
>       Don't make a copy of the constant vector, as it isn't used with
>       the decompiled lapcode.
>       Make sure that the correct lapcode pair/list is being modified while
>       replacing the jump table.
> commit 37956463d67795819fe7d8fe02d6249388364783
> Merge: 309b46420e fd6b829d91
> Author: Vibhav Pant <[email-masked]>
> Date:   Mon Jan 16 19:49:24 2017 +0530
>
>     update branch
> commit fea1ad36a0f7b1538984ab0f077095a53c570aa4
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Feb 5 18:55:45 2017 +0530
>
>     ; * byte-opt.el (byte-decompile-bytecode-1): Add more documentation.
> commit 309b46420e83826ed1e0b947f98a47e8525e3c36
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Jan 15 21:38:31 2017 +0530
>
>     * lisp/emacs-lisp/byte-opt.el: Optimize how tags are checked for use.
>
>     * byte-opt.el: (byte-optimize-lapcode): Return nil instantly on
>       finding the tag in a jump table.
> commit cadb044fc2e69266308cdcabe6181be0f624b484
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Feb 5 19:23:53 2017 +0530
>
>     bytecomp.el: Inline lapcode containing `byte-switch' correctly.
>
>     * lisp/emacs-lisp/bytecomp.el (byte-compile-inline-lapcode):
>       Restore value of byte-compile-depth after emitting a jump to a tag
>       in a jump table, or default/done tags.
>       Set the depth of final tags for byte-switch to nil after emitting
>       any jumps to them.
> commit 490fc5a5029c0d8e527a0c7f423ba83fd6afda60
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Feb 5 21:48:27 2017 +0530
>
>     ; bytecomp.el (-inline-lapcode): Fix incorrect parenthesis, refactor
> commit 8c0f326ea237e8acd03c51c1b3a44d237c044562
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Jan 15 19:36:26 2017 +0530
>
>     * lisp/emacs-lisp/bytecomp.el: Add documentation, remove code duplication
> commit 382f6603ad4ba2a69b3961bdc68580ce77d222f9
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Feb 5 21:51:05 2017 +0530
>
>     ; Fix typo.
>
>     * lisp/emacs-lisp/bytecomp.el (byte-compile-cond-jump-table-info): Fix
>       typo in docstring.
> commit 88549ec38e9bb30e338a9985d0de4e6263b40fb7
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Jan 15 01:26:04 2017 +0530
>
>     Add new 'switch' byte-code.
>
>     'switch' takes two arguments from the stack: the variable to test, and
>     a jump table (implemented as a hash-table with the appropriate :test
>     function). By looking up the value of the variable in the hash table,
>     the interpreter can jump to the label pointed to by the value, if any.
>     This implementation can only be used for `cond' forms of the type
>     `(cond ((test x 'foo) 'bar) ...)`, such that the function `test` and
>     variable `x` is same for all clauses.
>
>     * lisp/emacs-lisp/bytecomp.el:
>
>       * Add (byte-compile-cond-valid-obj2-p), (byte-compile-cond-vars),
>         (byte-compile-cond-jump-table-info), (byte-compile-jump-table-add-tag),
>         (byte-compile-cond-jump-table), byte-compile-jump-tables.
>
>       * Add defcustom `byte-compile-cond-use-jump-table'.
>
>       * (byte-compile-cond): Use them.
>
>       * (byte-compile-lapcode): Patch tags present in jump tables, if any.
>
>     * lisp/emacs-lisp//byte-opt.el: (byte-optimize-lapcode): Add checks to
>       some peephole optimizations to prevent them from messing up any code
>       involving `byte-switch`.
>
>     * src/bytecode.c: (exec_byte_code): Add bytecode Bswitch.
> commit 74a3423b0b92b80d84f6de62d1f2d61c21e4bd90
> Author: Vibhav Pant <[email-masked]>
> Date:   Sun Feb 5 22:10:22 2017 +0530
>
>     * byte-opt.el (byte-decompile-bytecode-1): Use eq instead of =.
>
> ----
> -ap

-- 
Vibhav Pant
[email-masked]