bug#73022: 31.0.50; Crash in build_frame_matrix_from_leaf_window after C-x 2 and reducing terminal size

Eli Zaretskii <[email protected]> Sun, 02 Aug 2026 10:43:01 +0300
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
> From: りすりす / TwoSquirrels
>  <[email protected]>
> Date: Sun, 2 Aug 2026 01:59:37 +0900
> 
> I tried changing the emacs_abort() in cmcheckmagic to mark the frame
> garbaged instead:
> 
> --- a/src/cm.c
> +++ b/src/cm.c
> @@ -119,7 +119,10 @@ cmcheckmagic (struct tty_display_info *tty)
>    if (curX (tty) == FrameCols (tty))
>      {
>        if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1)
> -       emacs_abort ();
> +       {
> +         SET_FRAME_GARBAGED (XFRAME (tty->top_frame));
> +         return;
> +       }
>        if (tty->termscript)
>         putc ('\r', tty->termscript);
>        putc ('\r', tty->output);
> 
> With this patch on emacs-30, the recipe does not crash any more. The
> display comes back correctly when the terminal becomes large enough
> again. The same build crashes without the patch.
> 
> I am not sure if this is the correct fix. It only skips the abort and
> leaves the redrawing to the next redisplay.

AFAIU, this fix is only correct if the problem happened due to
resizing the frame.  But the fix doesn't check that.  If the problem
happened due to some other (unspecified) cause, the fix will cause an
endless loop of redisplay, which is not very friendly.

So I think we need some additional conditions to set the frame's
garbaged flag instead of aborting, before we install something like
that.

Btw, I cannot reproduce the crash on my system, FWIW.