Subject: Re: bug#65198: 29.1; Emacs29.1 crash in function face_for_font

From: 张云峰 <[email-masked]>
Date: Fri, 11 Aug 2023 08:15:41 +0800

I've tested this patch, unfortunately, it doesn't work, still crashes

GDB information:
Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
0x0000555555619516 in produce_glyphless_glyph ()
(gdb) bt
#0  0x0000555555619516 in produce_glyphless_glyph ()
#1  0x0000555555640789 in gui_produce_glyphs ()
#2  0x0000555555623f70 in move_it_in_display_line_to ()
#3  0x000055555562935a in move_it_to ()
#4  0x000055555563e84f in window_text_pixel_size ()
#5  0x000055555563f526 in Fwindow_text_pixel_size ()
#6  0x00007fffe7dc07a8 in
F6669742d6672616d652d746f2d6275666665722d31_fit_frame_to_buffer_1_0 ()
    at /home/zayfen/github.com/emacs/src/../native-lisp/29.1.50-9e9f496f/preloaded/window-0d1b8b93-6f4eee58.eln
#7  0x000055555576a032 in funcall_subr ()
#8  0x0000555555766ba1 in Ffuncall ()
#9  0x000055555576aa04 in eval_sub ()
#10 0x000055555576ce6d in FletX ()
#11 0x000055555576aba7 in eval_sub ()
#12 0x000055555576be0d in funcall_lambda ()
#13 0x000055555576c3ee in apply_lambda ()
#14 0x000055555576a49b in eval_sub ()
#15 0x000055555576ce6d in FletX ()
#16 0x000055555576aba7 in eval_sub ()
#17 0x000055555576be0d in funcall_lambda ()
#18 0x000055555576c3ee in apply_lambda ()
#19 0x000055555576a49b in eval_sub ()
#20 0x000055555576ca2d in Flet ()
#21 0x000055555576aba7 in eval_sub ()
#22 0x000055555576aba7 in eval_sub ()
#23 0x000055555576ce6d in FletX ()
#24 0x000055555576aba7 in eval_sub ()
#25 0x000055555576af0d in Fprogn ()
#26 0x000055555576aba7 in eval_sub ()
#27 0x000055555576aba7 in eval_sub ()
#28 0x000055555576be0d in funcall_lambda ()
#29 0x000055555576c3ee in apply_lambda ()
#30 0x000055555576a49b in eval_sub ()
#31 0x000055555576aba7 in eval_sub ()
#32 0x000055555576af0d in Fprogn ()
#33 0x000055555576aba7 in eval_sub ()
#34 0x000055555576aba7 in eval_sub ()
#35 0x000055555576ce6d in FletX ()
#36 0x000055555576aba7 in eval_sub ()
#37 0x000055555576af0d in Fprogn ()
#38 0x000055555575666c in Fsave_current_buffer ()
#39 0x000055555576aba7 in eval_sub ()
#40 0x000055555576aba7 in eval_sub ()
#41 0x000055555576ce6d in FletX ()
#42 0x000055555576aba7 in eval_sub ()
#43 0x000055555576ce6d in FletX ()
#44 0x000055555576aba7 in eval_sub ()
#45 0x000055555576be0d in funcall_lambda ()
#46 0x000055555576c3ee in apply_lambda ()
#47 0x000055555576a49b in eval_sub ()
#48 0x000055555576d66b in Feval ()
#49 0x000055555576ace1 in eval_sub ()

Eli Zaretskii <[email-masked]> 于2023年8月11日周五 02:36写道：
>
> > From: 张云峰 <[email-masked]>
> > Date: Fri, 11 Aug 2023 01:58:34 +0800
> > Cc: [email-masked]
> >
> > 2023-08-11_01-53.png
> > when popup frame has the warning-icon (marked in picture) , emacs will crash immediately.
>
> Can you try the patch below and see if it prevents the crash in these
> cases?
>
> diff --git a/src/xdisp.c b/src/xdisp.c
> index 9cddcfe..b25bdc7 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -8312,9 +8312,14 @@ get_next_display_element (struct it *it)
>        && success_p
>        && FRAME_WINDOW_P (it->f))
>      {
> -      struct face *face = FACE_FROM_ID (it->f, it->face_id);
> +      struct face *face = FACE_FROM_ID_OR_NULL (it->f, it->face_id);
>
> -      if (it->what == IT_COMPOSITION && it->cmp_it.ch >= 0)
> +      if (!face)
> +       {
> +         it->what = IT_GLYPHLESS;
> +         it->glyphless_method = GLYPHLESS_DISPLAY_EMPTY_BOX;
> +       }
> +      else if (it->what == IT_COMPOSITION && it->cmp_it.ch >= 0)
>         {
>           /* Automatic composition with glyph-string.   */
>           Lisp_Object gstring = composition_gstring_from_id (it->cmp_it.id);