]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/symtab] Fix data race on objfile->template_symbols
authorTom de Vries <tdevries@suse.de>
Fri, 15 Jul 2022 17:10:42 +0000 (19:10 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 21 Jul 2022 13:06:40 +0000 (15:06 +0200)
commit333d407393541c078d7c539f3c3907728c5556f7
treec4bb12aa6a2bc61c926ab1df8cb6929879659d3c
parent4f005db8e084bc9825145f048b3b48b35673b2fb
[gdb/symtab] Fix data race on objfile->template_symbols

Data race between:
...
  Read of size 8 at 0x7b4000006dd8 by thread T4:
    #0 new_symbol gdb/dwarf2/read.c:21085 (gdb+0x868212)
    #1 handle_struct_member_die gdb/dwarf2/read.c:14828 (gdb+0x851be8)
    #2 process_structure_scope gdb/dwarf2/read.c:14865 (gdb+0x851e70)
    #3 process_die gdb/dwarf2/read.c:8649 (gdb+0x83a048)
    #4 read_namespace gdb/dwarf2/read.c:16026 (gdb+0x857a32)
    #5 process_die gdb/dwarf2/read.c:8689 (gdb+0x83a100)
    #6 read_file_scope gdb/dwarf2/read.c:9616 (gdb+0x83cb81)
    #7 process_die gdb/dwarf2/read.c:8620 (gdb+0x839f43)
    #8 process_full_comp_unit gdb/dwarf2/read.c:8383 (gdb+0x839509)
    #9 process_queue_item gdb/dwarf2/read.c:7592 (gdb+0x8359f5)
...
and:
...
  Previous write of size 8 at 0x7b4000006dd8 by main thread:
    #0 new_symbol gdb/dwarf2/read.c:21086 (gdb+0x868247)
    #1 handle_struct_member_die gdb/dwarf2/read.c:14828 (gdb+0x851be8)
    #2 process_structure_scope gdb/dwarf2/read.c:14865 (gdb+0x851e70)
    #3 process_die gdb/dwarf2/read.c:8649 (gdb+0x83a048)
    #4 read_namespace gdb/dwarf2/read.c:16026 (gdb+0x857a32)
    #5 process_die gdb/dwarf2/read.c:8689 (gdb+0x83a100)
    #6 read_file_scope gdb/dwarf2/read.c:9616 (gdb+0x83cb81)
    #7 process_die gdb/dwarf2/read.c:8620 (gdb+0x839f43)
    #8 process_full_comp_unit gdb/dwarf2/read.c:8383 (gdb+0x839509)
    #9 process_queue_item gdb/dwarf2/read.c:7592 (gdb+0x8359f5)
...

Fix this by adding a lock in new_symbol for adding to
objfile->template_symbols.
gdb/dwarf2/read.c