Skip to content

Delay specific span_bug() call until abort_if_errors() - #24367

Merged
bors merged 4 commits into
rust-lang:masterfrom
ebfull:fix_ice_cat_expr
Apr 26, 2015
Merged

Delay specific span_bug() call until abort_if_errors()#24367
bors merged 4 commits into
rust-lang:masterfrom
ebfull:fix_ice_cat_expr

Conversation

@ebfull

Copy link
Copy Markdown
Contributor

An actual typeck error is the cause of many failed compilations but an
unrelated bug is being reported instead. It is triggered because a typeck
error is presumably not yet identified during compiler execution, which
would normally bypass an invariant in the presence of other errors. In
this particular situation, we delay the reporting of the bug until
abort_if_errors().

Closes#23827, closes#24356, closes#23041, closes#22897, closes#23966,
closes#24013, and closes#23729

There is at least one situation where this bug may still be genuinely
triggered (#23437).

An actual typeck error is the cause of many failed compilations but an
unrelated bug is being reported instead. It is triggered because a typeck
error is presumably not yet identified during compiler execution, which
would normally bypass an invariant in the presence of other errors. In
this particular situation, we delay the reporting of the bug until
abort_if_errors().
Closesrust-lang#23827, closesrust-lang#24356, closesrust-lang#23041, closesrust-lang#22897, closesrust-lang#23966,
closesrust-lang#24013, and closesrust-lang#23729
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @alexcrichton

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

@ebfull

Copy link
Copy Markdown
ContributorAuthor

r? @pnkfelix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't change the message here; it is still a call to cat_expr_unadjusted up above, which is info I wanted to capture in the ICE message.

@pnkfelix

Copy link
Copy Markdown
Contributor

My reasoning behind calling span_bug in the first place was that I wanted to be notified about cases where the call to cat_expr is err'ing.

I guess as long as such cases continue to emit an ICE, then its not wrong to make this change.

But I wonder if it might be simpler (and more correct) to try to identify an earlier spot in the control flow to add an additional call to abort_if_errors.

Update: Of course there is also the option of doing both; i.e. land this PR now, but also try to fix the ICE itself by finding a new place (or more) to call abort_if_errors.

Update 2: Adding earlier calls to abort_if_errors won't fix things, both for the reason outlined down below (that I transcribed from @arielb1) but also because the code path in question is already checking if the tcx.sess has reported any errors anyway.

@pnkfelix

Copy link
Copy Markdown
Contributor

@arielb1 points out that inserting a new call to abort_if_errors would not be ideal, since it will continue to cause us to abort, when we really want to allow compilation to keep going and find more (independent) errors

The real problem here, @arielb1 points out, is that the guard on the span_bug here is only checking the tcx.sess to see if any errors have been emitted, but the fcx itself may also have errors registered that are not reflected in the tcx.sess.

Update: On further investigation, I am not 100% sure the analysis in this comment is quite right. E.g. I do not yet see how one can have errors registered in the fcx that are not reflected in the tcx.sess; stay tuned...

@pnkfelix

Copy link
Copy Markdown
Contributor

Actually, another potential way to go here would be to use the same strategy employed in this PR, except with the refinement that the Some arm for the match *delayed_bug should only ICE if !self.diagnostic().handler().has_errors().

That is, if we did end up reporting at least one error, then we could just say "okay, lets pretend that was the error that caused cat_expr to Err.

(Though I do worry about the potential for circular reasoning here, where a cat_expr Err that has gone undetected could then yield a spurious error downstream, and then that's reported, but is useless to the user and at the same time we get no ICE bug report...)

@ebfull

Copy link
Copy Markdown
ContributorAuthor

Actually, another potential way to go here would be to use the same strategy employed in this PR, except with the refinement that the Some arm for the match *delayed_bug should only ICE if !self.diagnostic().handler().has_errors().
That is, if we did end up reporting at least one error, then we could just say "okay, lets pretend that was the error that caused cat_expr to Err.

If I'm reading your comment right, that's what the code currently does. It should abort before the match *delayed_bug if there are any errors.

@arielb1

Copy link
Copy Markdown
Contributor

I say remove the tcx.sess.has_errors() check in that case. The worst case here is that we get crazy lifetime errors.

@ebfull

Copy link
Copy Markdown
ContributorAuthor

Done with both your recommendations, but it'd be nicer if these ICEs can be avoided by changing mem_categorization somehow.

@pnkfelix

Copy link
Copy Markdown
Contributor

@ebfull after discussion with @arielb1 on IRC, I think we can indeed avoid many of the ICE's, not by changing mem_categorization, but rather by restructuring the type checker to do high-level signature-matching checks (e.g. that trait impls define all necessary items from the trait definitions) before checking any bodies. I have a prototype that does that in development right now.

We may indeed still want to put in this PR, but i am not certain of that yet; I, like you, would prefer to get rid of this ICE entirely. (And indeed, the path to get there may still involve changes to mem_categorization; I am not sure yet.)

@pnkfelix

Copy link
Copy Markdown
Contributor

@ebfull btw you were correct when you wrote:

If I'm reading your comment right, that's what the code currently does. It should abort before the match *delayed_bug if there are any errors.

that is, my comment was based on a misreading of your code.

Update: fixed typo where I mistyped @ebfull 's username.

@pnkfelix

Copy link
Copy Markdown
Contributor

I have opened #24422 , which adopts the strategy outlined in an earlier comment.

However, it does not address all of the ICE's listed in this ticket. So we may still indeed want to adopt this change. I will look into it.

@ebull

Copy link
Copy Markdown

@pnkfelix ebfull != ebull :)


From: Felix S Klock II notifications@github.com
Sent: Tuesday, April 14, 2015 12:57 PM
To: rust-lang/rust
Cc: ebull
Subject: Re: [rust] Delay specific span_bug() call until abort_if_errors() (#24367)

I have opened #24422#24422 , which adopts the strategy outlined in an earlier comment.

[https://avatars3.githubusercontent.com/u/173127?v=3&s=400]#24422

Typeck highlevel before bodies by pnkfelix · Pull Request #24422 · rust-lang/rust · GitHub
typeck: Do high-level structural/signature checks before function body checks. This avoids various ICEs, e.g. premature calls to cat_expr that yield the dreaded "cat_expr Errd" ICE. However, it also means that some early error feedback...
Read more...#24422

However, it does not address all of the ICE's listed in this ticket. So we may still indeed want to adopt this change. I will look into it.

Reply to this email directly or view it on GitHubhttps://github.com//pull/24367#issuecomment-92979142.

@huonw

Copy link
Copy Markdown
Contributor

r? @pnkfelix (fell through the cracks?)

@pnkfelix

Copy link
Copy Markdown
Contributor

@huonw well, i was half-hoping to find a way to fix all of the known ICE's without adopting the strategy outlined in this PR. But its probably a better plan to adopt it at this point.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ebfull you'll need to update the test; the compiler has changed now with #24422 so that this error message is no longer emitted (since the problem in the impl below is signaled first).

@ebfull

Copy link
Copy Markdown
ContributorAuthor

Done, I stopped testing against what you fixed in #24422 as well.

@pnkfelix

Copy link
Copy Markdown
Contributor

@bors r+ be11171 rollup

@bors

bors commented Apr 25, 2015

Copy link
Copy Markdown
Collaborator

⌛ Testing commit be11171 with merge 7765aed...

@bors

bors commented Apr 25, 2015

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-mac-32-opt

@alexcrichton

Copy link
Copy Markdown
Member

@bors: retry

On Sat, Apr 25, 2015 at 6:10 AM, bors notifications@github.com wrote:

[image: 💔] Test failed - auto-mac-32-opt
http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/4695


Reply to this email directly or view it on GitHub
#24367 (comment).

@bors

bors commented Apr 25, 2015

Copy link
Copy Markdown
Collaborator

⌛ Testing commit be11171 with merge b01ed84...

@bors

bors commented Apr 25, 2015

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-linux-64-nopt-t

@pnkfelix

Copy link
Copy Markdown
Contributor

@bors retry

@bors

bors commented Apr 26, 2015

Copy link
Copy Markdown
Collaborator

⌛ Testing commit be11171 with merge b0043db...

bors added a commit that referenced this pull request Apr 26, 2015
An actual typeck error is the cause of many failed compilations but an
unrelated bug is being reported instead. It is triggered because a typeck
error is presumably not yet identified during compiler execution, which
would normally bypass an invariant in the presence of other errors. In
this particular situation, we delay the reporting of the bug until
abort_if_errors().
Closes#23827, closes#24356, closes#23041, closes#22897, closes#23966,
closes#24013, and closes#23729
**There is at least one situation where this bug may still be genuinely
triggered (#23437).**
@bors

bors commented Apr 26, 2015

Copy link
Copy Markdown
Collaborator

@bors
bors merged commit be11171 into rust-lang:masterApr 26, 2015
@ebfull

Copy link
Copy Markdown
ContributorAuthor

Should this be backported to beta like #24422?

@pnkfelix

Copy link
Copy Markdown
Contributor

triage: beta-nominated

(I am personally on fence, but it is worth discussing)

@rust-highfiverust-highfive added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 26, 2015
@pnkfelix

Copy link
Copy Markdown
Contributor

not accepted for beta backport.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment