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

remove keys w/ skolemized regions from proj cache when popping skolemized regions #37294

Merged
merged 3 commits into from
Oct 22, 2016

Conversation

nikomatsakis
Copy link
Contributor

This addresses #37154 (a regression). The projection cache was incorrectly caching the results for skolemized regions -- when we pop skolemized regions, we are supposed to drop cache keys for them (just as we remove those skolemized regions from the region inference graph). This is because those skolemized region numbers will be reused later with different meaning (and we have determined that the old ones don't leak out in any meaningful way).

I did a somewhat aggressive fix here of only removing keys that mention the skolemized regions. One could imagine just removing all keys added since we started the skolemization (as indeed I did in my initial commit). This more aggressive fix required fixing a latent bug in TypeFlags, as an aside.

I believe the more aggressive fix is correct; clearly there can be entries that are unrelated to the skoelemized region, and it's a shame to remove them. My one concern was that it is possible I believe to have some region variables that are created and related to skolemized regions, and maybe some of them could end up in the cache. However, that seems harmless enough to me-- those relations will be removed, and couldn't have impacted how trait resolution proceeded anyway (iow, the cache entry is not wrong, though it is kind of useless).

r? @pnkfelix
cc @arielb1

@bors
Copy link
Contributor

bors commented Oct 20, 2016

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

@brson brson added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 20, 2016
@pnkfelix
Copy link
Member

@bors r+

@pnkfelix
Copy link
Member

@nikomatsakis oh there's conflicts; well, r=me. :)

@bors
Copy link
Contributor

bors commented Oct 21, 2016

📌 Commit 80aeb7b has been approved by pnkfelix

@nikomatsakis
Copy link
Contributor Author

@bors r+

@bors
Copy link
Contributor

bors commented Oct 21, 2016

📌 Commit 483bc86 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 21, 2016

⌛ Testing commit 483bc86 with merge f5cfbf6...

@alexcrichton
Copy link
Member

@bors: retry force clean

Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 22, 2016
…sakis

remove keys w/ skolemized regions from proj cache when popping skolemized regions

This addresses rust-lang#37154 (a regression). The projection cache was incorrectly caching the results for skolemized regions -- when we pop skolemized regions, we are supposed to drop cache keys for them (just as we remove those skolemized regions from the region inference graph). This is because those skolemized region numbers will be reused later with different meaning (and we have determined that the old ones don't leak out in any meaningful way).

I did a *somewhat* aggressive fix here of only removing keys that mention the skolemized regions. One could imagine just removing all keys added since we started the skolemization (as indeed I did in my initial commit). This more aggressive fix required fixing a latent bug in `TypeFlags`, as an aside.

I believe the more aggressive fix is correct; clearly there can be entries that are unrelated to the skoelemized region, and it's a shame to remove them. My one concern was that it *is* possible I believe to have some region variables that are created and related to skolemized regions, and maybe some of them could end up in the cache. However, that seems harmless enough to me-- those relations will be removed, and couldn't have impacted how trait resolution proceeded anyway (iow, the cache entry is not wrong, though it is kind of useless).

r? @pnkfelix
cc @arielb1
@bors
Copy link
Contributor

bors commented Oct 22, 2016

⌛ Testing commit 483bc86 with merge 4879166...

bors added a commit that referenced this pull request Oct 22, 2016
remove keys w/ skolemized regions from proj cache when popping skolemized regions

This addresses #37154 (a regression). The projection cache was incorrectly caching the results for skolemized regions -- when we pop skolemized regions, we are supposed to drop cache keys for them (just as we remove those skolemized regions from the region inference graph). This is because those skolemized region numbers will be reused later with different meaning (and we have determined that the old ones don't leak out in any meaningful way).

I did a *somewhat* aggressive fix here of only removing keys that mention the skolemized regions. One could imagine just removing all keys added since we started the skolemization (as indeed I did in my initial commit). This more aggressive fix required fixing a latent bug in `TypeFlags`, as an aside.

I believe the more aggressive fix is correct; clearly there can be entries that are unrelated to the skoelemized region, and it's a shame to remove them. My one concern was that it *is* possible I believe to have some region variables that are created and related to skolemized regions, and maybe some of them could end up in the cache. However, that seems harmless enough to me-- those relations will be removed, and couldn't have impacted how trait resolution proceeded anyway (iow, the cache entry is not wrong, though it is kind of useless).

r? @pnkfelix
cc @arielb1
@bors bors merged commit 483bc86 into rust-lang:master Oct 22, 2016
@alexcrichton alexcrichton added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 24, 2016
@nikomatsakis
Copy link
Contributor Author

I feel mildly uncomfortable accepting this for beta-backport since I am the author. However, my assessment is that it is a relatively low risk -- it basically just removes things from the cache; I don't think this can cause a problem. The only impact might be on cycle detection, but we only remove things from the cache "on the way up", so cycles would still be detected. (And anyway I don't think we rely on this at present.)

Somebody want to agree to the backport? cc @rust-lang/compiler

@eddyb
Copy link
Member

eddyb commented Oct 25, 2016

SGTM.

@arielb1
Copy link
Contributor

arielb1 commented Oct 26, 2016

agree to backport.

@pnkfelix
Copy link
Member

agree to backport

@pnkfelix
Copy link
Member

discussed in compiler team mtg. its a kinda non-trivial backport, and at this point the regression has reached the point of being stable->stable.

so the question is: Is it all that bad to leave the ICE in for one more cycle?

Some members of the team (myself included) expressed indifference towards backport vs letting trains handle it.

@nikomatsakis
Copy link
Contributor Author

discussed in compiler team mtg. its a kinda non-trivial backport, and at this point the regression has reached the point of being stable->stable.

so the question is: Is it all that bad to leave the ICE in for one more cycle?

Some members of the team (myself included) expressed indifference towards backport vs letting trains handle it.

No strong opinion. @brson, your thoughts?

@brson
Copy link
Contributor

brson commented Nov 3, 2016

I'll see if it cherry-picks and passes the test suite, and if not just leave it for next cycle.

@brson
Copy link
Contributor

brson commented Nov 3, 2016

By 'non-trivial' you must have meant it won't cherry-pick, because it doesn't. Let's just leave it.

@brson brson removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Nov 3, 2016
@nikomatsakis nikomatsakis deleted the issue-37154 branch April 14, 2017 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

7 participants