[PATCH 08/17] rpm: publish the configuration result once
Aaron Merey
amerey@redhat.com
Mon Nov 23 04:14:22 GMT 2026
A worker sets init_tried before rpmReadConfigFiles finishes. A second
worker can treat initialization as failed and skip the lookup.
Initialize the shared result once and wait for it before using it.
WARNING: ThreadSanitizer: data race
Read of size 1 at 0x0000009b350c by thread T17:
#0 missing_rpm_enlist ... rpm_finder.cxx:67
Previous write of size 1 at 0x0000009b350c by thread T19:
#0 missing_rpm_enlist ... rpm_finder.cxx:69
Assisted-by: Codex <noreply@openai.com>
---
rpm_finder.cxx | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/rpm_finder.cxx b/rpm_finder.cxx
index 44826735b..ea516ca06 100644
--- a/rpm_finder.cxx
+++ b/rpm_finder.cxx
@@ -51,7 +51,6 @@ extern "C" {
static int
missing_rpm_enlist (systemtap_session& sess, const char *filename, const char *rpm_type)
{
- static int rpm_init_done = 0;
rpmts ts;
rpmdbMatchIterator mi;
int count = 0;
@@ -59,23 +58,18 @@ missing_rpm_enlist (systemtap_session& sess, const char *filename, const char *r
if (filename == NULL)
return 0;
- if (!rpm_init_done)
+ static const bool rpm_init_done = []
{
- static int init_tried;
-
- /* Already failed the initialization before? */
- if (init_tried)
- return 0;
- init_tried = 1;
-
if (rpmReadConfigFiles(NULL, NULL) != 0)
{
cerr << _("Error reading the rpm configuration files") << endl;
- return 0;
+ return false;
}
- rpm_init_done = 1;
- }
+ return true;
+ }();
+ if (!rpm_init_done)
+ return 0;
/* If we've seen this combo before, don't check again... */
if (!sess.rpms_checked.insert(string(filename) + rpm_type).second)
--
2.56.1
More information about the Systemtap
mailing list