Subject: Re: bug#71176: 30.0.50; Segmentation fault (SIGSEGV) in TTY+emacsclient, default_face is nil

From: Eli Zaretskii <[email-masked]>
Date: Fri, 24 May 2024 22:26:08 +0300

> From: Daniel Clemente <[email-masked]>
> Date: Fri, 24 May 2024 17:38:11 +0000
> 
> Using emacsclient, with Emacs compiled without X support. I'm seeing crashes from time to time, after dozens
> of hours of normal work, mainly when opening a new emacsclient frame. I didn't find how to reproduce this.
> The crashes have been happening since I switched to TTY-only (weeks or months ago). I attach some gdb
> output+exploration of 1 crash, and my build details.
> Apparently there's a nil default_face.

Which should never happen.

> My ~/.emacs is large but I don't do anything weird with the 'default face, apart from (set-face-foreground
> 'default "#bbb"). Note that #bbb appears in the backtrace.
> I use rxvt-unicode; $TERM=rxvt-unicode-256color
> 
> Could it be because the GC runs before tty_lookup_color has finished its job?

Unlikely.

> Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
> face_at_buffer_position (w=0x5555747a08e0, pos=1, endptr=endptr@entry=0x7fffffff9918, limit=<optimized
> out>, mouse=mouse@entry=false, base_face_id=<optimized out>, attr_filter=<optimized out>) at
> xfaces.c:6819
> warning: Source file is more recent than executable.
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is not a good sign: you have edited your sources after the Emacs
binary was produced, so some of the information in the backtrace and
the GDB session might be inaccurate or even incorrect.

> 6819      return default_face->id;

Do you use face-remapping?  Is face-remapping-alist non-nil when this
happens?  If so, can you show the value of Vface_remapping_alist?

> Configured using:
>  'configure --prefix=/opt/dc/emacs/ --without-dbus --with-tiff=no --without-tiff
>  --without-libsystemd --without-dbus --with-mailutils --with-native-compilation --without-modules
>  --with-x-toolkit=no --without-imagemagick --without-xft --without-harfbuzz --without-freetype
>  --without-libotf --without-xwidgets --without-xpm --without-jpeg --without-gif --without-png
>  --without-webp --without-rsvg --without-cairo --without-x 'CFLAGS=-g3 -O3''

I recommend against using -O3 to build Emacs: at the very least it
makes debugging much harder.  More importantly, with latest GCC
versions it could produce invalid code (a.k.a. "GCC bugs").  The
default optimization level -O2 should be more than enough.  (I'm not
saying this has anything to do with the segfaults.)