aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2025-07-03 16:19:09 +0300
committerEli Zaretskii2025-07-03 16:19:09 +0300
commit205d69e7e64cf23df0bc7a52b1149f6130c117b5 (patch)
treec36510881f35bdefb5559e7c2d21daab9c0780d9 /src
parentf48c283e885bbc5feee0804bc12f1cb633249316 (diff)
downloademacs-205d69e7e64cf23df0bc7a52b1149f6130c117b5.tar.gz
emacs-205d69e7e64cf23df0bc7a52b1149f6130c117b5.zip
Avoid segfaults due to C-g when a thread does GC
* src/keyboard.c (handle_interrupt): Don't forcibly switch threads if a non-main thread was in GC when the signal handler was called.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 8b2ebd215d2..fcb66f4c58a 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -12394,7 +12394,15 @@ handle_interrupt (bool in_signal_handler)
12394 thread, see deliver_process_signal. So we must make sure the 12394 thread, see deliver_process_signal. So we must make sure the
12395 main thread holds the global lock. */ 12395 main thread holds the global lock. */
12396 if (in_signal_handler) 12396 if (in_signal_handler)
12397 maybe_reacquire_global_lock (); 12397 {
12398 /* But if the signal handler was called when a non-main thread was
12399 in GC, just return, since switching threads by force-taking the
12400 global lock will confuse the heck out of GC, and will most
12401 likely segfault. */
12402 if (!main_thread_p (current_thread) && gc_in_progress)
12403 return;
12404 maybe_reacquire_global_lock ();
12405 }
12398#endif 12406#endif
12399 if (waiting_for_input && !echoing) 12407 if (waiting_for_input && !echoing)
12400 quit_throw_to_read_char (in_signal_handler); 12408 quit_throw_to_read_char (in_signal_handler);