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

Fix waiting on a query that panicked #115198

Merged
merged 1 commit into from
Aug 26, 2023
Merged

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Aug 25, 2023

This fixes waiting on a query that panicked. The code now looks for QueryResult::Poisoned in the query state in addition to the query cache. This fixes #111528.

r? @cjgillot

@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 Aug 25, 2023
Comment on lines +304 to +313
// We didn't find the query result in the query cache. Check if it was
// poisoned due to a panic instead.
let lock = query.query_state(qcx).active.get_shard_by_value(&key).lock();
match lock.get(&key) {
// The query we waited on panicked. Continue unwinding here.
Some(QueryResult::Poisoned) => FatalError.raise(),
_ => panic!(
"query result must in the cache or the query must be poisoned after a wait"
),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The only possible course of action is unwinding. Should we replace the match by an assertion?

Suggested change
// We didn't find the query result in the query cache. Check if it was
// poisoned due to a panic instead.
let lock = query.query_state(qcx).active.get_shard_by_value(&key).lock();
match lock.get(&key) {
// The query we waited on panicked. Continue unwinding here.
Some(QueryResult::Poisoned) => FatalError.raise(),
_ => panic!(
"query result must in the cache or the query must be poisoned after a wait"
),
}
// We didn't find the query result in the query cache. Check if it was
// poisoned due to a panic instead.
debug_assert!(
matches!(
query.query_state(qcx).active.get_shard_by_value(&key).lock().get(&key),
Some(QueryResult::Poisoned),
),
"query result must in the cache or the query must be poisoned after a wait",
);
// The query we waited on panicked. Continue unwinding here.
FatalError.raise()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like the current version makes it more clear that we should only call FatalError.raise() once we observe the QueryResult::Poisoned case. I don't think I want to downgrade to a debug_assert without some more testing of the parallel compiler. This path is also not terribly hot.

@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Aug 26, 2023

📌 Commit 3040d92 has been approved by cjgillot

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 26, 2023
@bors
Copy link
Contributor

bors commented Aug 26, 2023

⌛ Testing commit 3040d92 with merge 22d41ae...

@bors
Copy link
Contributor

bors commented Aug 26, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 22d41ae to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 26, 2023
@bors bors merged commit 22d41ae into rust-lang:master Aug 26, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Aug 26, 2023
@Zoxc Zoxc deleted the query-panic-wait branch August 26, 2023 16:26
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (22d41ae): 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

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)
2.8% [2.8%, 2.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.2% [-1.2%, -1.2%] 1
All ❌✅ (primary) - - 0

Cycles

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

Binary size

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

Bootstrap: 630.77s -> 631.198s (0.07%)
Artifact size: 316.08 MiB -> 316.03 MiB (-0.02%)

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
Development

Successfully merging this pull request may close these issues.

ICE: parallel compiler: value must be in cache after waiting
5 participants