Subject: Re: bug#59832: 30.0.50; [TREESIT] Segfault in treesit_load_language

From: German Pacenza <[email-masked]>
Date: Tue, 06 Dec 2022 10:06:24 -0300

Eli Zaretskii <[email-masked]> writes:

> Strange, it shouldn't have happened.  How is CFLAGS set on src/Makefile?  It
> should be something like this:
>
>   CFLAGS = -O2 -g3

git clean -fxd
./autogen.sh
CFLAGS="-O2 -g3" ./configure --without-modules ...

Inside src/Makefile is CFLAGS = -O2 -g3

I also tried ggdb3 with the same result

file src/emacs:
src/emacs: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3cc057b3a7d0f18ff7c819c55a4da8d7ac355846, for GNU/Linux 4.4.0, with debug_info, not stripped

>
> Also, please try printing the value of the full list of the candidate
> libraries:
>
>   (gdb) source .gdbinit
>   (gdb) pp path_candidates
>
> The file .gdbinit is in the src directory of the Emacs source tree, so if
> you start GDB not from that directory, you will need to type the full
> absolute file name of .gdbinit in the "source" command.

Running from src directory:

gdb ./emacs
GNU gdb (GDB) 12.1
Copyright (C) 2022 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 "x86_64-pc-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 ./emacs...
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
WAYLAND_DISPLAY = wayland-0
TERM = foot
Breakpoint 1 at 0x46a18: file emacs.c, line 426.
(gdb) source .gdbinit 
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from terminal]
Redefine command "xgetptr"? (y or n) [answered Y; input not from terminal]
Redefine command "xgetint"? (y or n) [answered Y; input not from terminal]
Redefine command "xgettype"? (y or n) [answered Y; input not from terminal]
Redefine command "xgetsym"? (y or n) [answered Y; input not from terminal]
Redefine command "xsymname"? (y or n) [answered Y; input not from terminal]
Redefine command "pr"? (y or n) [answered Y; input not from terminal]
Redefine command "pp"? (y or n) [answered Y; input not from terminal]
Redefine command "pv"? (y or n) [answered Y; input not from terminal]
Redefine command "xfmt"? (y or n) [answered Y; input not from terminal]
Redefine command "ppt"? (y or n) [answered Y; input not from terminal]
Redefine command "pitmethod"? (y or n) [answered Y; input not from terminal]
Redefine command "pitx"? (y or n) [answered Y; input not from terminal]
Redefine command "pit"? (y or n) [answered Y; input not from terminal]
Redefine command "prowx"? (y or n) [answered Y; input not from terminal]
Redefine command "prow"? (y or n) [answered Y; input not from terminal]
Redefine command "pcursorx"? (y or n) [answered Y; input not from terminal]
Redefine command "pcursor"? (y or n) [answered Y; input not from terminal]
Redefine command "pwinx"? (y or n) [answered Y; input not from terminal]
Redefine command "pwin"? (y or n) [answered Y; input not from terminal]
Redefine command "pbiditype"? (y or n) [answered Y; input not from terminal]
Redefine command "pgx"? (y or n) [answered Y; input not from terminal]
Redefine command "pg"? (y or n) [answered Y; input not from terminal]
Redefine command "pgi"? (y or n) [answered Y; input not from terminal]
Redefine command "pgn"? (y or n) [answered Y; input not from terminal]
--Type <RET> for more, q to quit, c to continue without paging--c
Redefine command "pgrowx"? (y or n) [answered Y; input not from terminal]
Redefine command "pgrow"? (y or n) [answered Y; input not from terminal]
Redefine command "pgrowit"? (y or n) [answered Y; input not from terminal]
Redefine command "prowlims"? (y or n) [answered Y; input not from terminal]
Redefine command "pmtxrows"? (y or n) [answered Y; input not from terminal]
Redefine command "xtype"? (y or n) [answered Y; input not from terminal]
Redefine command "pvectype"? (y or n) [answered Y; input not from terminal]
Redefine command "xvectype"? (y or n) [answered Y; input not from terminal]
Redefine command "pvecsize"? (y or n) [answered Y; input not from terminal]
Redefine command "xvecsize"? (y or n) [answered Y; input not from terminal]
Redefine command "xint"? (y or n) [answered Y; input not from terminal]
Redefine command "xptr"? (y or n) [answered Y; input not from terminal]
Redefine command "xmarker"? (y or n) [answered Y; input not from terminal]
Redefine command "xoverlay"? (y or n) [answered Y; input not from terminal]
Redefine command "xsymwithpos"? (y or n) [answered Y; input not from terminal]
Redefine command "xsymbol"? (y or n) [answered Y; input not from terminal]
Redefine command "xstring"? (y or n) [answered Y; input not from terminal]
Redefine command "xvector"? (y or n) [answered Y; input not from terminal]
Redefine command "xprocess"? (y or n) [answered Y; input not from terminal]
Redefine command "xframe"? (y or n) [answered Y; input not from terminal]
Redefine command "xcompiled"? (y or n) [answered Y; input not from terminal]
Redefine command "xwindow"? (y or n) [answered Y; input not from terminal]
Redefine command "xwinconfig"? (y or n) [answered Y; input not from terminal]
Redefine command "xsubr"? (y or n) [answered Y; input not from terminal]
Redefine command "xchartable"? (y or n) [answered Y; input not from terminal]
Redefine command "xsubchartable"? (y or n) [answered Y; input not from terminal]
Redefine command "xboolvector"? (y or n) [answered Y; input not from terminal]
Redefine command "xbuffer"? (y or n) [answered Y; input not from terminal]
Redefine command "xhashtable"? (y or n) [answered Y; input not from terminal]
Redefine command "xcons"? (y or n) [answered Y; input not from terminal]
Redefine command "nextcons"? (y or n) [answered Y; input not from terminal]
Redefine command "xcar"? (y or n) [answered Y; input not from terminal]
Redefine command "xcdr"? (y or n) [answered Y; input not from terminal]
Redefine command "xlist"? (y or n) [answered Y; input not from terminal]
Redefine command "xfloat"? (y or n) [answered Y; input not from terminal]
Redefine command "xscrollbar"? (y or n) [answered Y; input not from terminal]
Redefine command "xpr"? (y or n) [answered Y; input not from terminal]
Redefine command "xprintstr"? (y or n) [answered Y; input not from terminal]
Redefine command "xprintsym"? (y or n) [answered Y; input not from terminal]
Redefine command "xcoding"? (y or n) [answered Y; input not from terminal]
Redefine command "xcharset"? (y or n) [answered Y; input not from terminal]
Redefine command "xfontset"? (y or n) [answered Y; input not from terminal]
Redefine command "xfont"? (y or n) [answered Y; input not from terminal]
Redefine command "xbacktrace"? (y or n) [answered Y; input not from terminal]
Redefine command "xprintbytestr"? (y or n) [answered Y; input not from terminal]
Redefine command "xwhichsymbols"? (y or n) [answered Y; input not from terminal]
Redefine command "hookpost-backtrace"? (y or n) [answered Y; input not from terminal]
Redefine command "ff"? (y or n) [answered Y; input not from terminal]
DISPLAY = :0
WAYLAND_DISPLAY = wayland-0
TERM = foot
Breakpoint 2 at 0x46a18: file emacs.c, line 426.
(gdb) pp path_candidates
No symbol "path_candidates" in current context.
(gdb) run
Starting program: /home/german/repos/emacs-test/src/emacs 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffee7fe6c0 (LWP 71788)]
[New Thread 0x7fffedffd6c0 (LWP 71789)]
[New Thread 0x7fffed7fc6c0 (LWP 71790)]
[New Thread 0x7fffecffb6c0 (LWP 71791)]
[Detaching after vfork from child process 71792]
[Detaching after vfork from child process 71796]

Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
treesit_load_language (language_symbol=<optimized out>, signal_symbol=0x7fffffffd4e8, signal_data=0x7fffffffd4f0) at treesit.c:565
565	     char *library_name = SSDATA (XCAR (tail));
(gdb) pp path_candidates
[Thread 0x7fffedffd6c0 (LWP 71789) exited]
nil
(gdb) 

-- 
German Pacenza