Skip to content

Commit 8366017

Browse files
rwestrelpull[bot]
authored andcommitted
8342496: C2/Shenandoah: SEGV in compiled code when running jcstress
Reviewed-by: shade, rkennke
1 parent d3066be commit 8366017

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const Mem
10411041
Node* u = ctrl->fast_out(i);
10421042
if (u->_idx < last &&
10431043
u != barrier &&
1044+
!u->depends_only_on_test() && // preserve dependency on test
10441045
!uses_to_ignore.member(u) &&
10451046
(u->in(0) != ctrl || (!u->is_Region() && !u->is_Phi())) &&
10461047
(ctrl->Opcode() != Op_CatchProj || u->Opcode() != Op_CreateEx)) {
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2024, Red Hat, Inc. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/**
25+
* @test
26+
* @bug 8342496
27+
* @summary C2/Shenandoah: SEGV in compiled code when running jcstress
28+
* @requires vm.flavor == "server"
29+
* @requires vm.gc.Shenandoah
30+
*
31+
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+StressGCM
32+
* -XX:+StressLCM -XX:+UseShenandoahGC -XX:LoopMaxUnroll=0 -XX:StressSeed=270847015 TestLoadBypassesNullCheck
33+
* @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+StressGCM
34+
* -XX:+StressLCM -XX:+UseShenandoahGC -XX:LoopMaxUnroll=0 TestLoadBypassesNullCheck
35+
*
36+
*/
37+
38+
public class TestLoadBypassesNullCheck {
39+
private static A fieldA = new A();
40+
private static Object fieldO = new Object();
41+
private static volatile int volatileField;
42+
43+
public static void main(String[] args) {
44+
for (int i = 0; i < 20_000; i++) {
45+
test1();
46+
}
47+
fieldA = null;
48+
try {
49+
test1();
50+
} catch (NullPointerException npe) {
51+
}
52+
}
53+
54+
private static boolean test1() {
55+
for (int i = 0; i < 1000; i++) {
56+
volatileField = 42;
57+
A a = fieldA;
58+
Object o = a.fieldO;
59+
if (o == fieldO) {
60+
return true;
61+
}
62+
}
63+
return false;
64+
}
65+
66+
private static class A {
67+
public Object fieldO;
68+
}
69+
}

0 commit comments

Comments
 (0)