Subject: Re: bug#71073: Emacs segfaults if corfu is asked to autocomplete something while the LSP server providing completions is still starting/indexing

From: Eli Zaretskii <[email-masked]>
Date: Tue, 21 May 2024 21:47:44 +0300

[You are again replying only to me.  Please use Reply All.]

> Date: Tue, 21 May 2024 18:26:54 +0000
> From: alexis purslane <[email-masked]>
> 
> Wait wait! No need, I got it to happen. As it turns out, the timing is a bit narrower
> than I thought. Attached is the full backtrace for all threads as requested. 
> 
> 
> 
> On Tuesday, May 21st, 2024 at 6:21 PM, Eli Zaretskii <[email-masked]> wrote:
> 
> > [Please use Reply All to reply, so as to keep the bug tracker CC'ed.]
> > 
> 
> > > Date: Tue, 21 May 2024 16:32:13 +0000
> > > From: alexis purslane [email-masked]
> > > 
> 
> > > Okay, I tried to reproduce this in gdb, but it wouldn't do it? I was using
> > > the exact same configuration file, LSP server executable, test file, everything.
> > > The only differences were I had to run it with sudo because of the security
> > > settings of my OS, so I made it use the same config and everything by
> > > manually setting $HOME, and that when run with GDB for some reason Emacs
> > > ran under XWayland instead of Wayland. Maybe it's the latter that makes the
> > > difference?
> > 
> 
> > 
> 
> > I don't know. But we must have more detailed and more accurate
> > backtrace to make any progress here.
> > 
> 
> > Can someone please reproduce these crashes under GDB and post a
> > complete backtrace?
> 
> 
> Thread 10 (Thread 0x7fffd2b8f6c0 (LWP 57508) "dconf worker"):
> #0  0x00000000005811a0 in deliver_input_available_signal ()
> #1  0x00007fffee9af750 in <signal handler called> () at /lib64/libc.so.6
> #2  0x00007fffeea797ed in poll () at /lib64/libc.so.6
> #3  0x00007ffff710b724 in g_main_context_iterate_unlocked.isra () at /lib64/libglib-2.0.so.0
> #4  0x00007ffff70abb03 in g_main_context_iteration () at /lib64/libglib-2.0.so.0
> #5  0x00007fffd867d705 in dconf_gdbus_worker_thread () at /usr/lib64/gio/modules/libdconfsettings.so

This does not seem to be a segfault, this is SIGIO that gets delivered
to one of the Glib threads.  While the main thread seems to just be
going about its business:

> Thread 1 (Thread 0x7fffe8df3280 (LWP 56994) "emacs-29.3"):
> #0  0x0000000000625768 in plist_get ()
> #1  0x0000000000579f81 in parse_modifiers ()
> #2  0x0000000000590ad8 in access_keymap_1.lto_priv ()
> #3  0x000000000057f7ea in read_char ()
> #4  0x0000000000648f3a in read_filtered_event.lto_priv ()
> #5  0x00007fffe7bd92ff in F7369742d666f72_sit_for_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/subr-13adf6a6-bfb9f448.eln

Nothing here that is not normal, I think.  Did GDB say "thread 1 got
SIGSEGV"?

Po Lu, do you see anything problematic?

And why does GDB kick in when we get SIGIO?

But if this _is_ a segfault, then what could cause it?  The plist_get
call seems to be from Fget:

  Lisp_Object propval = plist_get (CDR (Fassq (symbol,
					       Voverriding_plist_environment)),
				   propname);

in which case the problem is with overriding-plist-environment or
something?  Or maybe it's the second call to plist_get:

  return plist_get (XSYMBOL (symbol)->u.s.plist, propname);

Here's the full backtrace, for those who didn't get the original
message (everyone but me):

  Thread 10 (Thread 0x7fffd2b8f6c0 (LWP 57508) "dconf worker"):
  #0  0x00000000005811a0 in deliver_input_available_signal ()
  #1  0x00007fffee9af750 in <signal handler called> () at /lib64/libc.so.6
  #2  0x00007fffeea797ed in poll () at /lib64/libc.so.6
  #3  0x00007ffff710b724 in g_main_context_iterate_unlocked.isra () at /lib64/libglib-2.0.so.0
  #4  0x00007ffff70abb03 in g_main_context_iteration () at /lib64/libglib-2.0.so.0
  #5  0x00007fffd867d705 in dconf_gdbus_worker_thread () at /usr/lib64/gio/modules/libdconfsettings.so
  #6  0x00007ffff70da8a3 in g_thread_proxy () at /lib64/libglib-2.0.so.0
  #7  0x00007fffeea051f7 in start_thread () at /lib64/libc.so.6
  #8  0x00007fffeea8742c in clone3 () at /lib64/libc.so.6

  Thread 9 (Thread 0x7fffd358f6c0 (LWP 57507) "gmain"):
  #0  0x00007fffeea797ed in poll () at /lib64/libc.so.6
  #1  0x00007ffff710b724 in g_main_context_iterate_unlocked.isra () at /lib64/libglib-2.0.so.0
  #2  0x00007ffff70abb03 in g_main_context_iteration () at /lib64/libglib-2.0.so.0
  #3  0x00007ffff70abb59 in glib_worker_main () at /lib64/libglib-2.0.so.0
  #4  0x00007ffff70da8a3 in g_thread_proxy () at /lib64/libglib-2.0.so.0
  #5  0x00007fffeea051f7 in start_thread () at /lib64/libc.so.6
  #6  0x00007fffeea8742c in clone3 () at /lib64/libc.so.6

  Thread 8 (Thread 0x7fffd3f8f6c0 (LWP 57506) "pool-spawner"):
  #0  0x00000000005811a0 in deliver_input_available_signal ()
  #1  0x00007fffee9af750 in <signal handler called> () at /lib64/libc.so.6
  #2  0x00007fffeea8521d in syscall () at /lib64/libc.so.6
  #3  0x00007ffff710883d in g_cond_wait () at /lib64/libglib-2.0.so.0
  #4  0x00007ffff707558b in g_async_queue_pop_intern_unlocked () at /lib64/libglib-2.0.so.0
  #5  0x00007ffff70dba93 in g_thread_pool_spawn_thread () at /lib64/libglib-2.0.so.0
  #6  0x00007ffff70da8a3 in g_thread_proxy () at /lib64/libglib-2.0.so.0
  #7  0x00007fffeea051f7 in start_thread () at /lib64/libc.so.6
  #8  0x00007fffeea8742c in clone3 () at /lib64/libc.so.6

  Thread 7 (Thread 0x7fffd918f6c0 (LWP 57505) "emacs-29.3"):
  #0  0x00007fffeea8521d in syscall () at /lib64/libc.so.6
  #1  0x00007ffff710883d in g_cond_wait () at /lib64/libglib-2.0.so.0
  #2  0x00007ffff707558b in g_async_queue_pop_intern_unlocked () at /lib64/libglib-2.0.so.0
  #3  0x00007ffff70755ec in g_async_queue_pop () at /lib64/libglib-2.0.so.0
  #4  0x00007fffee9600a9 in fc_thread_func () at /lib64/libpangoft2-1.0.so.0
  #5  0x00007ffff70da8a3 in g_thread_proxy () at /lib64/libglib-2.0.so.0
  #6  0x00007fffeea051f7 in start_thread () at /lib64/libc.so.6
  #7  0x00007fffeea8742c in clone3 () at /lib64/libc.so.6

  Thread 1 (Thread 0x7fffe8df3280 (LWP 56994) "emacs-29.3"):
  #0  0x0000000000625768 in plist_get ()
  #1  0x0000000000579f81 in parse_modifiers ()
  #2  0x0000000000590ad8 in access_keymap_1.lto_priv ()
  #3  0x000000000057f7ea in read_char ()
  #4  0x0000000000648f3a in read_filtered_event.lto_priv ()
  #5  0x00007fffe7bd92ff in F7369742d666f72_sit_for_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/subr-13adf6a6-bfb9f448.eln
  #6  0x000000000062148d in Ffuncall ()
  #7  0x00007fffd139a2c4 in F6a736f6e7270632d72657175657374_jsonrpc_request_0 () at /usr/lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/jsonrpc-e62a9c36-62ae7160.eln
  #8  0x000000000062148d in Ffuncall ()
  #9  0x0000000000621b90 in Fapply ()
  #10 0x000000000066b8bc in exec_byte_code ()
  #11 0x000000000062148d in Ffuncall ()
  #12 0x00000000005b6122 in Fall_completions ()
  #13 0x00007fffe7b7ba67 in F636f6d706c6574696f6e2d70636d2d2d616c6c2d636f6d706c6574696f6e73_completion_pcm__all_completions_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #14 0x000000000062148d in Ffuncall ()
  #15 0x00007fffe7b7ef86 in F636f6d706c6574696f6e2d737562737472696e672d2d616c6c2d636f6d706c6574696f6e73_completion_substring__all_completions_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #16 0x000000000062148d in Ffuncall ()
  #17 0x00007fffe7b7fa16 in F636f6d706c6574696f6e2d666c65782d616c6c2d636f6d706c6574696f6e73_completion_flex_all_completions_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #18 0x000000000062148d in Ffuncall ()
  #19 0x0000000000621b90 in Fapply ()
  #20 0x000000000066b8bc in exec_byte_code ()
  #21 0x000000000062148d in Ffuncall ()
  #22 0x00007fffe7b68852 in F636f6d706c6574696f6e2d2d736f6d65_completion__some_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #23 0x000000000062148d in Ffuncall ()
  #24 0x00007fffe7b6d914 in F636f6d706c6574696f6e2d2d6e74682d636f6d706c6574696f6e_completion__nth_completion_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #25 0x000000000062148d in Ffuncall ()
  #26 0x00007fffe7b6dcd0 in F636f6d706c6574696f6e2d616c6c2d636f6d706c6574696f6e73_completion_all_completions_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #27 0x000000000062148d in Ffuncall ()
  #28 0x0000000000621b90 in Fapply ()
  #29 0x000000000066b8bc in exec_byte_code ()
  #30 0x000000000062148d in Ffuncall ()
  #31 0x0000000000621b90 in Fapply ()
  #32 0x00007fffd1515be9 in F636f7266752d2d66696c7465722d636f6d706c6574696f6e73_corfu__filter_completions_0 () at /var/home/alexispurslane/.emacs.d/eln-cache/29.3-f9fbfec9/corfu-4ecf6dfc-d30fc894.eln
  #33 0x000000000062148d in Ffuncall ()
  #34 0x00007fffd1516b9e in F636f7266752d2d7265636f6d70757465_corfu__recompute_0 () at /var/home/alexispurslane/.emacs.d/eln-cache/29.3-f9fbfec9/corfu-4ecf6dfc-d30fc894.eln
  #35 0x000000000062148d in Ffuncall ()
  #36 0x00007fffd1517e25 in F636f7266752d2d757064617465_corfu__update_0 () at /var/home/alexispurslane/.emacs.d/eln-cache/29.3-f9fbfec9/corfu-4ecf6dfc-d30fc894.eln
  #37 0x000000000066b8bc in exec_byte_code ()
  #38 0x000000000062148d in Ffuncall ()
  #39 0x0000000000621e82 in Fapply ()
  #40 0x000000000066b8bc in exec_byte_code ()
  #41 0x000000000062148d in Ffuncall ()
  #42 0x0000000000621e82 in Fapply ()
  #43 0x000000000066b8bc in exec_byte_code ()
  #44 0x000000000062148d in Ffuncall ()
  #45 0x00007fffd151b4c7 in F636f7266752d2d6175746f2d636f6d706c6574652d6465666572726564_corfu__auto_complete_deferred_0 () at /var/home/alexispurslane/.emacs.d/eln-cache/29.3-f9fbfec9/corfu-4ecf6dfc-d30fc894.eln
  #46 0x000000000062148d in Ffuncall ()
  #47 0x0000000000621e82 in Fapply ()
  #48 0x000000000062148d in Ffuncall ()
  #49 0x00007fffe7813f60 in F74696d65722d6576656e742d68616e646c6572_timer_event_handler_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/timer-3ee7cfd9-226b3dc9.eln
  #50 0x000000000062148d in Ffuncall ()
  #51 0x0000000000577d55 in timer_check ()
  #52 0x00000000005782fd in readable_events.lto_priv ()
  #53 0x0000000000582a80 in get_input_pending.lto_priv ()
  #54 0x000000000068591f in wait_reading_process_output ()
  #55 0x000000000057c62c in kbd_buffer_get_event ()
  #56 0x000000000057e886 in read_char ()
  #57 0x0000000000587743 in read_key_sequence.lto_priv ()
  #58 0x0000000000573f75 in command_loop_1.lto_priv ()
  #59 0x000000000060fa9e in internal_condition_case ()
  #60 0x00000000005734d6 in command_loop_2 ()
  #61 0x000000000060f9f7 in internal_catch ()
  #62 0x0000000000573933 in command_loop ()
  #63 0x0000000000573a2f in recursive_edit_1 ()
  #64 0x0000000000573c1d in Frecursive_edit ()
  #65 0x0000000000479569 in main ()
  #0  0x0000000000625768 in plist_get ()
  #1  0x0000000000579f81 in parse_modifiers ()
  #2  0x0000000000590ad8 in access_keymap_1.lto_priv ()
  #3  0x000000000057f7ea in read_char ()
  #4  0x0000000000648f3a in read_filtered_event.lto_priv ()
  #5  0x00007fffe7bd92ff in F7369742d666f72_sit_for_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/subr-13adf6a6-bfb9f448.eln
  #6  0x000000000062148d in Ffuncall ()
  #7  0x00007fffd139a2c4 in F6a736f6e7270632d72657175657374_jsonrpc_request_0 () at /usr/lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/jsonrpc-e62a9c36-62ae7160.eln
  #8  0x000000000062148d in Ffuncall ()
  #9  0x0000000000621b90 in Fapply ()
  #10 0x000000000066b8bc in exec_byte_code ()
  #11 0x000000000062148d in Ffuncall ()
  #12 0x00000000005b6122 in Fall_completions ()
  #13 0x00007fffe7b7ba67 in F636f6d706c6574696f6e2d70636d2d2d616c6c2d636f6d706c6574696f6e73_completion_pcm__all_completions_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #14 0x000000000062148d in Ffuncall ()
  #15 0x00007fffe7b7ef86 in F636f6d706c6574696f6e2d737562737472696e672d2d616c6c2d636f6d706c6574696f6e73_completion_substring__all_completions_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #16 0x000000000062148d in Ffuncall ()
  #17 0x00007fffe7b7fa16 in F636f6d706c6574696f6e2d666c65782d616c6c2d636f6d706c6574696f6e73_completion_flex_all_completions_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #18 0x000000000062148d in Ffuncall ()
  #19 0x0000000000621b90 in Fapply ()
  #20 0x000000000066b8bc in exec_byte_code ()
  #21 0x000000000062148d in Ffuncall ()
  #22 0x00007fffe7b68852 in F636f6d706c6574696f6e2d2d736f6d65_completion__some_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #23 0x000000000062148d in Ffuncall ()
  #24 0x00007fffe7b6d914 in F636f6d706c6574696f6e2d2d6e74682d636f6d706c6574696f6e_completion__nth_completion_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #25 0x000000000062148d in Ffuncall ()
  #26 0x00007fffe7b6dcd0 in F636f6d706c6574696f6e2d616c6c2d636f6d706c6574696f6e73_completion_all_completions_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/minibuffer-1b0f548b-25462d74.eln
  #27 0x000000000062148d in Ffuncall ()
  #28 0x0000000000621b90 in Fapply ()
  #29 0x000000000066b8bc in exec_byte_code ()
  #30 0x000000000062148d in Ffuncall ()
  #31 0x0000000000621b90 in Fapply ()
  #32 0x00007fffd1515be9 in F636f7266752d2d66696c7465722d636f6d706c6574696f6e73_corfu__filter_completions_0 () at /var/home/alexispurslane/.emacs.d/eln-cache/29.3-f9fbfec9/corfu-4ecf6dfc-d30fc894.eln
  #33 0x000000000062148d in Ffuncall ()
  #34 0x00007fffd1516b9e in F636f7266752d2d7265636f6d70757465_corfu__recompute_0 () at /var/home/alexispurslane/.emacs.d/eln-cache/29.3-f9fbfec9/corfu-4ecf6dfc-d30fc894.eln
  #35 0x000000000062148d in Ffuncall ()
  #36 0x00007fffd1517e25 in F636f7266752d2d757064617465_corfu__update_0 () at /var/home/alexispurslane/.emacs.d/eln-cache/29.3-f9fbfec9/corfu-4ecf6dfc-d30fc894.eln
  #37 0x000000000066b8bc in exec_byte_code ()
  #38 0x000000000062148d in Ffuncall ()
  #39 0x0000000000621e82 in Fapply ()
  #40 0x000000000066b8bc in exec_byte_code ()
  #41 0x000000000062148d in Ffuncall ()
  #42 0x0000000000621e82 in Fapply ()
  #43 0x000000000066b8bc in exec_byte_code ()
  #44 0x000000000062148d in Ffuncall ()
  #45 0x00007fffd151b4c7 in F636f7266752d2d6175746f2d636f6d706c6574652d6465666572726564_corfu__auto_complete_deferred_0 () at /var/home/alexispurslane/.emacs.d/eln-cache/29.3-f9fbfec9/corfu-4ecf6dfc-d30fc894.eln
  #46 0x000000000062148d in Ffuncall ()
  #47 0x0000000000621e82 in Fapply ()
  #48 0x000000000062148d in Ffuncall ()
  #49 0x00007fffe7813f60 in F74696d65722d6576656e742d68616e646c6572_timer_event_handler_0 () at /usr/bin/../lib64/emacs/29.3/native-lisp/29.3-f9fbfec9/preloaded/timer-3ee7cfd9-226b3dc9.eln
  #50 0x000000000062148d in Ffuncall ()
  #51 0x0000000000577d55 in timer_check ()
  #52 0x00000000005782fd in readable_events.lto_priv ()
  #53 0x0000000000582a80 in get_input_pending.lto_priv ()
  #54 0x000000000068591f in wait_reading_process_output ()
  #55 0x000000000057c62c in kbd_buffer_get_event ()
  #56 0x000000000057e886 in read_char ()
  #57 0x0000000000587743 in read_key_sequence.lto_priv ()
  #58 0x0000000000573f75 in command_loop_1.lto_priv ()
  #59 0x000000000060fa9e in internal_condition_case ()
  #60 0x00000000005734d6 in command_loop_2 ()
  #61 0x000000000060f9f7 in internal_catch ()
  #62 0x0000000000573933 in command_loop ()
  #63 0x0000000000573a2f in recursive_edit_1 ()
  #64 0x0000000000573c1d in Frecursive_edit ()
  #65 0x0000000000479569 in main ()