aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-06-30 13:31:06 +0200
committerTom de Vries <tdevries@suse.de>2022-06-30 13:31:06 +0200
commit6418644b0d09af7d1334cc034a7bf8674c061d6e (patch)
treed7c2a3ddee3491d63835669c54918031848906ac /gdbsupport
parent68514a919ec9a4b04b3b56730e9b070580a0e221 (diff)
downloadgdb-6418644b0d09af7d1334cc034a7bf8674c061d6e.zip
gdb-6418644b0d09af7d1334cc034a7bf8674c061d6e.tar.gz
gdb-6418644b0d09af7d1334cc034a7bf8674c061d6e.tar.bz2
[gdb] Block SIGTERM in worker threads
With gdb build with gcc-12 and -fsanitize=thread, and test-case gdb.base/gdb-sigterm.exp, I run into: ... WARNING: ThreadSanitizer: data race (pid=9722)^M Write of size 4 at 0x00000325bc68 by thread T1:^M #0 handle_sigterm(int) src/gdb/event-top.c:1211 (gdb+0x8ec01f)^M ... Previous read of size 4 at 0x00000325bc68 by main thread:^M [failed to restore the stack]^M ^M Location is global 'sync_quit_force_run' of size 4 at \ 0x00000325bc68 (gdb+0x325bc68)^M ... SUMMARY: ThreadSanitizer: data race gdb/event-top.c:1211 in \ handle_sigterm(int)^M ... and 3 more data races involving handle_sigterm and locations: - active_ext_lang - quit_flag - heap block of size 40 (XNEW (async_signal_handler) in create_async_signal_handler) This was reported in PR29297. The testcase executes a "kill -TERM $gdb_pid", which generates a process-directed signal. A process-directed signal can be delivered to any thread, and what we see here is the fallout of the signal being delivered to a worker thread rather than the main thread. Fix this by blocking SIGTERM in the worker threads. [ I have not been able to reproduce this after it occurred for the first time, so unfortunately I cannot confirm that the patch fixes the problem. ] Tested on x86_64-linux, with and without -fsanitize=thread. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29297
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/block-signals.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/gdbsupport/block-signals.h b/gdbsupport/block-signals.h
index cf97208..4703690 100644
--- a/gdbsupport/block-signals.h
+++ b/gdbsupport/block-signals.h
@@ -42,6 +42,7 @@ public:
sigaddset (&mask, SIGCHLD);
sigaddset (&mask, SIGALRM);
sigaddset (&mask, SIGWINCH);
+ sigaddset (&mask, SIGTERM);
gdb_sigmask (SIG_BLOCK, &mask, &m_old_mask);
#endif
}