From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 87EB23858404; Tue, 16 Apr 2024 22:53:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87EB23858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713308029; bh=HooxLCsmTRjCP5L52yj1HjU4qBJ+E7F8N2Z1gYCx1Ac=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CY986zCT7+fe/yzsV/+ctWl93pWYjIVmMZFekntm+c/vP1AxuW0a3Y2YG//OI4UH3 KQI5H9LbWqk+GoQ22unmznYWkrqH+MNDNUVJipR0v9mUNPrwDZnCwTvkDL92ujx610 RsrdnWY7HeTzkLPMPTL/aaIBIiv/mWpAvx5xjuzo= From: "cvs-commit at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/31264] [gdb] ThreadSanitizer: data race format.c:132 in bfd_preserve_save Date: Tue, 16 Apr 2024 22:53:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: tromey at sourceware dot org X-Bugzilla-Target-Milestone: 15.1 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=3D31264 --- Comment #12 from Sourceware Commits --- The master branch has been updated by Tom Tromey : https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dbacc61fd3e6f= d61a59fb59bcc657be17a381520d commit bacc61fd3e6fd61a59fb59bcc657be17a381520d Author: Tom Tromey Date: Mon Feb 12 18:06:56 2024 -0700 Thread-safety improvements for bfd_check_format_matches A gdb bug found that bfd_check_format_matches has some data races when called from multiple threads. In particular, it changes the BFD error handler, which is a global. It also has a local static variable ("in_check_format") that is used for recursion detection. And, finally, it may emit warnings to the per-xvec warning array, which is a global. This patch removes all the races here. The first part of patch is to change _bfd_error_handler to directly handle the needs of bfd_check_format_matches. This way, the error handler does not need to be changed. This change lets us use the new per-thread global (error_handler_messages, replacing error_handler_bfd) to also remove the need for in_check_format -- a single variable suffices. Finally, the global per-xvec array is replaced with a new type that holds the error messages. The outermost such type is stack-allocated in bfd_check_format_matches. I tested this using the binutils test suite. I also built gdb with thread sanitizer and ran the test case that was noted as failing. Finally, Alan sent me the test file that caused the addition of the xvec warning code in the first place, and I confirmed that "nm-new" has the same behavior on this file both before and after this patch. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31264 Co-Authored-By: Alan Modra --=20 You are receiving this mail because: You are on the CC list for the bug.=