[PATCH 12/17] dwflpp: guard traversal of the global alias cache
Aaron Merey
amerey@redhat.com
Mon Nov 23 04:14:26 GMT 2026
declaration_resolve_other_cus walks global_alias_cache while another
worker publishes a CU's type map. Hold cache_mutex during the scan
and use the entry returned by find().
WARNING: ThreadSanitizer: data race
Write of size 8 at 0xffff8f0003a8 by thread T2 (mutexes: write M0):
#3 dwflpp::global_alias_caching_callback_cus ... dwflpp.cxx:1239
Previous read of size 8 at 0xffff8f0003a8 by thread T1:
#0 dwflpp::declaration_resolve_other_cus
Assisted-by: Codex <noreply@openai.com>
---
dwflpp.cxx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dwflpp.cxx b/dwflpp.cxx
index 42d087df2..fe3b527f2 100644
--- a/dwflpp.cxx
+++ b/dwflpp.cxx
@@ -1252,12 +1252,14 @@ Dwarf_Die *
dwflpp::declaration_resolve_other_cus(const string& name)
{
iterate_over_cus(global_alias_caching_callback_cus, this, true);
+ std::lock_guard<std::mutex> lock (cache_mutex);
for (auto i = global_alias_cache.begin();
i != global_alias_cache.end(); ++i)
{
cu_type_cache_t *v = (*i).second;
- if (v->find(name) != v->end())
- return & ((*v)[name]);
+ auto it = v->find (name);
+ if (it != v->end ())
+ return &it->second;
}
return NULL;
--
2.56.1
More information about the Systemtap
mailing list