From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 4/5] [gdb/symtab] Work around fsanitize=address false positive for per_cu->unit_type
Date: Wed, 29 Jun 2022 17:29:13 +0200 [thread overview]
Message-ID: <20220629152914.13149-4-tdevries@suse.de> (raw)
In-Reply-To: <20220629152914.13149-1-tdevries@suse.de>
When building gdb with -fsanitize=thread and gcc 12, and running test-case
gdb.dwarf2/dwz.exp, we run into a data race between:
...
Write of size 1 at 0x7b200000300e by thread T4:
#0 process_psymtab_comp_unit gdb/dwarf2/read.c:6789 (gdb+0x830720)
...
and:
...
Previous read of size 1 at 0x7b200000300e by main thread:
#0 cutu_reader::cutu_reader(dwarf2_per_cu_data*, dwarf2_per_objfile*, \
abbrev_table*, dwarf2_cu*, bool, abbrev_cache*) gdb/dwarf2/read.c:6164 \
(gdb+0x82edab)
...
In other words, between:
...
this_cu->unit_type = DW_UT_partial;
...
and:
...
if (this_cu->reading_dwo_directly)
...
Both fields are part of the same bitfield, and writing to one field while
reading from another is not a problem, so this is a false positive.
Fix this by moving the unit_type field out of the bitfield.
Use type unsigned char instead of enum dwarf_unit_type to keep requiring only
8 bits.
The size of struct dwarf2_per_cu_data remains the same (at least for -m64).
Tested on x86_64-linux.
---
gdb/dwarf2/read.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index db300b19621..abce4f83f39 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -100,6 +100,7 @@ struct dwarf2_per_cu_data
{
dwarf2_per_cu_data ()
: lang (language_unknown),
+ unit_type {},
queued (false),
is_debug_types (false),
is_dwz (false),
@@ -109,7 +110,6 @@ struct dwarf2_per_cu_data
addresses_seen (false),
mark (false),
files_read (false),
- unit_type {},
scanned (false)
{
}
@@ -128,6 +128,10 @@ struct dwarf2_per_cu_data
/* The language of this CU. */
language lang;
+ /* The unit type of this CU. We'd like to use dwarf_unit_type but that
+ requires 'int' storage. */
+ unsigned char unit_type;
+
/* Flag indicating this compilation unit will be read in before
any of the current compilation units are processed. */
unsigned int queued : 1;
@@ -174,9 +178,6 @@ struct dwarf2_per_cu_data
point in trying to read it again next time. */
bool files_read : 1;
- /* The unit type of this CU. */
- ENUM_BITFIELD (dwarf_unit_type) unit_type : 8;
-
/* True if this CU has been scanned by the indexer; false if
not. */
std::atomic<bool> scanned;
--
2.35.3
next prev parent reply other threads:[~2022-06-29 15:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-29 15:29 [PATCH 1/5] [COVER-LETTER, RFC] Fix some fsanitize=thread issues in gdb's cooked index Tom de Vries
2022-06-29 15:29 ` [PATCH 2/5] [gdb/symtab] Fix data race on per_cu->dwarf_version Tom de Vries
2022-07-01 11:16 ` Tom de Vries
2022-07-02 11:07 ` Tom de Vries
2022-07-04 18:51 ` Tom Tromey
2022-07-04 19:43 ` Tom de Vries
2022-07-04 19:53 ` Tom Tromey
2022-06-29 15:29 ` [PATCH 3/5] [gdb/symtab] Work around fsanitize=address false positive for per_cu->lang Tom de Vries
2022-06-29 17:38 ` Pedro Alves
2022-06-29 18:25 ` Pedro Alves
2022-06-29 18:28 ` Pedro Alves
2022-07-04 7:04 ` [PATCH 3/5] [gdb/symtab] Work around fsanitize=address false positive for per_ cu->lang Tom de Vries
2022-07-04 18:32 ` [PATCH 3/5] [gdb/symtab] Work around fsanitize=address false positive for per_cu->lang Tom Tromey
2022-07-04 19:45 ` Tom de Vries
2022-07-06 19:20 ` [PATCH] Introduce struct packed template, fix -fsanitize=thread for per_cu fields Pedro Alves
2022-07-07 10:18 ` Tom de Vries
2022-07-07 15:26 ` Pedro Alves
2022-07-08 14:54 ` Tom de Vries
2022-07-12 10:22 ` Tom de Vries
2022-06-29 15:29 ` Tom de Vries [this message]
2022-06-29 15:29 ` [PATCH 5/5] [gdb/symtab] Fix data race on per_cu->lang Tom de Vries
2022-07-04 18:30 ` Tom Tromey
2022-07-05 8:17 ` Tom de Vries
2022-07-05 15:19 ` Tom de Vries
2022-07-06 15:42 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220629152914.13149-4-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).