Skip to content

Commit 70d5cac

Browse files
committed
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: iignatyev, clanger
1 parent e0d5b5f commit 70d5cac

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
@@ -25,6 +25,8 @@
2525
* @test
2626
* @bug 8202414
2727
* @summary Unsafe write after primitive array creation may result in array length change
28+
* @modules java.base/jdk.internal.misc
29+
* @library /test/lib
2830
* @run main/othervm compiler.c2.Test8202414
2931
*/
3032

@@ -34,10 +36,18 @@
3436
import java.lang.reflect.Field;
3537
import java.security.AccessController;
3638
import java.security.PrivilegedAction;
39+
import jtreg.SkippedException;
3740

3841
public class Test8202414 {
3942

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