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

From: German Pacenza <[email-masked]>
Date: Mon, 05 Dec 2022 11:31:53 -0300

Eli Zaretskii <[email-masked]> writes:

> Please run Emacs under GDB and when it crashes, type
>
>   (gdb) thread apply all bt
>
> and post here everything this produces.
>
>> Building with -g3 -O0 emacs shows a warning buffer instead of crashing.
>
> Please show the text in the warning buffer.
>
> It is very hard to investigate this problem without the data I described
> above.  Please try providing it.
>
> Thanks.

The message in debug build is:

⛔ Warning (treesit): Cannot activate tree-sitter, because language definition for c is unavailable (symbol-error): src/emacs: undefined symbol: tree_sitter_c

Backtrace of the release build:
(gdb) thread apply all bt

Thread 5 (Thread 0x7fffdd3fb6c0 (LWP 1794) "dconf worker"):
#0  0x00007fffeef140bf in poll () at /usr/lib/libc.so.6
#1  0x00007ffff70e81ff in  () at /usr/lib/libglib-2.0.so.0
#2  0x00007ffff7090132 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#3  0x00007fffdf592fde in  () at /usr/lib/gio/modules/libdconfsettings.so
#4  0x00007ffff70bee05 in  () at /usr/lib/libglib-2.0.so.0
#5  0x00007fffeee9f8fd in  () at /usr/lib/libc.so.6
#6  0x00007fffeef21a60 in  () at /usr/lib/libc.so.6

Thread 4 (Thread 0x7fffddbfc6c0 (LWP 1793) "gdbus"):
#0  0x00007fffeef140bf in poll () at /usr/lib/libc.so.6
#1  0x00007ffff70e81ff in  () at /usr/lib/libglib-2.0.so.0
#2  0x00007ffff7090ddf in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#3  0x00007ffff72e637c in  () at /usr/lib/libgio-2.0.so.0
#4  0x00007ffff70bee05 in  () at /usr/lib/libglib-2.0.so.0
#5  0x00007fffeee9f8fd in  () at /usr/lib/libc.so.6
#6  0x00007fffeef21a60 in  () at /usr/lib/libc.so.6

Thread 2 (Thread 0x7fffdebfe6c0 (LWP 1791) "gmain"):
#0  0x00007fffeef140bf in poll () at /usr/lib/libc.so.6
#1  0x00007ffff70e81ff in  () at /usr/lib/libglib-2.0.so.0
#2  0x00007ffff7090132 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#3  0x00007ffff7090182 in  () at /usr/lib/libglib-2.0.so.0
#4  0x00007ffff70bee05 in  () at /usr/lib/libglib-2.0.so.0
#5  0x00007fffeee9f8fd in  () at /usr/lib/libc.so.6
#6  0x00007fffeef21a60 in  () at /usr/lib/libc.so.6

Thread 1 (Thread 0x7fffea480940 (LWP 1788) "emacs"):
#0  treesit_load_language (language_symbol=<optimized out>, signal_symbol=0x7fffffffd348, signal_data=0x7fffffffd350) at treesit.c:565
#1  0x00005555557e7e74 in Ftreesit_langauge_available_p (language=0x3d80, detail=0x30) at treesit.c:628
#2  0x0000555555759756 in Ffuncall (nargs=3, args=0x7fffffffd3f0) at eval.c:2995
#3  0x00007fffcfbe3219 in F747265657369742d72656164792d70_treesit_ready_p_0 () at /home/german/.emacs.d/eln-cache/30.0.50-f7873392/treesit-37439c61-1dbc135d.eln
#4  0x000055555579e890 in exec_byte_code (fun=<optimized out>, args_template=<optimized out>, nargs=<optimized out>, args=<optimized out>) at bytecode.c:809
#5  0x0000555555759756 in Ffuncall (nargs=nargs@entry=1, args=args@entry=0x7fffffffd6e8) at eval.c:2995
#6  0x000055555575562e in Ffuncall_interactively (nargs=1, args=0x7fffffffd6e8) at callint.c:248
#7  0x0000555555759756 in Ffuncall (nargs=2, args=0x7fffffffd6e0) at eval.c:2995
#8  0x0000555555759b28 in Fapply (nargs=nargs@entry=3, args=args@entry=0x7fffffffd6e0) at eval.c:2619
#9  0x0000555555756ec2 in Fcall_interactively (function=0x2aaa8a451450, record_flag=0xd5f0, keys=0x555556efaf25) at callint.c:340
#10 0x00007fffe10b73e5 in F636f6d6d616e642d65786563757465_command_execute_0 () at /home/german/.local/emacs/bin/../lib/emacs/30.0.50/native-lisp/30.0.50-f7873392/preloaded/simple-fab5b0cf-fe41d9a7.eln
#11 0x0000555555759756 in Ffuncall (nargs=3, args=0x7fffffffd8d0) at eval.c:2995
#12 0x00007fffe10b60c9 in F657865637574652d657874656e6465642d636f6d6d616e64_execute_extended_command_0 () at /home/german/.local/emacs/bin/../lib/emacs/30.0.50/native-lisp/30.0.50-f7873392/preloaded/simple-fab5b0cf-fe41d9a7.eln
#13 0x0000555555759756 in Ffuncall (nargs=nargs@entry=4, args=args@entry=0x7fffffffda18) at eval.c:2995
--Type <RET> for more, q to quit, c to continue without paging--c
#14 0x000055555575562e in Ffuncall_interactively (nargs=4, args=0x7fffffffda18) at callint.c:248
#15 0x0000555555759756 in Ffuncall (nargs=5, args=0x7fffffffda10) at eval.c:2995
#16 0x0000555555759970 in Fapply (nargs=nargs@entry=3, args=args@entry=0x7fffffffdb80) at eval.c:2666
#17 0x0000555555756ec2 in Fcall_interactively (function=0x2aaa89fc8af8, record_flag=0x0, keys=0x7fffe0627a1d) at callint.c:340
#18 0x00007fffe10b73e5 in F636f6d6d616e642d65786563757465_command_execute_0 () at /home/german/.local/emacs/bin/../lib/emacs/30.0.50/native-lisp/30.0.50-f7873392/preloaded/simple-fab5b0cf-fe41d9a7.eln
#19 0x0000555555759756 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffffffdd30) at eval.c:2995
#20 0x00005555556dc549 in call1 (arg1=<optimized out>, fn=0x49b0) at /home/german/repos/emacs/src/lisp.h:3247
#21 command_loop_1 () at keyboard.c:1495
#22 0x0000555555757e37 in internal_condition_case (bfun=bfun@entry=0x5555556dc150 <command_loop_1>, handlers=handlers@entry=0x90, hfun=hfun@entry=0x5555556cf1a0 <cmd_error>) at eval.c:1474
#23 0x00005555556c7c66 in command_loop_2 (handlers=handlers@entry=0x90) at keyboard.c:1125
#24 0x0000555555757d91 in internal_catch (tag=tag@entry=0xfa50, func=func@entry=0x5555556c7c40 <command_loop_2>, arg=arg@entry=0x90) at eval.c:1197
#25 0x00005555556c7c01 in command_loop () at keyboard.c:1103
#26 0x00005555556ced22 in recursive_edit_1 () at keyboard.c:712
#27 0x00005555556cf0b0 in Frecursive_edit () at keyboard.c:795
#28 0x00005555555e0a66 in main (argc=<optimized out>, argv=0x7fffffffe1f8) at emacs.c:2523

-- 
German Pacenza