Subject: bug#43700: 28.0.50; Crash creating a second frame

From: Andy Moreton <[email-masked]>
Date: Thu, 01 Oct 2020 01:15:20 +0100

On Wed 30 Sep 2020, Andy Moreton wrote:

> On Tue 29 Sep 2020, Andy Moreton wrote:
>
>> On 29/09/2020 15:37, Eli Zaretskii wrote:
>>>> From: Andy Moreton <[email-masked]>
>>>> Date: Tue, 29 Sep 2020 11:46:48 +0100
>>>>
>>>> After loading emacs (and files saved by desktop), do C-x 5 2 to create a
>>>> new frame. Emacs crashes, and gdb shows the following backtrace.
>>> Is this repeatable?  Does it happen with "emacs -Q", per chance?  Or
>>> with unoptimized builds?
>
> Building with -O0 from commit 5b0d8d0f288fd505ca90bd30df709a5e7ab540d6 I
> can reproduce the crash on another machine with the same setup:

I have not managed to repro this problem from emacs -Q, but after
further investigation I have narrowed it down to some interaction with
settings in my .emacs.d/init.el and org mode:

1) Run "emacs --no-desktop" (so using my init.el)
2) Load a trivial org file (e.g. containing "* foo", a single heading)
3) Type "C-x 5 2" to create a new frame (causing the crash)

The init.el file has:

    (tool-bar-mode 0))
    ;; ...much omitted...

    (use-package org
    :bind
    (:map org-mode-map
          ([remap org-toggle-archive-tag]         . ignore)
          ([remap org-archive-subtree]            . ignore)
          ([remap org-archive-subtree-default]    . ignore)
          ([remap org-archive-to-archive-sibling] . ignore))
     ...

If I comment out the remap bindings, emacs does not crash in the recipe above,
and also does not crash if I use this instead:

    (use-package org
    :bind
    (:map org-mode-map
          ("C-c C-x a"     . nil)  ;; was org-toggle-archive-tag
          ("C-c $"         . nil)  ;; was org-archive-subtree
          ("C-c C-x C-a"   . nil)  ;; was org-archive-subtree-default
          ("C-c C-x A"     . nil)) ;; was org-archive-to-archive-sibling
     ...

I have an effective workaround now, but nevertheless emacs should not
crash: the key binding commands should reject invalid configuration.

The use-package binding internals invoke define-key, and that macro
should reject invalid settings.

    AndyM