[Bug translator/34414] New: @choose_defined / trinary-expression over-evaluation
fche at redhat dot com
sourceware-bugzilla@sourceware.org
Mon Jul 20 13:54:51 GMT 2026
https://sourceware.org/bugzilla/show_bug.cgi?id=34414
Bug ID: 34414
Summary: @choose_defined / trinary-expression over-evaluation
Product: systemtap
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: translator
Assignee: systemtap at sourceware dot org
Reporter: fche at redhat dot com
Target Milestone: ---
When elaborating @defined($x) ? $x : $y,
var_expanding_visitor::visit_defined_op resolves the condition and
then calls abort_provide(), which sets aborted_p so the default
update_visitor::visit_ternary_expression skips both arms. The tree
is left as a ternary with a constant condition and still-unexpanded
target symbols in the arms. A later expansion pass walks that ternary
again without short-circuiting and elaborates the unused arm as
well. That makes scripts like @defined($mode) ? $mode : $nosuchvar
fail Pass 2 on $nosuchvar even when @defined($mode) is true (seen on
semok/thirtysix.stp / recent Fedora kernels). The intended semantics
are C-like: only the taken arm should be expanded. A fix is to teach
var_expanding_visitor to short-circuit ternaries whose condition
is already a literal—expand only the taken arm and provide that
expression directly. Note also that on current kernels $mode is not
@defined at every do_sys_open PC (often optimized out while $flags
remains), so tests that assume uniform $mode availability need a
stabler local even after the translator fix.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Systemtap
mailing list