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

The compiler keeps going on Ctrl-C #124212

Closed
RalfJung opened this issue Apr 20, 2024 · 13 comments · Fixed by #125523
Closed

The compiler keeps going on Ctrl-C #124212

RalfJung opened this issue Apr 20, 2024 · 13 comments · Fixed by #125523
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

Sometimes when things go really wrong the compiler emits a ton of error messages. This can actually take a while to render them all. And since somewhat recently, hitting Ctrl-C no longer interrupts that, I get a thousand error messages displayed after Ctrl-C.

I suspect this may have to do with #111769. The Ctrl-C handler does nothing at all on the first Ctrl-C unless the compiler is in the middle of const-eval.

Cc @saethlin

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 20, 2024
@saethlin
Copy link
Member

Do you have a reproducer? I have not run into this myself.

The implementation should also ensure that the compiler exits promptly if you hit ctrl+c again. Does it?

@matthiaskrgr
Copy link
Member

if stuff keeps going on ctrl+c, sometimes suspending the process (ctrl+z) and then killing the terminal does the trick somehow 😅

@RalfJung
Copy link
Member Author

Do you have a reproducer? I have not run into this myself.

Unfortunately no, I encountered this during some rustc hacking where I ended up getting well over 1k error messages in the standard library build and that turned out to be hard to cancel.

The implementation should also ensure that the compiler exits promptly if you hit ctrl+c again. Does it?

I thought I had tried that, but I am not entirely sure.

@ChrisDenton
Copy link
Contributor

ChrisDenton commented Apr 21, 2024

Is it possible the shell is part of the problem? If, by the time you hit ctrl-c, it's working through a large amount of output it still has buffered then it might be awhile before you see a response.

@RalfJung
Copy link
Member Author

It's possible, sure -- but usually it reacts to Ctrl-C immediately even when there's tons of output.

@fmease fmease added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-const-eval Area: constant evaluation (mir interpretation) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 21, 2024
@fmease
Copy link
Member

fmease commented Apr 21, 2024

Have you tried reverting #111769 to check if that fixes it?

@fmease fmease added C-bug Category: This is a bug. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. labels Apr 21, 2024
@RalfJung
Copy link
Member Author

No. At the time I was busy getting a PR done and now I don't have a reproducing example any more.

@bjorn3
Copy link
Member

bjorn3 commented Apr 22, 2024

#111769 only checks for ctrl-c during const eval, so if no const eval runs for an extended period of time, the ctrl-c will be silently ignored. This is not the only problem with that PR. It also caused #124265, and shows the "compilation was interrupted" error after the prompt is already drawn by bash.

@workingjubilee
Copy link
Contributor

workingjubilee commented Apr 22, 2024

is there a good way to make rustc loop endlessly without ever touching const eval? maybe via the trait solver? 🤔

it would help for debugging this.

@fmease fmease removed A-const-eval Area: constant evaluation (mir interpretation) S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. labels Apr 22, 2024
@fmease
Copy link
Member

fmease commented Apr 22, 2024

Yeah, just take any I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. issue (none are A-const-eval Area: constant evaluation (mir interpretation) anyway).
I can reproduce this issue with #122443 for example:

  • nightly-2024-03-26 (before #111769): Exits after a single ^C
  • nightly-2024-03-27 (after #111769): Requires ^C^C to exit

bjorn3's analysis checks out.

@workingjubilee
Copy link
Contributor

workingjubilee commented Apr 22, 2024

cool! I wasn't sure how much of the compiler's code flowed through const-eval, is why I asked.

@bjorn3
Copy link
Member

bjorn3 commented May 24, 2024

Another case where this is observed: #125428

IMO we should revert #111769 or at least make the signal handler run exit after a short timeout.

@saethlin
Copy link
Member

I'll post a PR that adds a timeout later today, but by all means if you feel strongly just put up a PR. The initial handler here was just added through the normal PR process, there's no reason to be more cautious on reverting or modifying it.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue May 25, 2024
Exit the process a short time after entering our ctrl-c handler

Fixes rust-lang#124212

r? `@bjorn3`
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 26, 2024
Rollup merge of rust-lang#125523 - saethlin:ctrlc-timeout, r=bjorn3

Exit the process a short time after entering our ctrl-c handler

Fixes rust-lang#124212

r? `@bjorn3`
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 28, 2024
Exit the process a short time after entering our ctrl-c handler

Fixes rust-lang/rust#124212

r? `@bjorn3`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants