Subject: Re: bug#63283: Emacs crash within fontset

From: Seppo Ronkainen <[email-masked]>
Date: Sat, 06 May 2023 22:36:35 +0000

more data

% gdb --args /home/user/.local/emacs-29.0.90_debug/inst/bin/emacs -Q ~/examplefilewithunicodetext
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/user/.local/emacs-29.0.90_debug/inst/bin/emacs...
(gdb) source /home/user/.local/emacs-29.0.90_debug/cons/src/.gdbinit
Warning: /home/user/../lwlib: No such file or directory.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from terminal]
DISPLAY = :0
TERM = xterm
Breakpoint 1 at 0x205be8: file emacs.c, line 427.
Breakpoint 2 at 0x1c4388: file xterm.c, line 26126.
(gdb) run
Starting program: /home/user/.local/emacs-29.0.90_debug/inst/bin/emacs -Q /home/user/examplefilewithunicodetext
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ff4a8ee80 (LWP 52196)]

(process:52189): Gtk-WARNING **: 21:29:18.069: Locale not supported by C library.
        Using the fallback 'C' locale.
[Detaching after vfork from child process 52197]
[Detaching after vfork from child process 52198]
[Detaching after vfork from child process 52199]

fontset.c:970: Emacs fatal error: assertion failed: fontset_id_valid_p (face->fontset)

Thread 1 "emacs" hit Breakpoint 1, terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:427
427       signal (sig, SIG_DFL);
(gdb) thread 1
[Switching to thread 1 (Thread 0x7ff5d6f700 (LWP 52189))]
#0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:427
427       signal (sig, SIG_DFL);
(gdb) bt 5
#0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:427
#1  0x000000555581ba04 in die (msg=0x55559f6900 "fontset_id_valid_p (face->fontset)", file=0x55559f6608 "fontset.c", line=970) at alloc.c:7707
#2  0x00000055559233c4 in face_for_char (f=0x55564c8470, face=0x5556292b90, c=12302, pos=1, object=XIL(0)) at fontset.c:970
#3  0x00000055555bd308 in FACE_FOR_CHAR (f=0x55564c8470, face=0x5556292b90, character=12302, pos=1, object=XIL(0)) at dispextern.h:1911
#4  0x00000055555dd054 in get_next_display_element (it=0x7fffff8a88) at xdisp.c:8184
(More stack frames follow...)

Lisp Backtrace:
"redisplay_internal (C function)" (0x0)
(gdb) frame 2
#2  0x00000055559233c4 in face_for_char (f=0x55564c8470, face=0x5556292b90, c=12302, pos=1, object=XIL(0)) at fontset.c:970
970       eassert (fontset_id_valid_p (face->fontset));
(gdb) info locals
fontset = XIL(0)
rfont_def = XIL(0x555605b2b8)
charset = XIL(0x300effff7380)
face_id = 85
id = 1432078920
(gdb) print font_driver_list
$1 = (struct font_driver_list *) 0x55560d77e0
(gdb) print f->font_driver_list
$2 = (struct font_driver_list *) 0x5556274ae0
(gdb) frame 3
#3  0x00000055555bd308 in FACE_FOR_CHAR (f=0x55564c8470, face=0x5556292b90, character=12302, pos=1, object=XIL(0)) at dispextern.h:1911
(gdb) p face->font
$5 = (struct font *) 0x0
(gdb) p face->fontset
$6 = -1
(gdb) q

if fontset carried -1 .. which in turn

/home/user/.local/emacs-29.0.90_debug/cons/src/fontset.c:970
  eassert (fontset_id_valid_p (face->fontset));
  fontset = FONTSET_FROM_ID (face->fontset);
  eassert (!BASE_FONTSET_P (fontset));

/home/user/.local/emacs-29.0.90_debug/cons/src/fontset.c:176
static bool
fontset_id_valid_p (int id)
{
  return (id >= 0 && id < ASIZE (Vfontset_table) - 1);
}

relevant commit ?
3c0dda2663e38635163f0fd6c19748c6eba1c3c8
Avoid asserting for fontset validity before it is used

Live long and prosper

Sent with Proton Mail secure email.

------- Original Message -------
On Saturday, May 6th, 2023 at 7:32 PM, Eli Zaretskii <[email-masked]> wrote:

> > Date: Sat, 06 May 2023 19:12:53 +0000
> > From: Seppo Ronkainen [email-masked]
> > Cc: [email-masked]
> > 
> > sure, here are captures of gdb and system-configuration-features from two build variants of 29.0.90 and one 26.3
> 
> 
> Thanks. Please repeat this session again, and this time, when Emacs
> aborts and GDB shows its prompt, do this:
> 
> (gdb) thread 1
> (gdb) pp fontset
> 
> If GDB says that it doesn't know the command "pp", type
> 
> (gdb) source /path/to/emacs/src/.gdbinit
> (gdb) pp fontset
> 
> and post everything GDB prints after that.
> 
> And one more data point: in the same session do this:
> 
> (gdb) frame 2
> (gdb) print font_driver_list
> (gdb) print f->font_driver_list
> 
> 
> and show the values GDB prints.