bugfix(runner): Profile coupon_call like function_call (fix from_trace panic). - #10081
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
…e panic).
ProfilingInfoProcessor::from_trace detected calls by matching only
CoreConcreteLibfunc::FunctionCall, but CouponCall routes through the same
function_call::build and emits `call rel 0`. The coupon call's Sierra
`return` then popped a stack frame the profiler never pushed, underflowing
the function stack and tripping `unreachable!("End of program reached, but
trace continues.")`. Match CouponCall alongside FunctionCall. Adds a
profiling golden regression test exercising a coupon call.
4c88c34 to
5d1e29d
Compare
PR SummaryLow Risk Overview A regression test exercises Reviewed by Cursor Bugbot for commit 5d1e29d. Bugbot is set up for automated code reviews on this repo. Configure here. |
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).

Summary
Fixes the profiler to correctly handle
coupon_calllibfunc invocations by treating them the same asFunctionCallwhen building stack traces. Previously, onlyCoreConcreteLibfunc::FunctionCallwas matched when determining whether to push a frame onto the profiling stack, causingcoupon_callinvocations to be silently ignored and producing incorrect stack traces.Type of change
Please check one:
Why is this change needed?
When a function is called via a coupon (
coupon_call), the profiler was not recognizing it as a function call boundary. This meant the callee's frames were not attributed to the correct stack trace depth, producing misleading profiling output.What was the behavior or documentation before?
coupon_callinvocations were not pushed onto the profiling function stack, so calls made via coupons did not appear as a nested stack frame in the profiling output (e.g.,test::main -> test::add_with_couponwould be missing).What is the behavior or documentation after?
coupon_callis now matched alongsideFunctionCallwhen deciding whether to push a new frame onto the profiling stack. Stack traces correctly reflect coupon-based calls, as validated by the new regression test case.Related issue or discussion (if any)
Regression fix — the test is explicitly labeled as a regression test for this behavior.
Additional context
A new test case (
Test profiling info with a coupon call) has been added to the profiling test data to prevent regressions. The test verifies thatcoupon_call<user@test::add_with_coupon>is properly framed and that the stack tracetest::main -> test::add_with_couponappears in the profiling output.