Skip to content
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

Depth limit const eval query #135167

Merged
merged 5 commits into from
Jan 13, 2025
Merged

Conversation

mzacho
Copy link
Contributor

@mzacho mzacho commented Jan 6, 2025

Currently the const-eval query doesn't have a recursion limit or timeout, causing the complier to freeze in an infinite loop, see #125718. This PR depth limits the eval_to_const_value_raw query (with the recursion_limit attribute) and improves the diagnostics for query overflow errors, so spans are reported for other dep kinds than layout_of (e.g. eval_to_const_value_raw).

fixes #125718
fixes #114192

@rustbot
Copy link
Collaborator

rustbot commented Jan 6, 2025

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @oli-obk (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Jan 6, 2025
| ^^^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "30"]` attribute to your crate (`recursive`)
= note: query depth increased by 17 when simplifying constant for the type system `RECUR`
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be neat if we could report the query backtrace before that recursion

Copy link
Contributor

Choose a reason for hiding this comment

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

(Similar to cycle errors)

Copy link
Contributor Author

@mzacho mzacho Jan 7, 2025

Choose a reason for hiding this comment

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

I'm not exactly sure how this should work since the job.id never repeats in this case. I guess we could determine when the cycle is complete by finding the first parent query with job.dep_kind == eval_to_const_value_raw and a span that matches the one of the current query. What do you think about this?

Seems like a bit of a hack but I can't really think of a better solution.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 8, 2025

@bors try

@oli-obk
Copy link
Contributor

oli-obk commented Jan 8, 2025

Gonna run crater to see if the default limit is fine

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 8, 2025
… r=<try>

Depth limit const eval query

Currently the const-eval query doesn't have a recursion limit or timeout, causing the complier to freeze in an infinite loop, see rust-lang#125718. This PR depth limits the `eval_to_const_value_raw` query (with the [`recursion_limit`](https://doc.rust-lang.org/reference/attributes/limits.html) attribute) and improves the diagnostics for query overflow errors, so spans are reported for other dep kinds than `layout_of` (e.g. `eval_to_const_value_raw`).

fixes rust-lang#125718
fixes rust-lang#114192
@bors
Copy link
Contributor

bors commented Jan 8, 2025

⌛ Trying commit 66c9a59 with merge 50b21af...

@bors
Copy link
Contributor

bors commented Jan 8, 2025

☀️ Try build successful - checks-actions
Build commit: 50b21af (50b21af28e291c419ae81eebcb7705fb4200dc90)

@theemathas
Copy link
Contributor

Should the code in #114192 (comment) also be included as a test?

@fmease
Copy link
Member

fmease commented Jan 8, 2025

Yes, that would great imo!

@mzacho mzacho force-pushed the depth-limit-const-eval-query branch from bbb8201 to 4b81c5b Compare January 8, 2025 19:04
@oli-obk
Copy link
Contributor

oli-obk commented Jan 8, 2025

@craterbot check

@mzacho
Copy link
Contributor Author

mzacho commented Jan 11, 2025

Don't think the job got enqueued? @oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Jan 11, 2025

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-135167 created and queued.
🤖 Automatically detected try build 50b21af
⚠️ Try build based on commit 66c9a59, but latest commit is 4b81c5b. Did you forget to make a new try build?
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 11, 2025
@craterbot
Copy link
Collaborator

🚧 Experiment pr-135167 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-135167 is completed!
📊 15 regressed and 3 fixed (567028 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Jan 13, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Jan 13, 2025

No regressions, just some disk failures

@bors r+

@bors
Copy link
Contributor

bors commented Jan 13, 2025

📌 Commit 4b81c5b has been approved by oli-obk

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 Jan 13, 2025
@bors
Copy link
Contributor

bors commented Jan 13, 2025

⌛ Testing commit 4b81c5b with merge 3ff1b64...

@bors
Copy link
Contributor

bors commented Jan 13, 2025

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 3ff1b64 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 13, 2025
@bors bors merged commit 3ff1b64 into rust-lang:master Jan 13, 2025
7 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 13, 2025
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3ff1b64): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary -3.9%, secondary -4.8%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Cycles

Results (secondary 0.9%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
8.5% [8.5%, 8.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-3.3%, -2.6%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 765.149s -> 764.23s (-0.12%)
Artifact size: 326.08 MiB -> 326.05 MiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. 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
8 participants