]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Make libdw_find_split_unit thread-safe
authorAaron Merey <amerey@redhat.com>
Fri, 12 Jul 2024 22:41:00 +0000 (18:41 -0400)
committerAaron Merey <amerey@redhat.com>
Tue, 16 Jul 2024 20:22:36 +0000 (16:22 -0400)
* (__libdw_find_split_unit): Add lock for cu->split.

Signed-off-by: Heather S. McIntyre <hsm2@rice.edu>
Signed-off-by: Aaron Merey <amerey@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
v2 changes:
Locking applied to __libdw_find_split_unit instead of try_split_file.

libdw/libdw_find_split_unit.c

index 67d31a9c428805a50ec1ef78a8e427fc1360368c..eb3d88d7032bb6234fa6f906406d24d199db01ba 100644 (file)
@@ -150,9 +150,14 @@ Dwarf_CU *
 internal_function
 __libdw_find_split_unit (Dwarf_CU *cu)
 {
+  rwlock_wrlock(cu->split_lock);
+
   /* Only try once.  */
   if (cu->split != (Dwarf_CU *) -1)
-    return cu->split;
+    {
+      rwlock_unlock(cu->split_lock);
+      return cu->split;
+    }
 
   /* We need a skeleton unit with a comp_dir and [GNU_]dwo_name attributes.
      The split unit will be the first in the dwo file and should have the
@@ -207,5 +212,6 @@ __libdw_find_split_unit (Dwarf_CU *cu)
   if (cu->split == (Dwarf_CU *) -1)
     cu->split = NULL;
 
+  rwlock_unlock(cu->split_lock);
   return cu->split;
 }