From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 53C853857030; Wed, 26 Jul 2023 16:23:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53C853857030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690388636; bh=Ce4KjpGMGrMga6TtpZIVAW6B8tBWpVgGJZlGeI0hLqc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JK7UO/bJpMPiEN4t2PlZZE0R8XtpQI4GF4hYSlQx/PlLJwf3JXZw0NW7pl1vKqgoc nBkvOtH0wqJxCaG2RKEjUbGyRcUDt6+58VkogD1kp8cabr/KLefhKANFxgz8Gijds0 R9Nj9mKJ6DaQyQonYuL1hmZOkGnl5U4xzRIfTi5k= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug dap/30680] [gdb/dap] ThreadSanitizer: data race gdbsupport/event-pipe.h:44 in event_pipe::is_open() const Date: Wed, 26 Jul 2023 16:23:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: dap X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30680 --- Comment #6 from Tom de Vries --- (In reply to Tom Tromey from comment #4) > > #2 sigchld_handler /data/vries/gdb/src/gdb/linux-nat.c:4238 (gdb+0x= 92f381) >=20 > This is odd because all the DAP-related threads should be started > with SIGCHLD blocked. I've written an assert to try to catch this situation without tsan: ... diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 250a8f43282..d6d0ba0f415 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -69,6 +69,7 @@ #include "gdbsupport/scope-exit.h" #include "gdbsupport/gdb-sigmask.h" #include "gdbsupport/common-debug.h" +#include "run-on-main-thread.h" #include /* This comment documents high-level logic of this file. @@ -4227,6 +4228,7 @@ linux_nat_target::supports_disable_randomization () static void sigchld_handler (int signo) { + gdb_assert (is_main_thread ()); int old_errno =3D errno; if (debug_linux_nat) diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c index c7d9de0afc8..f9388e33633 100644 --- a/gdb/run-on-main-thread.c +++ b/gdb/run-on-main-thread.c @@ -94,12 +94,27 @@ run_on_main_thread (std::function &&func) serial_event_set (runnable_event); } +#if CXX_STD_THREAD +static void +initialize_main_thread_var (void) +{ + static bool initialized =3D false; + + if (initialized) + return; + initialized =3D true; + + main_thread =3D std::this_thread::get_id (); +} +#endif + /* See run-on-main-thread.h. */ bool is_main_thread () { #if CXX_STD_THREAD + initialize_main_thread_var (); return std::this_thread::get_id () =3D=3D main_thread; #else-- return true; @@ -111,7 +126,7 @@ void _initialize_run_on_main_thread () { #if CXX_STD_THREAD - main_thread =3D std::this_thread::get_id (); + initialize_main_thread_var (); #endif runnable_event =3D make_serial_event (); add_file_handler (serial_event_fd (runnable_event), run_events, nullptr, ... and it does trigger. --=20 You are receiving this mail because: You are on the CC list for the bug.=