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

Deferred ICEs (i.e. delay_span_bug) are not preserved by incremental. #65401

Closed
eddyb opened this issue Oct 14, 2019 · 9 comments · Fixed by #65470
Closed

Deferred ICEs (i.e. delay_span_bug) are not preserved by incremental. #65401

eddyb opened this issue Oct 14, 2019 · 9 comments · Fixed by #65470
Labels
A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eddyb
Copy link
Member

eddyb commented Oct 14, 2019

When compiling a delay_span_bug testcase (e.g. the last snippet in #63154 (comment) on the current nightly, or any of the other examples in that issue on older compilers) with -Cincremental (or Cargo which does that by default), only the initial run will ICE.

Subsequent runs will succeed without an ICE, in the absence of any regular errors. However, changing the relevant code (e.g. adding a space) can cause the query that calls delay_span_bug to be recomputed and bring the ICE back.

IIUC, incremental compilation stores diagnostics and replays them on subsequent runs, but that appears to not apply to delay_span_bug ICEs.

cc @michaelwoerister

@csmoe csmoe added the A-incr-comp Area: Incremental compilation label Oct 14, 2019
@eddyb
Copy link
Member Author

eddyb commented Oct 14, 2019

It looks like without incremental we output artifacts (like rlib).
Do we do this in case of errors too? It seems bad to produce artifacts after an ICE.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 14, 2019
@Centril Centril added I-nominated P-high High priority labels Oct 14, 2019
@Centril
Copy link
Contributor

Centril commented Oct 14, 2019

Nominating and proposing P-high (mostly because of potential annoyance factor).

This should possibly also be labeled I-unsound under the assumption that under the general case of this issue, we might produce artifacts under subsequent runs that may produce UB traces. (However, it is probable that the user will notice the ICE at some other point in time and therefore discard the artifact.)

@michaelwoerister
Copy link
Member

The current expected behavior of the compiler is to not save any incremental state if an error occurs. delay_span_bug may slip through the cracks here.

@Centril
Copy link
Contributor

Centril commented Oct 14, 2019

@michaelwoerister In that case, it seems to me like it's a matter of recording the fact that we did a delay_span_bug (which we already do, https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.HandlerInner.html#structfield.delayed_span_bugs) and then have this mean "there was an error" in terms of "should we save incremental state?".

@michaelwoerister
Copy link
Member

Yep, the following check should also take delay_span_bug into account:

if sess.has_errors() {

While we are at it, we could also add a similar check to rustc_incremental::save_dep_graph() and rustc_incremental::save_work_product_index(), as not to waste time producing values that will then be discarded anyway:

pub fn save_dep_graph(tcx: TyCtxt<'_>) {

@Centril Centril added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-help-wanted Call for participation: Help is requested to fix this issue. labels Oct 14, 2019
@varkor varkor added the I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness label Oct 14, 2019
@traxys
Copy link
Contributor

traxys commented Oct 15, 2019

I'd like to start contributing to rustc and I wanted to ask if this is a good issue to start on (I have read the rustc book)

@Centril
Copy link
Contributor

Centril commented Oct 15, 2019

@traxys Sure, this is a decently good issue to start on and should be pretty interesting in terms of learning the infrastructure. If you get stuck, need help, and want to talk synchronously you can hop into https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.2365401.20delay_span_bug.20not.20preserved.20by.20incremental and we'll try to help out.

@michaelwoerister michaelwoerister added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed 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. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-high High priority labels Nov 1, 2019
@michaelwoerister
Copy link
Member

#65470 fixes this issue. It would still be good to have a test case for it.

@traxys
Copy link
Contributor

traxys commented Nov 1, 2019

I have started to write the code making this test possible, I'll open a PR shortly

Centril added a commit to Centril/rust that referenced this issue Nov 20, 2019
Making ICEs and test them in incremental

This adds:
 - A way to make the compiler ICE
 - A way to check for ICE in `cfail` tests with `should-ice`
 - A regression test for issue rust-lang#65401

I am not sure the attribute added `should-ice` is the best for this job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness 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