[PATCH 13/17] loc2stap: make the parameter-reference catch counter atomic
Aaron Merey
amerey@redhat.com
Mon Nov 23 04:14:27 GMT 2026
Parallel DW_OP_GNU_parameter_ref translations can reuse a catch
variable name. Reserve its numeric suffix with an atomic increment.
WARNING: ThreadSanitizer: data race
Write of size 4 at 0x0000009b2f6c by thread T70:
#0 location_context::handle_GNU_parameter_ref ... loc2stap.cxx:1947
Previous write of size 4 at 0x0000009b2f6c by thread T69:
#0 location_context::handle_GNU_parameter_ref ... loc2stap.cxx:1947
With four workers, stap -p2 emitted 64 catch clauses with only 56
distinct names. The fixed translator emitted 64 distinct names.
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 087fb0d79..7678d82d6 100644
--- a/loc2stap.cxx
+++ b/loc2stap.cxx
@@ -1943,7 +1943,7 @@ location_context::handle_GNU_parameter_ref (Dwarf_Op expr)
// Generate an error
vardecl *var = new vardecl;
- static int counter = 0;
+ static std::atomic<unsigned> counter {0};
var->name = std::string("_e_") + lex_cast(counter++);
var->type = pe_string;
var->arity = 0;
--
2.56.1
More information about the Systemtap
mailing list