aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-02-23 08:59:40 -0700
committerTom Tromey <tromey@adacore.com>2024-02-28 09:08:16 -0700
commit8bb8f8346729c35433c961f7f1ed3a801776a362 (patch)
tree16018f54edb869c5d52ac3ad4486355d71758e50 /gdb/python
parent4b72a278f46245635ca03ffc8179570c07e3531a (diff)
downloadgdb-8bb8f8346729c35433c961f7f1ed3a801776a362.zip
gdb-8bb8f8346729c35433c961f7f1ed3a801776a362.tar.gz
gdb-8bb8f8346729c35433c961f7f1ed3a801776a362.tar.bz2
Fix gdb.interrupt race
gdb.interrupt was introduced to implement DAP request cancellation. However, because it can be run from another thread, and because I didn't look deeply enough at the implementation, it turns out to be racy. The fix here is to lock accesses to certain globals in extension.c. Note that this won't work in the case where configure detects that the C++ compiler doesn't provide thread support. This version of the patch disables DAP entirely in this situation. Regression tested on x86-64 Fedora 38. I also ran gdb.dap/pause.exp in a thread-sanitizer build tree to make sure the reported race is gone. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31263
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-dap.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/python/py-dap.c b/gdb/python/py-dap.c
index 2034105..9a00130 100644
--- a/gdb/python/py-dap.c
+++ b/gdb/python/py-dap.c
@@ -92,10 +92,14 @@ call_dap_fn (const char *fn_name)
void
dap_interp::init (bool top_level)
{
+#if CXX_STD_THREAD
call_dap_fn ("run");
current_ui->input_fd = -1;
current_ui->m_input_interactive_p = false;
+#else
+ error (_("GDB was compiled without threading, which DAP requires"));
+#endif
}
void