]> sourceware.org Git - systemtap.git/commitdiff
stapbpf (for PR27030): bugfix error messages in bpf assembly
authorSerhei Makarov <smakarov@redhat.com>
Mon, 14 Dec 2020 17:39:51 +0000 (12:39 -0500)
committerSerhei Makarov <smakarov@redhat.com>
Mon, 14 Dec 2020 17:43:28 +0000 (12:43 -0500)
Need to retain the asm_stmts vector so that bpf assembly tokens
are not deallocated on exception throw.

Otherwise, printing semantic errors from bpf assembly causes segfault.

* bpf-translate.cxx (struct bpf_unparser): retain asm_stmts vector.
(bpf_unparser::visit_embeddedcode): reuse retained asm_stmts vector.

bpf-translate.cxx

index f61a088a0f0de4c2669fcec0f9bad793f6277cfd..b463cc818e1d6b8fb4ca9c651943231e1e066199 100644 (file)
@@ -173,6 +173,7 @@ struct bpf_unparser : public throwing_visitor
 
   // Used to track errors.
   value *error_status;
+  std::vector<asm_stmt> asm_stmts;
 
   // Used to switch execution of program to catch blocks.
   std::vector<block *> catch_jump;
@@ -1477,7 +1478,9 @@ bpf_unparser::visit_embeddedcode (embeddedcode *s)
 #ifdef DEBUG_CODEGEN
   this_ins.notes.push("asm");
 #endif
-  std::vector<asm_stmt> statements;
+  // XXX retain asm_stmts to avoid deallocating tok on throw
+  std::vector<asm_stmt> &statements = this->asm_stmts;
+  statements.clear();
   asm_stmt stmt;
 
   // PR24528: The /* userspace */ annotation is used to mark
This page took 0.031078 seconds and 5 git commands to generate.