Sitelet https://github.com/starkware-libs/cairo/pull/10081
Skip to content

bugfix(runner): Profile coupon_call like function_call (fix from_trace panic). - #10081

Merged
orizi merged 1 commit into
mainfrom
orizi/06-11-bugfix_runner_profile_coupon_call_like_function_call_fix_from_trace_panic_
Jun 11, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/06-11-bugfix_runner_profile_coupon_call_like_function_call_fix_from_trace_panic_

Conversation

@orizi

@orizi orizi commented Jun 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes the profiler to correctly handle coupon_call libfunc invocations by treating them the same as FunctionCall when building stack traces. Previously, only CoreConcreteLibfunc::FunctionCall was matched when determining whether to push a frame onto the profiling stack, causing coupon_call invocations to be silently ignored and producing incorrect stack traces.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

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_call invocations 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_coupon would be missing).


What is the behavior or documentation after?

coupon_call is now matched alongside FunctionCall when 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 that coupon_call<user@test::add_with_coupon> is properly framed and that the stack trace test::main -> test::add_with_coupon appears in the profiling output.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator Author

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.
@orizi
orizi force-pushed the orizi/06-11-bugfix_runner_profile_coupon_call_like_function_call_fix_from_trace_panic_ branch from 4c88c34 to 5d1e29d Compare June 11, 2026 08:37
@orizi
orizi marked this pull request as ready for review June 11, 2026 08:44
@cursor

cursor Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Narrow change to profiling stack-frame detection plus test data; no auth, execution, or data-path impact.

Overview
The runner profiler now treats coupon_call Sierra invocations like function_call when building the function stack during trace collection, so coupon-based calls get correct nested stack traces instead of being skipped.

A regression test exercises main calling add_with_coupon via a coupon and asserts Sierra/Cairo stack traces include test::main -> test::add_with_coupon.

Reviewed by Cursor Bugbot for commit 5d1e29d. Bugbot is set up for automated code reviews on this repo. Configure here.

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

@orizi
orizi added this pull request to the merge queue Jun 11, 2026

@eytan-starkware eytan-starkware left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@eytan-starkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on orizi).

Merged via the queue into main with commit 528ddcf Jun 11, 2026
54 checks passed
@orizi
orizi deleted the orizi/06-11-bugfix_runner_profile_coupon_call_like_function_call_fix_from_trace_panic_ branch June 11, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants