diff options
author | Tom de Vries <tdevries@suse.de> | 2022-07-15 19:10:42 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-07-21 15:06:40 +0200 |
commit | 333d407393541c078d7c539f3c3907728c5556f7 (patch) | |
tree | c4bb12aa6a2bc61c926ab1df8cb6929879659d3c | |
parent | 4f005db8e084bc9825145f048b3b48b35673b2fb (diff) | |
download | gdb-333d407393541c078d7c539f3c3907728c5556f7.zip gdb-333d407393541c078d7c539f3c3907728c5556f7.tar.gz gdb-333d407393541c078d7c539f3c3907728c5556f7.tar.bz2 |
[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.
-rw-r--r-- | gdb/dwarf2/read.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 66f3ca0..d0452ab 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -21098,6 +21098,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, if (suppress_add) { +#if CXX_STD_THREAD + static std::mutex template_symbols_lock; + std::lock_guard<std::mutex> guard (template_symbols_lock); +#endif sym->hash_next = objfile->template_symbols; objfile->template_symbols = sym; list_to_add = NULL; |