[gdb/symtab] Make per_cu->m_lang atomic
authorTom de Vries <tdevries@suse.de>
Thu, 14 Jul 2022 06:19:00 +0000 (08:19 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 14 Jul 2022 06:19:00 +0000 (08:19 +0200)
commit14dd1080c6127e7ad7566598860a885aa244ff8d
tree778335a294f58877774d8c79af14605cab7763d2
parentb35bd7d552f80518ad90e81f592b73ee2ef736d7
[gdb/symtab] Make per_cu->m_lang atomic

When building gdb with -fsanitize=thread and running test-case
gdb.dwarf2/inlined_subroutine-inheritance.exp, we run into a data race
between:
...
  Read of size 1 at 0x7b2000003010 by thread T4:
    #0 packed<language, 1ul>::operator language() const packed.h:54
    #1 dwarf2_per_cu_data::set_lang(language) read.h:363
...
and:
...
  Previous write of size 1 at 0x7b2000003010 by main thread:
    #0 dwarf2_per_cu_data::set_lang(language) read.h:365
...

Fix this by making per_cu->m_lang atomic.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29286
gdb/dwarf2/read.h