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

Don't use queries when printing the query stack #112603

Closed

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Jun 14, 2023

This adds a parameter to try_collect_active_jobs indicating if it can use queries to describe query frames. This is set to false when when printing the query stack during an ICE to work around the infinite recursion seen in #112522.

@rustbot
Copy link
Collaborator

rustbot commented Jun 14, 2023

r? @eholk

(rustbot has picked a reviewer for you, use r? to override)

@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 Jun 14, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the try_collect_active_jobs-no-queries branch from 932347a to 30b2d25 Compare June 14, 2023 03:03
@compiler-errors
Copy link
Member

This seems like a really heavy hammer to solve this issue.

Is it possible to just use with_no_queries/NO_QUERIES more judiciously within the pretty-printing code? I'd rather we print something for the query stack -- knowing the query frame descr is often very useful...

if !can_call_queries {
// Return a minimal query frame if we can't call queries
return QueryStackFrame::new(String::new(), None, None, None, kind, None, || Hash64::ZERO);
}
Copy link
Member

Choose a reason for hiding this comment

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

Can this be moved below the description formatting? It seems like that shouldn't use any queries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That can and does use queries.

@Zoxc
Copy link
Contributor Author

Zoxc commented Jun 16, 2023

It would be nice to at least print query keys, but I think we need either a separate non-query printing path or a better way to statically prevent queries to run for the existing path.

@bors
Copy link
Contributor

bors commented Jul 4, 2023

☔ The latest upstream changes (presumably #113303) made this pull request unmergeable. Please resolve the merge conflicts.

@eholk
Copy link
Contributor

eholk commented Jul 6, 2023

@compiler-errors - is the root of your concern that we're losing a lot of really helpful query information in the common case to avoid recursion in pathological cases?

I wonder if having a recursion_depth parameter we thread around would be a better compromise?

@compiler-errors
Copy link
Member

is the root of your concern that we're losing a lot of really helpful query information in the common case to avoid recursion in pathological cases?

Pretty much, yeah. The query stack being able to print keys on ICEs, for example, is quite helpful in my experience debugging the compiler.

@eholk
Copy link
Contributor

eholk commented Jul 6, 2023

@Zoxc - Do you think a recursion limit would work?

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2023
@Zoxc
Copy link
Contributor Author

Zoxc commented Aug 19, 2023

A recursion limit doesn't help for the parallel compiler which has more interesting failure scenarios. A more reliable way to print def paths is probably the way to go to restore debugging information.

@Zoxc Zoxc force-pushed the try_collect_active_jobs-no-queries branch from 30b2d25 to bb619af Compare August 21, 2023 19:30
@Zoxc
Copy link
Contributor Author

Zoxc commented Aug 21, 2023

I've introduced PrintContext and PrintArg types which get passed to the description function of queries. They hide tcx and the query key from direct access enabling the regular query descriptions to be used for the panic stack trace. If the query description use methods on PrintArg to access TyCtxt or the inner type, it will print <inaccessible> instead of doing the access for the panic case.

cc @cjgillot

@bors
Copy link
Contributor

bors commented Aug 28, 2023

☔ The latest upstream changes (presumably #115326) made this pull request unmergeable. Please resolve the merge conflicts.

@cjgillot
Copy link
Contributor

This PR is very complex, and makes the query description weird by changing the key type behind our back.
Alternative version: could we remove access to the tcx from TLS when we are in the plumbing code?

Today, we manipulate TLS twice when setting up a query:

  • once in start_query to setup the recursion, token and side-effect trackers,
  • once in with_task to setup dependency tracking.

Can the outer one remove access to the tcx, and have the inner one put it back?

@JohnCSimon
Copy link
Member

@Zoxc

ping from triage - can you post your status on this PR? This PR has not received an update in a few months. Thank you!

FYI: when a PR is ready for review, send a message containing
@rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

@Zoxc
Copy link
Contributor Author

Zoxc commented Feb 15, 2024

It doesn't seem like either approaches taken in this PR are very popular.

We may instead make the existing printing code respect with_no_queries!.

@Zoxc Zoxc closed this Feb 15, 2024
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) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

9 participants