Subject: bug#53924: 26.1; fontification sometimes fails for some characters despite available glyphs

From: "Greg A. Woods" <[email-masked]>
Date: Tue, 15 Feb 2022 14:04:56 -0800

At Tue, 15 Feb 2022 16:21:43 +0200, Eli Zaretskii <[email-masked]> wrote:
Subject: Re: bug#53924: 26.1; fontification sometimes fails for some characters despite available glyphs
>
> Can you show a simple Emacs -Q invocation with that font which
> crashes?  Then I think I or someone else could look into the reasons.

I'll work on that.

In the mean time here's another crash in the exact same spot, but this
time triggered a new way, while trying to zoom the "*Font Families*"
window created by my test function with text-scale-adjust (C-x C-+).
Before zooming all the sample text for all fonts in the window was
viewable without any problem.

I still can't figure out, I think because of the inline function,
exactly which line within fontset_find_font() where the crash happens.

Perhaps I should rebuild with -O0?

(this is Emacs from yesterday's Git master, with the Lucid toolkit)

(gdb) source ../src/.gdbinit
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from terminal]
DISPLAY = very.local:0
TERM = xterm-256color
Breakpoint 1 at 0xdcd800: file ../../src/emacs.c, line 408.
Breakpoint 2 at 0x4c7bdd: file ../../src/xterm.c, line 13072.
../src/.gdbinit:1375: Error in sourced command file:
Scripting in the "Python" language is not supported in this copy of GDB.
(gdb) run
Starting program: /work/woods/m-emacs/build-x86_64-nb9.99.81/src/emacs-29.0.50.1
[New LWP 17054 of process 7937]
[New process 7937]
Thread 1 "" received signal SIGSEGV, Segmentation fault.
fontset_find_font (fontset=fontset@entry=0xacb, c=c@entry=180,
    face=face@entry=0x7f04f5ec82c0, charset_id=charset_id@entry=-1,
    fallback=fallback@entry=false) at ../../src/lisp.h:757
757       return lisp_h_XLP (o);
(gdb) pp fontset
#<INVALID_LISP_OBJECT 0x00000acb>
(gdb) pp face
#<INVALID_LISP_OBJECT 0x7f04f5ec82c0>
(gdb) print fontset
$1 = (Lisp_Object) 0xacb
(gdb) print face
$2 = (struct face *) 0x7f04f5ec82c0
(gdb) print *fontset
$4 = <incomplete type>
(gdb) print *face
$3 = {lface = {0x63f0, 0x7f05110cd184, 0x7f0515df8dc4, 0xb2e0, 0x26e, 0xa170,
    0x7f05133441b0, 0x0, 0x0, 0x7f0515e54404, 0x7f0515e54424, 0x0, 0x0, 0x0, 0x0,
    0x7f0512221465, 0x0, 0x7f0511de0864, 0xf480, 0x0}, id = 4121, gc = 0x0, stipple = 0,
  foreground = 0, background = 16777215, underline_color = 0, overline_color = 0,
  strike_through_color = 0, box_color = 0, font = 0x0, fontset = -1,
  box_vertical_line_width = 0, box_horizontal_line_width = 0,
  underline_pixels_above_descent_line = 0, box = FACE_NO_BOX,
  underline = FACE_NO_UNDERLINE, use_box_color_for_shadows_p = false,
  overline_p = false, strike_through_p = false, foreground_defaulted_p = false,
  background_defaulted_p = false, underline_defaulted_p = false,
  overline_color_defaulted_p = false, strike_through_color_defaulted_p = false,
  box_color_defaulted_p = false, underline_at_descent_line_p = false,
  tty_bold_p = false, tty_italic_p = false, tty_underline_p = false,
  tty_reverse_p = false, tty_strike_through_p = false, colors_copied_bitwise_p = false,
  overstrike = false, hash = 34914959679024, next = 0x7f04fbd65a40, prev = 0x0,
  ascii_face = 0x7f04f5ec82c0, extra = 0x0}
(gdb) info locals
vec = <optimized out>
font_group = <optimized out>
i = <optimized out>
charset_matched = 0
found_index = <optimized out>
f = <optimized out>
rfont_def = <optimized out>
(gdb) bt
#0  fontset_find_font (fontset=fontset@entry=0xacb, c=c@entry=180,
    face=face@entry=0x7f04f5ec82c0, charset_id=charset_id@entry=-1,
    fallback=fallback@entry=false) at ../../src/lisp.h:757
#1  0x00000000005ee5dd in fontset_font (fontset=fontset@entry=0xacb, c=c@entry=180,
    face=face@entry=0x7f04f5ec82c0, id=-1) at ../../src/fontset.c:766
#2  0x00000000005eec55 in face_for_char (f=0x7f051297e9e0,
    face=face@entry=0x7f04f5ec82c0, c=180, pos=<optimized out>, object=<optimized out>)
    at ../../src/fontset.c:996
#3  0x0000000000436fd2 in FACE_FOR_CHAR (object=<optimized out>, pos=<optimized out>,
    character=<optimized out>, face=0x7f04f5ec82c0, f=<optimized out>)
    at ../../src/dispextern.h:1908
#4  get_next_display_element (it=it@entry=0x7f7fffb88b10) at ../../src/xdisp.c:8012
#5  0x000000000043e326 in display_line (it=it@entry=0x7f7fffb88b10,
    cursor_vpos=cursor_vpos@entry=0) at ../../src/xdisp.c:24105
#6  0x00000000004437fa in try_window (window=window@entry=0x7f0508317cfd, pos=...,
    flags=flags@entry=1) at ../../src/xdisp.c:20009
#7  0x0000000000461bc8 in redisplay_window (window=0x7f0508317cfd,
    just_this_one_p=just_this_one_p@entry=false) at ../../src/xdisp.c:19416
#8  0x0000000000463881 in redisplay_window_0 (window=window@entry=0x7f0508317cfd)
    at ../../src/xdisp.c:17061
#9  0x0000000000572a8e in internal_condition_case_1 (
    bfun=bfun@entry=0x463858 <redisplay_window_0>, arg=arg@entry=0x7f0508317cfd,
    handlers=<optimized out>, hfun=hfun@entry=0x417fee <redisplay_window_error>)
    at ../../src/eval.c:1503
#10 0x000000000041ab68 in redisplay_windows (window=0x7f0508317cfd)
    at ../../src/xdisp.c:17041
#11 0x000000000044cb8f in redisplay_internal () at ../../src/xdisp.c:16509
#12 0x000000000044df61 in redisplay () at ../../src/xdisp.c:15719
#13 0x0000000000502cb8 in read_char (commandflag=commandflag@entry=1,
    map=map@entry=0x7f051157e083, prev_event=0x0,
    used_mouse_menu=used_mouse_menu@entry=0x7f7fffb8dbfb, end_time=end_time@entry=0x0)
    at ../../src/keyboard.c:2586
#14 0x000000000050448f in read_key_sequence (keybuf=keybuf@entry=0x7f7fffb8dd10,
    prompt=prompt@entry=0x0, dont_downcase_last=dont_downcase_last@entry=false,
    can_return_switch_frame=can_return_switch_frame@entry=true,
    fix_current_buffer=fix_current_buffer@entry=true,
    prevent_redisplay=prevent_redisplay@entry=false) at ../../src/keyboard.c:9778
#15 0x0000000000505f82 in command_loop_1 () at ../../src/lisp.h:1153
#16 0x0000000000572a08 in internal_condition_case (
    bfun=bfun@entry=0x505d75 <command_loop_1>, handlers=handlers@entry=0x90,
    hfun=hfun@entry=0x4fa596 <cmd_error>) at ../../src/eval.c:1479
#17 0x00000000004f3f97 in command_loop_2 (handlers=handlers@entry=0x90)
    at ../../src/keyboard.c:1137
#18 0x000000000057296e in internal_catch (tag=tag@entry=0xe9d0,
--Type <RET> for more, q to quit, c to continue without paging--
    func=func@entry=0x4f3f81 <command_loop_2>, arg=arg@entry=0x90)
    at ../../src/eval.c:1210
#19 0x00000000004f3f50 in command_loop () at ../../src/lisp.h:1153
#20 0x00000000004fa1da in recursive_edit_1 () at ../../src/keyboard.c:724
#21 0x00000000004fa4ef in Frecursive_edit () at ../../src/keyboard.c:807
#22 0x0000000000dd55d7 in main (argc=2, argv=0x7f7fffb8e098) at ../../src/emacs.c:2430
(gdb)

--
					Greg A. Woods <[email-masked]>

Kelowna, BC     +1 250 762-7675           RoboHack <[email-masked]>
Planix, Inc. <[email-masked]>     Avoncote Farms <[email-masked]>