[PATCH 03/17] loc2stap: make the generated-local counter atomic
Aaron Merey
amerey@redhat.com
Mon Nov 23 04:14:17 GMT 2026
Parallel DWARF translations increment the same counter in new_local
without synchronization. Reserve each generated name with an atomic
increment.
WARNING: ThreadSanitizer: data race
Write of size 4 at 0x000000c23174 by thread T19:
#0 location_context::new_local ... loc2stap.cxx:257
Previous write of size 4 at 0x000000c23174 by thread T17:
#0 location_context::new_local ... loc2stap.cxx:257
Assisted-by: Codex <noreply@openai.com>
---
loc2stap.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/loc2stap.cxx b/loc2stap.cxx
index 2a2bcc270..087fb0d79 100644
--- a/loc2stap.cxx
+++ b/loc2stap.cxx
@@ -252,7 +252,7 @@ location_context::new_symref(vardecl *var)
symbol *
location_context::new_local(const char *namebase)
{
- static int counter;
+ static std::atomic<unsigned> counter {0};
vardecl *var = new vardecl;
var->unmangled_name = var->name = std::string(namebase) + lex_cast(counter++);
var->type = pe_long;
--
2.56.1
More information about the Systemtap
mailing list