Subject: Re: bug#77046: 31.0.50; Emacs sometimes crashes

From: Gerd Möllmann <[email-masked]>
Date: Sun, 16 Mar 2025 12:30:39 +0100

Eli Zaretskii <[email-masked]> writes:

> Gerd, any comments for the patch?  I found that
> combine_updates_for_frame was trying to combine updates for a
> topmost_child frame whose after_make_frame flag was false and whose
> desired_matrix was NULL.  That caused a segfault in
> make_matrix_current, called from copy_child_glyphs, when make_current
> dereferenced the pointer to desired_matrix.  AFAIU, we should not even
> try redisplaying such frames.
>
> diff --git a/src/xdisp.c b/src/xdisp.c
> index ac65493..d7e0691 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -17569,7 +17569,10 @@ #define AINC(a,i)							\
>  	  if (is_tty_frame (f))
>  	    {
>  	      /* Ignore all invisible tty frames, children or root.  */
> -	      if (!frame_redisplay_p (f))
> +	      if (!frame_redisplay_p (f)
> +		  /* Ignore frames not yet completely made, which we
> +		     cannot safely redisplay.  */
> +		  || !f->after_make_frame)
>  		continue;
>  
>  	      /* Remember tty root frames which we've seen.  */
>

Yes, I think your patch is correct.

(I wonder a bit though, how redisplay got its hands on that child frame.
OTOH. the OP's .el with make-frame/delete-frame and redisplays in a
tight loop is something so unusual...)