From: Serhei Makarov Date: Mon, 14 Dec 2020 17:39:51 +0000 (-0500) Subject: stapbpf (for PR27030): bugfix error messages in bpf assembly X-Git-Tag: release-4.5~123 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=b71d20af;p=systemtap.git stapbpf (for PR27030): bugfix error messages in bpf assembly 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. --- diff --git a/bpf-translate.cxx b/bpf-translate.cxx index f61a088a0..b463cc818 100644 --- a/bpf-translate.cxx +++ b/bpf-translate.cxx @@ -173,6 +173,7 @@ struct bpf_unparser : public throwing_visitor // Used to track errors. value *error_status; + std::vector asm_stmts; // Used to switch execution of program to catch blocks. std::vector catch_jump; @@ -1477,7 +1478,9 @@ bpf_unparser::visit_embeddedcode (embeddedcode *s) #ifdef DEBUG_CODEGEN this_ins.notes.push("asm"); #endif - std::vector statements; + // XXX retain asm_stmts to avoid deallocating tok on throw + std::vector &statements = this->asm_stmts; + statements.clear(); asm_stmt stmt; // PR24528: The /* userspace */ annotation is used to mark