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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 11 May 2021 16:42:26 +0300

> From: Alex Bennée <[email-masked]>
> Date: Tue, 11 May 2021 13:54:02 +0100
> Cc: [email-masked], Alan Mackenzie <[email-masked]>
> 
> (gdb) pp Vminibuffer_list
> (#<buffer  *Minibuf-0*> #<buffer  *Minibuf-1*>)

Thanks.

Alan, the code in nth_minibuffer and its callers is unsafe.  First,
Fnthcdr can return nil, and then XCAR of that in nth_minibuffer
crashes.  I fixed that now on the master branch, but there're more
problems: some the callers of nth_minibuffer don't seem to be
protected from it returning nil.  For example, we have this in
read_minibuf_unwind:

  Fset_buffer (nth_minibuffer (minibuf_level));

and this in minibuffer_unwind:

	set_window_buffer (window, nth_minibuffer (0), 0, 0);

In other cases you compare windows with nil, which can never be true,
so a preliminary test for nil would be nice to avoid a loop that can
never find anything useful.

Please make this code more robust.

Thanks.