diff options
author | Tom de Vries <tdevries@suse.de> | 2022-07-15 18:08:50 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-07-21 15:06:40 +0200 |
commit | a4f4bbc3530f68e615ac5614224bdcb7c21d68dc (patch) | |
tree | 2eb2df17cde09b297e96c5743ed10deec5dc4807 | |
parent | 2f8fd1da0e52f99138ed489016c774121a33e942 (diff) | |
download | gdb-a4f4bbc3530f68e615ac5614224bdcb7c21d68dc.zip gdb-a4f4bbc3530f68e615ac5614224bdcb7c21d68dc.tar.gz gdb-a4f4bbc3530f68e615ac5614224bdcb7c21d68dc.tar.bz2 |
[gdb] Fix data race in bitfield
Data race between:
...
Write of size 4 at 0x7b8009b483f0 by thread T2:
#0 set_type_align(type*, unsigned long) /home/vries/gdb_versions/devel/src/gdb/gdbtypes.c:3751 (gdb+0x961e08)
...
and:
...
Previous read of size 1 at 0x7b8009b483f1 by thread T4:
#0 type::instance_flags() const /home/vries/gdb_versions/devel/src/gdb/gdbtypes.h:1092 (gdb+0x59e74b)
...
corresponding to:
...
unsigned align_log2 : TYPE_ALIGN_BITS;
unsigned m_instance_flags : 9;
...
Fix this by wrapping them using "struct { ... };".
For now, don't worry about size increase, we might have to address this later
using packed.
Still, is this a correct fix? Maybe the problem is modifying a type from
different thread. If so, having this patch for now may expose that problem.
-rw-r--r-- | gdb/gdbtypes.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 3a4d644..751f21b 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1488,7 +1488,9 @@ struct type value of 1 means the alignment is 1, and a value of 9 means the alignment is 256. */ - unsigned align_log2 : TYPE_ALIGN_BITS; + struct { + unsigned align_log2 : TYPE_ALIGN_BITS; + }; /* * Flags specific to this instance of the type, indicating where on the ring we are. @@ -1500,7 +1502,9 @@ struct type instance flags are completely inherited from the target type. No qualifiers can be cleared by the typedef. See also check_typedef. */ - unsigned m_instance_flags : 9; + struct { + unsigned m_instance_flags : 9; + }; /* * Length of storage for a value of this type. The value is the expression in host bytes of what sizeof(type) would return. This |