[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.
This commit is contained in:
Tom de Vries
2022-07-15 18:08:50 +02:00
parent 2f8fd1da0e
commit a4f4bbc353

View File

@@ -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