Message ID | 20230804000329.21405-1-tdevries@suse.de |
---|---|
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C87A3857B8E for <patchwork@sourceware.org>; Fri, 4 Aug 2023 00:04:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C87A3857B8E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691107485; bh=IP4ZRN/0vMGtCvO0duyEGDCR/W2c2JHEDDWgOncMvdk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=X0LEUa1l9LqChocRn10sMI8EXfh+8NBQFarkkgX4l846ADSciDxqtfJgUMFq5p/UH oLi6b0wt8O4EL7/VC+Jw6cVQYf2UE91YFNLV6KA0kvFUtM7F8WfXwscYxwDNK5hZYe A4nmeal1iBJWldMByOYOo3L8JjvHM3Z5YjRgij30= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 991CC3858404 for <gdb-patches@sourceware.org>; Fri, 4 Aug 2023 00:03:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 991CC3858404 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 52CDB1F86A for <gdb-patches@sourceware.org>; Fri, 4 Aug 2023 00:03:45 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3DFBE1339E for <gdb-patches@sourceware.org>; Fri, 4 Aug 2023 00:03:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id O7zqDWFAzGQVLQAAMHmgww (envelope-from <tdevries@suse.de>) for <gdb-patches@sourceware.org>; Fri, 04 Aug 2023 00:03:45 +0000 To: gdb-patches@sourceware.org Subject: [PATCH v3 0/5] [gdb/symtab] Fix data-races in gdb.base/index-cache.exp Date: Fri, 4 Aug 2023 02:03:24 +0200 Message-Id: <20230804000329.21405-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tom de Vries <tdevries@suse.de> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Fix data-races in gdb.base/index-cache.exp
|
|
Message
Tom de Vries
Aug. 4, 2023, 12:03 a.m. UTC
When building gdb with -fsanitize=thread, we run into a data race in gdb.base/index-cache.exp. Fixing this leads us to another, and so on, so each patch addresses one particular data race, with the exception of the last patch, which extends the test-case a bit. The last patch, when applied without the series runs into a segfault with target board native-extended-gdbserver, filed as PR symtab/30712, but that seems to be fixed by a previous commit in this series. This is the reason for which the patch is part of this series. The first two patches implement the approach mentioned in PR30392 comment 2: ... The reader probably should capture the necessarily globals on the main thread and stash them until the index has been written. ... The 3rd patch cannot be fixed with this approach, so it uses the packed<bool, 1> approach: ... - unsigned int queued : 1; + packed<bool, 1> queued; ... There's one more patch like that, I checked using pahole that the struct size is not increased. I spent some time convincing myself that the data races on disjoint bitfields are not benign. I started with reading [1], and got convinced by "2.5 Disjoint bit manipulation" in [2]. Also [3] looked interesting, but haven't read it in full. Tested on x86_64-linux, with and without -fsanitize=thread. PR symtab/30392 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30392 References: [1] https://hacks.mozilla.org/2021/04/eliminating-data-races-in-firefox-a-technical-report/ [2] https://www.usenix.org/legacy/event/hotpar11/tech/final_files/Boehm.pdf [3] https://bartoszmilewski.com/2020/08/11/benign-data-races-considered-harmful/ Tom de Vries (5): [gdb/symtab] Fix data race on index_cache::m_enabled [gdb/symtab] Fix data race on bfd::{cacheable,format} [gdb/symtab] Fix race on dwarf2_per_cu_data::{queued,is_debug_type} [gdb/symtab] Fix data race on dwarf2_per_cu_data::{m_header_read_in,is_debug_type} [gdb/testsuite] Extend gdb.base/index-cache.exp gdb/dwarf2/cooked-index.c | 12 ++++--- gdb/dwarf2/cooked-index.h | 4 ++- gdb/dwarf2/index-cache.c | 48 +++++++++++++++++++------- gdb/dwarf2/index-cache.h | 25 +++++++++++++- gdb/dwarf2/read.h | 26 +++++++------- gdb/testsuite/gdb.base/index-cache-2.c | 24 +++++++++++++ gdb/testsuite/gdb.base/index-cache.c | 6 ++-- gdb/testsuite/gdb.base/index-cache.exp | 22 ++++++++++-- 8 files changed, 132 insertions(+), 35 deletions(-) create mode 100644 gdb/testsuite/gdb.base/index-cache-2.c base-commit: 8d76ceb7f1d2f0d25b76b0a16afd25dc0ba74dca
Comments
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Tested on x86_64-linux, with and without -fsanitize=thread.
Tom> PR symtab/30392
Tom> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30392
Thank you. This looks good to me.
Approved-By: Tom Tromey <tom@tromey.com>
Tom