From 227a1dc3271997a6f9c1451dd335d84a78fc338e Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Fri, 12 Jul 2024 18:41:00 -0400 Subject: [PATCH] libdw: Make libdw_find_split_unit thread-safe * (__libdw_find_split_unit): Add lock for cu->split. Signed-off-by: Heather S. McIntyre Signed-off-by: Aaron Merey Signed-off-by: Mark Wielaard v2 changes: Locking applied to __libdw_find_split_unit instead of try_split_file. --- libdw/libdw_find_split_unit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libdw/libdw_find_split_unit.c b/libdw/libdw_find_split_unit.c index 67d31a9c..eb3d88d7 100644 --- a/libdw/libdw_find_split_unit.c +++ b/libdw/libdw_find_split_unit.c @@ -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; } -- 2.47.2