Skip to content

bootstrap: Don't use panics to report user errors #107019

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
jyn514 opened this issue Jan 18, 2023 · 7 comments
Open

bootstrap: Don't use panics to report user errors #107019

jyn514 opened this issue Jan 18, 2023 · 7 comments
Labels
A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust E-help-wanted Call for participation: Help is requested to fix this issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jyn514
Copy link
Member

jyn514 commented Jan 18, 2023

Currently, bootstrap uses assert! interchangeably between "we expect this command to always succeed" and "you, the user, did something wrong and need to fix it". See

assert!(out.status.success(), "`cargo miri setup` returned with non-0 exit code");
for an example of the former and
assert!(llvm_bin_path.is_dir());
for an example of the latter. We should have more helpful error reporting for the latter, to make it more clear that it's not a bug.

The background motivation is that people are used to seeing the latter panics, and so don't report bugs when they see the former. This makes it hard to fix bugs because we don't know things are broken.

@jyn514 jyn514 added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. labels Jan 18, 2023
@GentBinaku
Copy link

Can I take this ?

@jyn514
Copy link
Member Author

jyn514 commented Jan 18, 2023

@GentBinaku go for it!

@est31
Copy link
Member

est31 commented Jan 18, 2023

I think it's easy to find things that are clear user errors and to print that to the user. But in general, even a failing cargo miri setup invocation could have originated in an user error, so I'd advise against something like the ICE error message that links to the issue tracker.

@jyn514
Copy link
Member Author

jyn514 commented Jan 18, 2023

@est31 in that case, I would expect cargo-miri to have a reasonable message that explains what's going on. but honestly at that point even if miri anticipated the error the whole thing becomes quite murky: is it a "user error" if bootstrap and miri both work fine individually but not in combination? Is it a "user error" if someone runs x fix expecting it to work and do something useful (it's been broken for years)?

FWIW rustc prints the ICE message when you rebase over master and try to reuse the incremental cache and that was very helpful for finding #76720.

@est31
Copy link
Member

est31 commented Jan 18, 2023

is it a "user error" if bootstrap and miri both work fine individually but not in combination? Is it a "user error" if someone runs x fix expecting it to work and do something useful (it's been broken for years)?

Yeah it is a really hard question to answer. The problem is rooted in bootstrap's nature of being a system integration tool, with some of the components of the system even provided by the user (or optionally provided, say the stage 0 compiler).

The components called by bootstrap have different concepts of "user" as bootstrap (for them, bootstrap is another user), they receive different input data (it's been preprocessed by bootstrap), etc. In rustc on the other hand, everyone is on the same page about who the user is, what user input is, etc.

and that was very helpful for finding

Interesting, I didn't know about that. rustc's ICE messages might not be 100% accurate but they have a very low false positive rate which is very helpful.

@jyn514
Copy link
Member Author

jyn514 commented Jan 18, 2023

Interesting, I didn't know about that. rustc's ICE messages might not be 100% accurate but they have a very low false positive rate which is very helpful.

Yup, and this was one case where it was a false positive: the bug was in bootstrap because it was forcing two different compilers to reuse the same incremental cache.

In general I would rather not tell people to ignore errors; the worst that happens is we get multiple reports of the same bug, whereas if we tell people to ignore errors we don't know about real bugs people are running into.

@jyn514
Copy link
Member Author

jyn514 commented Apr 5, 2023

Copying my comment from #107417:

As a general rule:

  • If the panic can only happen because bootstrap's code itself was changed, it's an internal error (e.g. the Step checking in builder.rs)
  • If the panic can only happen because of a config.toml option or flags passed to bootstrap, before any commands are run, it's a user error
  • If the panic happens because of an external command it's ambiguous, but I would prefer to default to panicking so people report the bug.
  • If the panic happens because of an I/O error it's likely an internal error.
  • If the panic should never happen (e.g. "path traversal attack") it's an internal error

@jyn514 jyn514 removed the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust E-help-wanted Call for participation: Help is requested to fix this issue. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

3 participants