aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-07-15 18:54:04 +0200
committerTom de Vries <tdevries@suse.de>2022-07-21 15:06:40 +0200
commitb4303a08c2569e64c193656eae9e097170eb756a (patch)
tree64357d7b0128d6293ab975c637565757801c5c66
parentc2ae16cc58b64e21a6b993544943fb9612e904a2 (diff)
downloadgdb-b4303a08c2569e64c193656eae9e097170eb756a.zip
gdb-b4303a08c2569e64c193656eae9e097170eb756a.tar.gz
gdb-b4303a08c2569e64c193656eae9e097170eb756a.tar.bz2
[gdb] Fix data race in cleanup_undefined_stabs_types
Data race for: ... Read of size 4 at 0x00000324db04 by thread T1: #0 cleanup_undefined_types_1 /home/vries/gdb_versions/devel/src/gdb/stabsread.c:4437 (gdb+0xe60bdd) #1 cleanup_undefined_stabs_types(objfile*) /home/vries/gdb_versions/devel/src/gdb/stabsread.c:4500 (gdb+0xe60c48) #2 buildsym_compunit::end_compunit_symtab_get_static_block(unsigned long, int, int) /home/vries/gdb_versions/devel/src/gdb/buildsym.c:837 (gdb+0x63dbba) #3 process_full_comp_unit /home/vries/gdb_versions/devel/src/gdb/dwarf2/read.c:8404 (gdb+0x8395f4) #4 process_queue_item /home/vries/gdb_versions/devel/src/gdb/dwarf2/read.c:7592 (gdb+0x8359f5) ... and location: ... Location is global 'undef_types_length' of size 4 at 0x00000324db04 ... Likewise for: ... WARNING: ThreadSanitizer: data race (pid=12737) Read of size 4 at 0x00000324db1c by thread T4: #0 cleanup_undefined_types_noname /home/vries/gdb_versions/devel/src/gdb/stabsread.c:4383 (gdb+0xe608b2) #1 cleanup_undefined_stabs_types(objfile*) /home/vries/gdb_versions/devel/src/gdb/stabsread.c:4501 (gdb+0xe60c54) #2 buildsym_compunit::end_compunit_symtab_get_static_block(unsigned long, int, int) /home/vries/gdb_versions/devel/src/gdb/buildsym.c:837 (gdb+0x63dbba) #3 process_full_comp_unit /home/vries/gdb_versions/devel/src/gdb/dwarf2/read.c:8404 (gdb+0x8395f4) #4 process_queue_item /home/vries/gdb_versions/devel/src/gdb/dwarf2/read.c:7592 (gdb+0x8359f5) ... and location: ... Location is global 'noname_undefs_length' of size 4 at 0x00000324db1c ... Fix this by adding a lock in cleanup_undefined_stabs_types.
-rw-r--r--gdb/stabsread.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 98ea59d..79e8aa1 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -4497,6 +4497,11 @@ cleanup_undefined_types_1 (void)
void
cleanup_undefined_stabs_types (struct objfile *objfile)
{
+#if CXX_STD_THREAD
+ static std::mutex cleanup_undefined_stabs_types_lock;
+ std::lock_guard<std::mutex> guard (cleanup_undefined_stabs_types_lock);
+#endif
+
cleanup_undefined_types_1 ();
cleanup_undefined_types_noname (objfile);
}