Subject: Re: bug#60096: 29.0.60; Crash in format_mode_line_unwind_data

From: Eli Zaretskii <[email-masked]>
Date: Sat, 17 Dec 2022 12:00:47 +0200

> Date: Sat, 17 Dec 2022 10:17:00 +0100
> Cc: [email-masked], [email-masked]
> From: martin rudalics <[email-masked]>
> 
>  > Basically, set-window-configuration was called in a situation where it
>  > has only one valid buffer to play with, which is tough for its logic
>  > and the various other functions it invokes.  The result was a bunch of
>  > bad windows with nil as their buffer.
> 
> If a live window has nil as its buffer, next redisplay will reliably
> crash Emacs anyway.  So this
> 
>        /* We may have deleted windows above.  Then again, maybe we
> 	 haven't: the functions we call to maybe delete windows can
> 	 decide a window cannot be deleted.  Force recalculation of
> 	 Vwindow_list next time it is needed, to make sure stale
> 	 windows with no buffers don't escape into the wild, which
> 	 will cause crashes elsewhere.  */
>        Vwindow_list = Qnil;
> 
> should not be needed.

It is needed in this case because it forces redisplay to recompute the
window list (in propagate_buffer_redisplay, if not earlier).  If the
above is not done, Vwindow_list will be reused, and the problematic
(bogus?) windows in it _will_ cause a crash.

> The earlier call
> 
>        delete_all_child_windows (FRAME_ROOT_WINDOW (f));
> 
> should have reliably reset Vwindow_list to nil.

AFAIR, the code which runs after that call recalculated Vwindow_list,
adding to it those windows with no buffer.  You should be able to see
that by running the simple recipe posted by Juri at the beginning of
this bug report.

What about the other parts of the changeset I installed -- do they
look okay to you? any comments?