Subject: Re: bug#48337: Fwd: 28.0.50; Emacs crashing randomly (possibly minibuffer activity related)

From: Alan Mackenzie <[email-masked]>
Date: Tue, 11 May 2021 20:14:47 +0000

Hello, Alex.

On Tue, May 11, 2021 at 07:51:20 +0100, Alex Bennée wrote:
> I can now recreate at will with a magit sequence (l o hackbox/ TAB) which
> triggers a minibuffer re-size to accommodate the list of git branches:

Could you possibly give us a precise recipe to reproduce this bug, and a
GDB backtrace with Emacs compiled with CFLAGS='-O0 g3' (or similar)?  So
much of the needed information in your large dump post has been
optimised away by the compiler.  Would you please also make sure that
the Lisp backtrace is at the end of the GDB backtrace.  I think this
should happen automatically if you have an Emacs .gdbinit in the
directory where you start GDB from.

That Factive_minibuffer_window is throwing an error is mainly because it
is being invalidly called.  In particular, the variable minibuf_level
appears to be invalid, as compared with the internal list of
minibuffers.

Would you please also test my theory of the last paragraph, by applying
the following patch (which reverses Eli's recent patch) and seeing if
the bug still happens.  Thanks!

diff --git a/src/minibuf.c b/src/minibuf.c
index 52d1275451..3afba0db68 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -653,6 +653,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
     }
 
   minibuf_level++;         /* Before calling choose_minibuf_frame.  */
+  minibuffer = get_minibuffer (minibuf_level); /* Temporary fix, 2021-05-11. */
 
   /* Choose the minibuffer window and frame, and take action on them.  */
 
@@ -766,7 +767,8 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
 
   /* Switch to the minibuffer.  */
 
-  minibuffer = get_minibuffer (minibuf_level);
+  /* minibuffer = get_minibuffer (minibuf_level); Temporarily moved,
+     2021-05-11. */
   set_minibuffer_mode (minibuffer, minibuf_level);
   Fset_buffer (minibuffer);
 
@@ -969,8 +971,8 @@ is_minibuffer (EMACS_INT depth, Lisp_Object buf)
 nth_minibuffer (EMACS_INT depth)
 {
   Lisp_Object tail = Fnthcdr (make_fixnum (depth), Vminibuffer_list);
-  if (NILP (tail))
-    return Qnil;
+  /*  if (NILP (tail)) Temporarily commented out, 2021-05-11
+      return Qnil; */
   return XCAR (tail);
 }

[ .... ]

> Let me know if you want something else.

See above.  ;-)

[ .... ]

> On Tue, 11 May 2021 at 03:24, Eli Zaretskii <[email-masked]> wrote:

> > Please show the Lisp value of Vminibuffer_list.

I have seen the answer to this request.  Thanks!

> -- 
> Alex Bennée
> KVM/QEMU Hacker for Linaro

-- 
Alan Mackenzie (Nuremberg, Germany).