[PATCH 16/17] tapsets: synchronize SDT mark suggestions with module scans
Aaron Merey
amerey@redhat.com
Mon Nov 23 04:14:30 GMT 2026
suggest_marks searches the module cache while query_module inserts
into it. Hold session_data_mutex for the lookup and while copying
mark names. Use the same lock when adding mark names, and release it
before ranking suggestions.
WARNING: ThreadSanitizer: data race
Read of size 8 at 0xffff888269a8 by thread T20 (mutexes: write M0):
#7 std::map<...>::find ... stl_map.h:1440
#8 suggest_marks ... tapsets.cxx:9842
Previous write of size 8 at 0xffff888269a8 by thread T18
(mutexes: write M1):
#2 std::map<...>::operator[] ... stl_map.h:559
#3 query_module ... tapsets.cxx:3377
Assisted-by: Codex <noreply@openai.com>
---
tapsets.cxx | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tapsets.cxx b/tapsets.cxx
index ff2fd7253..9b88a4dff 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -9570,7 +9570,10 @@ sdt_query::setup_note_probe_entry (const string& scn_name,
probe_name = name;
arg_string = args;
- focus.mod_info->marks.insert(make_pair(provider, name));
+ {
+ lock_guard<recursive_mutex> g (sess.session_data_mutex);
+ focus.mod_info->marks.insert(make_pair(provider, name));
+ }
// Did we find a matching probe?
if (! (dw.function_name_matches_pattern (probe_name, pp_mark)
@@ -9668,7 +9671,10 @@ sdt_query::iterate_over_probe_entries()
clog << _("saw .probes ") << probe_name << (provider_name != "" ? _(" (provider ")+provider_name+") " : "")
<< "@0x" << lex_cast_hex(pc, false) << endl;
- focus.mod_info->marks.insert(make_pair(provider_name, probe_name));
+ {
+ lock_guard<recursive_mutex> g (sess.session_data_mutex);
+ focus.mod_info->marks.insert(make_pair(provider_name, probe_name));
+ }
if (dw.function_name_matches_pattern (probe_name, pp_mark)
&& ((pp_provider == "") || dw.function_name_matches_pattern (provider_name, pp_provider)))
@@ -9822,6 +9828,7 @@ suggest_marks(systemtap_session& sess,
const string& mark,
const string& provider)
{
+ unique_lock<recursive_mutex> guard (sess.session_data_mutex);
if (mark.empty() || modules.empty() || sess.module_cache == NULL || sess.suppress_costly_diagnostics)
return "";
@@ -9867,6 +9874,7 @@ suggest_marks(systemtap_session& sess,
}
}
+ guard.unlock ();
if (sess.verbose > 2)
{
clog << "suggesting " << marks.size() << " marks "
--
2.56.1
More information about the Systemtap
mailing list