Skip to content

Commit ad2e6e4

Browse files
caojoshuaPaul Hohensee
authored andcommitted
8251152: ARM32: jtreg c2 Test8202414 test crash
Some CPUs (like ARM32) does not support unaligned memory accesses. To avoid JVM crashes tests that perform such accesses should be skipped on corresponding platforms. Reviewed-by: phh Backport-of: 70d5cac
1 parent 58076db commit ad2e6e4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

test/hotspot/jtreg/compiler/c2/Test8202414.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
* @bug 8202414
2727
* @summary Unsafe write after primitive array creation may result in array length change
2828
* @requires (os.arch != "sparc") & (os.arch != "sparcv9")
29+
* @modules java.base/jdk.internal.misc
30+
* @library /test/lib
2931
* @run main/othervm compiler.c2.Test8202414
3032
*/
3133

@@ -35,10 +37,18 @@
3537
import java.lang.reflect.Field;
3638
import java.security.AccessController;
3739
import java.security.PrivilegedAction;
40+
import jtreg.SkippedException;
3841

3942
public class Test8202414 {
4043

4144
public static void main(String[] args) {
45+
// Some CPUs (for example, ARM) does not support unaligned
46+
// memory accesses. This test may cause JVM crash due to
47+
// alignment check failure on such CPUs.
48+
if (!jdk.internal.misc.Unsafe.getUnsafe().unalignedAccess()) {
49+
throw new SkippedException(
50+
"Platform is missing unaligned memory accesses support.");
51+
}
4252
System.err.close();
4353
int count = 0;
4454
while (count++ < 120000) {

test/hotspot/jtreg/compiler/unsafe/JdkInternalMiscUnsafeUnalignedAccess.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016 SAP SE. All rights reserved.
2+
* Copyright (c) 2016, 2020 SAP SE. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
2626
* @bug 8158260
2727
* @summary Test unaligned Unsafe accesses
2828
* @modules java.base/jdk.internal.misc:+open
29-
*
29+
* @library /test/lib
3030
* @run main/othervm -Diters=20000 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation
3131
* compiler.unsafe.JdkInternalMiscUnsafeUnalignedAccess
3232
* @author volker.simonis@gmail.com
@@ -38,6 +38,7 @@
3838

3939
import java.lang.reflect.Field;
4040
import java.nio.ByteOrder;
41+
import jtreg.SkippedException;
4142

4243
public class JdkInternalMiscUnsafeUnalignedAccess {
4344
static final int ITERS = Integer.getInteger("iters", 20_000);
@@ -131,8 +132,7 @@ static void putLong_17(long l) {
131132
public static void main(String[] args) throws Exception {
132133

133134
if (!UNSAFE.unalignedAccess()) {
134-
System.out.println("Platform is not supporting unaligned access - nothing to test.");
135-
return;
135+
throw new SkippedException("Platform is not supporting unaligned access - nothing to test.");
136136
}
137137

138138
memory = UNSAFE.allocateMemory(SIZE);

0 commit comments

Comments
 (0)