From a4f4bbc3530f68e615ac5614224bdcb7c21d68dc Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 15 Jul 2022 18:08:50 +0200 Subject: [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. --- gdb/gdbtypes.h | 8 ++++++-- 1 file 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 -- cgit v1.1