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
8303279: C2 Compiler crash (triggered by Kotlin 1.8.10) #14600
Conversation
👋 Welcome back simonis! A progress list of the required criteria for merging this PR into |
Webrevs
|
@simonis I reproduced it and I'm taking a closer look. |
I've added @rwestrel's test to the PR and verified that the code generated for the new test with this fix is the same like the code that was generated before JDK-8238691 and also the same like the code generated if we run with |
/contributor add roland |
@simonis |
FWIW, I propose an alternate fix here. master...rwestrel:jdk:JDK-8303279 |
Thanks @rwestrel. I'm fine with your patch. Do you want to take JDK-8303279 and propose your fix as PR? I will then close mine. |
Let me open the PR. I will away for a week though starting later today. |
Closing this PR in favour of @rwestrel 's. |
This is a problem probably introduced by JDK-8238691. It could reproduce it with JDK 17, 18 and 21 and results in the following crash (see JBS-issue for more details):
SubTypeCheckNode::sub()
expects that it'ssub_t
inputType
is either a Klasspointer (i.e.Type::KlassPtr
) or an Ooppointer (i.e.Type::OopPtr
,Type::InstPtr
orType::AryPtr
). It only checks for a Klasspointer and if that's not the case it assumes an Ooppointer. However, in the crashing case,sub_t
has the generic pointer typeType::AnyPtr
so debug builds will run into an assertion and product builds will just crash.The
SubTypeCheckNode
in question has the following shape insplit_if()
:split_if()
then searches for the first contstant input pfSubTypeCheck
Phi
-node and findsConP (#NULL)
. It then callsSubTypeCheckNode::sub()
withsub_t
asConP (#NULL)
's type which isType::AnyPtr
and crashes.I've verified that returning
bottom_type()
fromSubTypeCheckNode::sub
for the(!sub_t->isa_klassptr() && !sub_t->isa_oopptr())
case fixes the crash (by instrumenting the VM to ensure that the compilation as well as the further program execution succeeds if we take the new branch).I'm only not sure if the unusual graph which leads to this crash is caused by the uncommon bytecode generated by the Kotlin compiler or if it is the result of another problem in an earlier optimization stage?
While browsing JBS, I found JDK-8303513 which seems similar to this issue (i.e. also caused by a SubTypeCheckNode with an input of the TOP constant node).
While looking at
SubTypeCheckNode::Ideal()
I found that it already has exactly the same safeguard as proposed forSubTypeCheckNode::sub()
in this PR, namely:I'd really appreciate if @rwestrel could take a look at this issue.
Progress
Issue
Contributors
<roland@openjdk.org>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14600/head:pull/14600
$ git checkout pull/14600
Update a local copy of the PR:
$ git checkout pull/14600
$ git pull https://git.openjdk.org/jdk.git pull/14600/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14600
View PR using the GUI difftool:
$ git pr show -t 14600
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14600.diff
Webrev
Link to Webrev Comment