Subject: bug#72692: closed (Re: bug#72692: Emacs 31.05 (40eecd594ac) get SIGSEGV on Linux (Linux 6.6.45 Kde Wayland))

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 24 Aug 2024 09:13:02 +0000

Your bug report

#72692: Emacs 31.05 (40eecd594ac) get SIGSEGV on Linux (Linux 6.6.45 Kde Wayland)

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
72692: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72692
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#72692: Emacs 31.05 (40eecd594ac) get SIGSEGV on Linux (Linux 6.6.45 Kde Wayland)
From: Eli Zaretskii <[email-masked]>
To: [email-masked]
Cc: [email-masked], [email-masked]
Date: Sat, 24 Aug 2024 12:09:09 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Cc: [email-masked], [email-masked]
> Date: Mon, 19 Aug 2024 19:49:03 +0300
> From: Eli Zaretskii <[email-masked]>
> 
> > Date: Mon, 19 Aug 2024 16:34:59 +0000
> > From: Pip Cet <[email-masked]>
> > Cc: [email-masked], [email-masked]
> > 
> > "Eli Zaretskii" <[email-masked]> writes:
> > 
> > > Thanks, but I'd also like to see the callers which call
> > > free_realized_face in a way that causes the latter to call
> > > free_face_fontset.  That's why I asked for backtraces from those
> > > calls, but I don't think you sent such backtraces.  What you sent was
> > 
> > Just for the record, you asked:
> > 
> > > So can you show a backtrace from the call to free_realized_faces
> > > (supposedly called by realize_basic_faces?) which causes these
> > > printfs:
> > > > fontset 103 used for face 0x117cca0
> > > > fontset 103 used for face 0x2a7a3c0
> > > > fontset 103 used for face 0x117cca0
> > > > fontset 103 used for face 0x2a62860
> > 
> > ... which I misunderstood.  Sorry.
> 
> Sorry for being unclear.
> 
> > Is this what you want?
> 
> Yes, recompute_basic_faces was the prime suspect.  I think we added
> several calls to it over the last years, to fix problems with face
> cache being emptied at some unexpected times.
> 
> > Indeed, I can report that the bug doesn't seem to occur after this
> > simple change:
> > 
> > diff --git a/src/xfaces.c b/src/xfaces.c
> > index 684b6ccfac7..a4ac9c0787a 100644
> > --- a/src/xfaces.c
> > +++ b/src/xfaces.c
> > @@ -736,6 +736,7 @@ recompute_basic_faces (struct frame *f)
> >        clear_face_cache (false);
> >        if (!realize_basic_faces (f))
> >         emacs_abort ();
> > +      f->face_change = true;
> >      }
> >  }
> >  
> > 
> > So something like that (though moving the call down into
> > realize_basic_faces or even further would be good) would probably work
> > for the OP, and emacs-30?
> 
> I think setting the flag in recompute_basic_faces should be enough.
> Let me think about it some more.

I decided to go with this change only, and installed it on the
emacs-30 release branch.  Let's hope it makes this tricky problem go
away.

I'm closing this bug.  If the problem resurfaces, we can reopen it.

Subject: Emacs 31.05 (40eecd594ac) get SIGSEGV on Linux (Linux 6.6.45 Kde Wayland)
From: Eval EXEC <[email-masked]>
To: [email-masked]
Date: Sun, 18 Aug 2024 16:29:13 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

I'm help to tesing Emacs master branch (commit: 40eecd594ac) on Linux.

I compile emacs source code by:

```bash

make extraclean
./autogen.sh \
   && ./configure \
   --prefix=$(realpath ../emacs-build/$(git branch --show-current | sed 
's/\//_/g'))\
   --with-imagemagick --with-xwidgets \
   --with-modules --with-x-toolkit=gtk3 --without-compress-install \
   --without-toolkit-scroll-bars --with-native-compilation --with-mailutils\
   --with-tree-sitter --with-xinput2  \
   --with-dbus  --with-native-compilation=aot \
   --with-file-notification=inotify\
   && make -j30 install
```

When I using emacs, I got crash, the backtrace is :

```

line to your configuration file "/home/exec/.config/gdb/gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the 
shell:
         info "(gdb)Auto-loading safe path"
warning: File 
"/nix/store/x47hg342iyiw50c1fhqjzz4n0rqy3dhh-isl-0.20/lib/libisl.so.19.1.0-gdb.py" 
auto-loading has been declined by your `auto-load safe-path' set to 
"$debugdir:$datadir/auto-load:/nix/store/40yjzm7r5ki59kkk9423dnwbm86x7pyd-gcc-13.2.0-lib".
(gdb) c
The program is not being run.
(gdb) bt
#0  0x00007f9eaeea2efc in __pthread_kill_implementation () from 
/nix/store/dbcw19dshdwnxdv5q2g6wldj6syyvq7l-glibc-2.39-52/lib/libc.so.6
#1  0x00007f9eaee52e86 in raise () from 
/nix/store/dbcw19dshdwnxdv5q2g6wldj6syyvq7l-glibc-2.39-52/lib/libc.so.6
#2  0x0000000000473791 in terminate_due_to_signal (sig=sig@entry=11, 
backtrace_limit=backtrace_limit@entry=40) at emacs.c:469
#3  0x0000000000473ccd in handle_fatal_signal (sig=sig@entry=11) at 
sysdep.c:1800
#4  0x00000000005c4bf8 in deliver_thread_signal (sig=sig@entry=11, 
handler=0x473cc2 <handle_fatal_signal>) at sysdep.c:1792
#5  0x00000000005c4c7c in deliver_fatal_thread_signal (sig=11) at 
sysdep.c:1812
#6  handle_sigsegv (sig=11, siginfo=<optimized out>, arg=<optimized 
out>) at sysdep.c:1950
#7  <signal handler called>
#8  fontset_find_font (fontset=fontset@entry=0x0, c=c@entry=127802, 
face=face@entry=0x13fec610, charset_id=charset_id@entry=-1, 
fallback=fallback@entry=false)
     at /home/exec/Projects/git.savannah.gnu.org/git/emacs/src/lisp.h:2127
#9  0x00000000006dd64d in fontset_font (fontset=fontset@entry=0x0, 
c=c@entry=127802, face=face@entry=0x13fec610, id=-1) at fontset.c:793
#10 0x00000000006dddce in face_for_char (f=0x28b8ee0, 
face=face@entry=0x13fec610, c=127802, pos=<optimized out>, 
object=<optimized out>) at fontset.c:1031
#11 0x00000000004b503c in FACE_FOR_CHAR (object=<optimized out>, 
pos=<optimized out>, character=<optimized out>, face=0x13fec610, 
f=<optimized out>)
     at 
/home/exec/Projects/git.savannah.gnu.org/git/emacs/src/dispextern.h:1962
#12 get_next_display_element (it=it@entry=0x7ffe5294f4c0) at xdisp.c:8547
#13 0x00000000004c4258 in display_string (string=string@entry=0x0, 
lisp_string=lisp_string@entry=0x765cc214, 
face_string=face_string@entry=0x0, 
face_string_pos=face_string_pos@entry=0, start=<optimized out>,
     it=it@entry=0x7ffe5294f4c0, field_width=<optimized out>, 
precision=<optimized out>, max_x=496, multibyte=<optimized out>) at 
xdisp.c:29274
#14 0x00000000004c4d78 in display_mode_element 
(it=it@entry=0x7ffe5294f4c0, depth=<optimized out>, depth@entry=1, 
field_width=<optimized out>, field_width@entry=0, precision=<optimized 
out>, precision@entry=0,
     elt=<optimized out>, props=<optimized out>, risky=<optimized out>) 
at xdisp.c:27822
#15 0x00000000004c5210 in display_mode_element 
(it=it@entry=0x7ffe5294f4c0, depth=1, depth@entry=0, 
field_width=field_width@entry=0, precision=precision@entry=0, 
elt=<optimized out>, elt@entry=0xef4fb43,
     props=props@entry=0x0, risky=false) at xdisp.c:28007
#16 0x00000000004c7d00 in display_mode_line (w=w@entry=0x3064de10, 
face_id=MODE_LINE_INACTIVE_FACE_ID, format=0xef4fb43) at xdisp.c:27495
#17 0x00000000004c9fdd in display_mode_lines (w=w@entry=0x3064de10) at 
xdisp.c:27408
#18 0x00000000004dfb25 in redisplay_window (window=<optimized out>, 
just_this_one_p=just_this_one_p@entry=false) at xdisp.c:20981
#19 0x00000000004e372b in redisplay_window_0 
(window=window@entry=0x3064de15) at xdisp.c:18070
#20 0x000000000063315c in internal_condition_case_1 
(bfun=bfun@entry=0x4e3700 <redisplay_window_0>, 
arg=arg@entry=0x3064de15, handlers=<optimized out>, 
hfun=hfun@entry=0x49b6a0 <redisplay_window_error>)
     at eval.c:1637
#21 0x0000000000497ff9 in redisplay_windows (window=0x3064de15) at 
xdisp.c:18039
#22 0x000000000049801d in redisplay_windows (window=0x3064dbf5) at 
xdisp.c:18033
#23 0x00000000004cb2d3 in redisplay_internal () at xdisp.c:17438
#24 0x00000000004cc8d5 in redisplay () at xdisp.c:16613
#25 0x00000000005b3dfc in read_char (commandflag=1, 
map=map@entry=0x7650ab73, prev_event=0x0, 
used_mouse_menu=used_mouse_menu@entry=0x7ffe52955ecb, 
end_time=end_time@entry=0x0) at keyboard.c:2678
#26 0x00000000005b6f34 in read_key_sequence 
(keybuf=keybuf@entry=0x7ffe52956050, 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, 
disable_text_conversion_p=false) at keyboard.c:10736
#27 0x00000000005b8fd8 in command_loop_1 () at keyboard.c:1429
#28 0x00000000006330cf in internal_condition_case 
(bfun=bfun@entry=0x5b8e00 <command_loop_1>, 
handlers=handlers@entry=0x90, hfun=hfun@entry=0x5a8e20 <cmd_error>) at 
eval.c:1613
#29 0x00000000005a3fb6 in command_loop_2 (handlers=handlers@entry=0x90) 
at keyboard.c:1168
#30 0x0000000000632ff3 in internal_catch (tag=tag@entry=0x12450, 
func=func@entry=0x5a3f90 <command_loop_2>, arg=arg@entry=0x90) at 
eval.c:1292
#31 0x00000000005a3f51 in command_loop () at keyboard.c:1146
#32 0x00000000005a898a in recursive_edit_1 () at keyboard.c:754
#33 0x00000000005a8d0f in Frecursive_edit () at keyboard.c:837
#34 0x000000000047ca5a in main (argc=1, argv=<optimized out>) at 
emacs.c:2624
```

I believe the crash is related to the font, but I can't reproduce it. It 
happens about once a day.

What information should I provide to help investigate this bug?

And my OS info is:

```

❯ nix-info -m
  - system: `"x86_64-linux"`
  - host os: `Linux 6.6.45, NixOS, 24.05 (Uakari), 24.05.20240813.4a92571`
  - multi-user?: `yes`
  - sandbox: `yes`
  - version: `nix-env (Nix) 2.18.5`
  - channels(exec): `""`
  - channels(root): `""`
  - nixpkgs: `/nix/store/qszplw617r895nbcprgyj139c9a3r0xs-source`
```

Thank you!