Introduce thread-safe way to handle SIGSEGV
authorTom Tromey <tom@tromey.com>
Mon, 4 Mar 2019 22:12:04 +0000 (15:12 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 26 Nov 2019 21:02:57 +0000 (14:02 -0700)
commit3b3978bca2a204a772563c8e121e4a02be72e802
tree70076c2fc0433920de0b7a71ae12b34311a5fdfa
parent9411c49ecc09df989ecddb05e1756e0a9da0d1c8
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
gdb/ChangeLog
gdb/cp-support.c
gdb/event-top.c
gdb/event-top.h
This page took 0.024378 seconds and 4 git commands to generate.