Skip to content

Commit

Permalink
8312440: assert(cast != nullptr) failed: must have added a cast to pi…
Browse files Browse the repository at this point in the history
…n the node

Reviewed-by: chagedorn, kvn, thartmann
  • Loading branch information
rwestrel committed Jul 27, 2023
1 parent b7545a6 commit 01e135c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/loopopts.cpp
Expand Up @@ -1697,7 +1697,7 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) {
}
if (cast != nullptr) {
Node* prev = _igvn.hash_find_insert(cast);
if (prev != nullptr) {
if (prev != nullptr && get_ctrl(prev) == x_ctrl) {
cast->destruct(&_igvn);
cast = prev;
} else {
Expand Down
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2023, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* bug 8312440
* @summary assert(cast != nullptr) failed: must have added a cast to pin the node
* @run main/othervm -XX:-BackgroundCompilation TestSunkNodeMissingCastAssert
*/


public class TestSunkNodeMissingCastAssert {
private static int N = 500;
private static int ia[] = new int[N];
private static volatile int ib[] = new int[N];

private static void test() {
for (int k = 1; k < 200; k++)
switch (k % 5) {
case 0:
ia[k - 1] -= 15;
case 2:
for (int m = 0; m < 1000; m++);
case 3:
ib[k - 1] <<= 5;
case 4:
ib[k + 1] <<= 3;
}
}

public static void main(String[] args) {
for (int i = 0; i < 20000; i++) {
test();
}
}
}

5 comments on commit 01e135c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 01e135c Sep 25, 2023

Choose a reason for hiding this comment

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

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on 01e135c Sep 25, 2023

Choose a reason for hiding this comment

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

@GoeLin Could not automatically backport 01e135c9 to openjdk/jdk21u due to conflicts in the following files:

  • src/hotspot/share/opto/loopopts.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b GoeLin-backport-01e135c9

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 01e135c91018a41800c2df534b1d6dbd396adbf4

# Backport the commit
$ git cherry-pick --no-commit 01e135c91018a41800c2df534b1d6dbd396adbf4
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 01e135c91018a41800c2df534b1d6dbd396adbf4'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u with the title Backport 01e135c91018a41800c2df534b1d6dbd396adbf4.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 01e135c Sep 25, 2023

Choose a reason for hiding this comment

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

/backport jdk21u pr/199

@openjdk
Copy link

@openjdk openjdk bot commented on 01e135c Sep 25, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-01e135c9 in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:pr/199, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 01e135c9 from the openjdk/jdk repository.

The commit being backported was authored by Roland Westrelin on 27 Jul 2023 and was reviewed by Christian Hagedorn, Vladimir Kozlov and Tobias Hartmann.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git GoeLin-backport-01e135c9:GoeLin-backport-01e135c9
$ git checkout GoeLin-backport-01e135c9
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git GoeLin-backport-01e135c9

Please sign in to comment.