Skip to content

rustc_expand: ensure stack in InvocationCollector::visit_expr #145410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Aug 14, 2025

In Fedora, when we built rustc with PGO on ppc64le, we started failing
the test issue-74564-if-expr-stack-overflow.rs. This could also be
reproduced on other arches by setting a smaller RUST_MIN_STACK, so
it's probably just unlucky that ppc64le PGO created a large stack frame
somewhere in this recursion path. Adding an ensure_sufficient_stack
solves the stack overflow.

Historically, that test and its fix were added in #74708,
which was also an ensure_sufficient_stack in this area of code at the
time. However, the refactor in #92573 basically left that
to the general MutVisitor, and then #142240 removed even
that ensure call. It may be luck that our tier-1 tested targets did not
regress the original issue across those refactors.

In Fedora, when we built rustc with PGO on ppc64le, we started failing
the test `issue-74564-if-expr-stack-overflow.rs`. This could also be
reproduced on other arches by setting a smaller `RUST_MIN_STACK`, so
it's probably just unlucky that ppc64le PGO created a large stack frame
somewhere in this recursion path. Adding an `ensure_sufficient_stack`
solves the stack overflow.

Historically, that test and its fix were added in rust-lang#74708,
which was also an `ensure_sufficient_stack` in this area of code at the
time. However, the refactor in rust-lang#92573 basically left that
to the general `MutVisitor`, and then rust-lang#142240 removed even
that ensure call. It may be luck that our tier-1 tested targets did not
regress the original issue across those refactors.
@rustbot
Copy link
Collaborator

rustbot commented Aug 14, 2025

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 14, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 14, 2025

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@Mark-Simulacrum
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 14, 2025
rustc_expand: ensure stack in `InvocationCollector::visit_expr`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 14, 2025
@rust-bors
Copy link

rust-bors bot commented Aug 15, 2025

☀️ Try build successful (CI)
Build commit: 573f999 (573f9998e93ec34dfdd88bca871a1bdbab6dcd19, parent: 898aff704d6f0d00343f21d31b8b9bfac8e43007)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (573f999): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 2
Improvements ✅
(primary)
-0.9% [-0.9%, -0.9%] 1
Improvements ✅
(secondary)
-0.4% [-0.8%, -0.2%] 25
All ❌✅ (primary) -0.9% [-0.9%, -0.9%] 1

Max RSS (memory usage)

Results (primary 2.4%, secondary -4.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% [-4.1%, -4.1%] 1
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Cycles

Results (secondary 5.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.8% [5.8%, 5.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.1%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 3
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 8
All ❌✅ (primary) -0.1% [-0.1%, -0.1%] 3

Bootstrap: 470.516s -> 469.329s (-0.25%)
Artifact size: 377.36 MiB -> 377.48 MiB (0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 15, 2025
@lqd
Copy link
Member

lqd commented Aug 15, 2025

r? lqd @bors r+

@bors
Copy link
Collaborator

bors commented Aug 15, 2025

📌 Commit f68bcb3 has been approved by lqd

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants