diff options
author | Tom Tromey <tom@tromey.com> | 2019-03-04 15:12:04 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-11-26 14:02:57 -0700 |
commit | 3b3978bca2a204a772563c8e121e4a02be72e802 (patch) | |
tree | 70076c2fc0433920de0b7a71ae12b34311a5fdfa /gdb/event-top.h | |
parent | 9411c49ecc09df989ecddb05e1756e0a9da0d1c8 (diff) | |
download | gdb-3b3978bca2a204a772563c8e121e4a02be72e802.zip gdb-3b3978bca2a204a772563c8e121e4a02be72e802.tar.gz gdb-3b3978bca2a204a772563c8e121e4a02be72e802.tar.bz2 |
Introduce thread-safe way to handle SIGSEGV
The gdb demangler installs a SIGSEGV handler in order to protect gdb
from demangler bugs. However, this is not thread-safe, as signal
handlers are global to the process.
This patch changes gdb to always install a global SIGSEGV handler, and
then lets threads indicate their interest in handling the signal by
setting a thread-local variable.
This patch then arranges for the demangler code to use this; being
sure to arrange for calls to warning and the like to be done on the
main thread.
One thing I wondered while writing this patch is if there are any
systems that do not have "sigaction". If gdb could assume this, it
would simplify this code.
gdb/ChangeLog
2019-11-26 Tom Tromey <tom@tromey.com>
* event-top.h (thread_local_segv_handler): Declare.
* event-top.c (thread_local_segv_handler): New global.
(install_handle_sigsegv, handle_sigsegv): New functions.
(async_init_signals): Install SIGSEGV handler.
* cp-support.c (gdb_demangle_jmp_buf): Change type. Now
thread-local.
(report_failed_demangle): New function.
(gdb_demangle): Make core_dump_allowed atomic. Remove signal
handler-setting code, instead use segv_handler. Run warning code
on main thread.
Change-Id: Ic832bbb033b64744e4b44f14b41db7e4168ce427
Diffstat (limited to 'gdb/event-top.h')
-rw-r--r-- | gdb/event-top.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gdb/event-top.h b/gdb/event-top.h index 1dc7b13..e844125 100644 --- a/gdb/event-top.h +++ b/gdb/event-top.h @@ -70,4 +70,10 @@ extern void gdb_rl_callback_handler_install (const char *prompt); currently installed. */ extern void gdb_rl_callback_handler_reinstall (void); +/* The SIGSEGV handler for this thread, or NULL if there is none. GDB + always installs a global SIGSEGV handler, and then lets threads + indicate their interest in handling the signal by setting this + thread-local variable. */ +extern thread_local void (*thread_local_segv_handler) (int); + #endif |