-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8324809: compiler can crash with SOE while proving if two recursive types are disjoint #19194
8324809: compiler can crash with SOE while proving if two recursive types are disjoint #19194
Conversation
…ypes are disjoint
👋 Welcome back vromero! A progress list of the required criteria for merging this PR into |
@vicente-romero-oracle This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 402 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
@vicente-romero-oracle The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
erasure(t.getUpperBound()) : | ||
visit(t.getUpperBound()); | ||
return rewriteAsWildcardType(bound, t, EXTENDS); | ||
if (seen.add(t)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, this code is called by Types.isCastable
, in an attempt to do some fancy logic (outside the spec) which allow to determine whether two types are disjoint or not. To do this, the code attempts to rewrite occurrences of type-variables using wildcards. So, in some cases the logic fails with SOE - so that result should lead to the consequence that we don't know whether the types are disjoint or not, but, since we're outside the scope of the spec, we need to treat them as not disjoint (e.g. the cast should be possible and we gave up proving that it should NOT be possible).
So, I'm afraid that return t
here is going to make this method stricter than intended, which will lead javac to think that the types are in fact disjoint, and that will result in a compiler error. I wonder if we should we return a ?
instead?
@@ -4734,6 +4734,10 @@ class Rewriter extends UnaryVisitor<Type> { | |||
|
|||
boolean high; | |||
boolean rewriteTypeVars; | |||
// map to avoid visiting same type argument twice, like in Foo<T>.Bar<T> | |||
Map<Type, Type> argMap = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to use both a map and a set, or can we just use the map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes and in any case the code is more readable, me thinks, with both than using only one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
/integrate |
Going to push as commit 39a55e9.
Your commit was automatically rebased without conflicts. |
@vicente-romero-oracle Pushed as commit 39a55e9. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
javac is crashing with SOE while compiling code like:
here while attributing:
return (D)new Builder<>();
the compiler is trying to prove that:Builder<C>
is castable toD
, then as the upper bound ofD
isBuilder<E>
, we need to check ifBuilder<C>
is castable toBuilder<E>
. Then the next step is to try to check if type variables C and E are disjoint. During this process is when the compiler gets out of resources given thatE <: Criteria
D <: Builder here we have E again and we start over in an infinite loop,
Here the proposal is to detect cycles in the type arguments graph and accept these type of casts if we find a cycle and thus can't prove if two types are disjoint,
TIA
Progress
Warning
8324809: compiler can crash with SOE while proving if two recursive types are disjoint
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19194/head:pull/19194
$ git checkout pull/19194
Update a local copy of the PR:
$ git checkout pull/19194
$ git pull https://git.openjdk.org/jdk.git pull/19194/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19194
View PR using the GUI difftool:
$ git pr show -t 19194
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19194.diff
Webrev
Link to Webrev Comment