[PATCH 05/17] tapsets: snapshot ELF-only function matches under the module lock

Aaron Merey amerey@redhat.com
Mon Nov 23 04:14:19 GMT 2026


query_module_symtab tests whether a function's DIE is empty while
update_symtab copies a DIE into the same func_info. Collect ELF-only
matches under symtab_mutex, then release it before invoking
callbacks.

  WARNING: ThreadSanitizer: data race
    Write of size 8 at 0xffff81412c18 by thread T20 (mutexes: write M0):
      #0 __tsan_memcpy
      #1 module_info::update_symtab ... tapsets.cxx:11155
    Previous read of size 8 at 0xffff81412c18 by thread T17:
      #0 bcmp
      #1 dwarf_query::query_module_symtab() ... tapsets.cxx:616

Assisted-by: Codex <noreply@openai.com>
---
 tapsets.cxx | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tapsets.cxx b/tapsets.cxx
index fe8ff17e8..e7f39b85a 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1589,11 +1589,13 @@ dwarf_query::query_module_symtab()
 {
   // Get the symbol table if we don't already have it
   module_info *mi = focus.mod_info;
+  unique_lock<recursive_mutex> lock (mi->symtab_mutex);
   if (mi->symtab_status == info_unknown)
     mi->get_symtab();
   if (mi->symtab_status == info_absent)
     return;
 
+  vector<func_info> matches;
   func_info *fi = NULL;
   symbol_table *sym_table = mi->sym_table;
 
@@ -1610,7 +1612,7 @@ dwarf_query::query_module_symtab()
                   || fi->descriptor) // ppc opd (and also undefined symbols)
                 continue;
               if (dw.function_name_matches_pattern(fi->name, function_str_val))
-                query_symtab_func_info(*fi, this);
+                matches.push_back (*fi);
             }
         }
       else
@@ -1620,10 +1622,14 @@ dwarf_query::query_module_symtab()
             {
               fi = *it;
               if (fi && null_die(&fi->die))
-                query_symtab_func_info(*fi, this);
+                matches.push_back (*fi);
             }
         }
     }
+
+  lock.unlock ();
+  for (auto &match : matches)
+    query_symtab_func_info (match, this);
 }
 
 void
-- 
2.56.1



More information about the Systemtap mailing list