Skip to content

Commit

Permalink
8251152: ARM32: jtreg c2 Test8202414 test crash
Browse files Browse the repository at this point in the history
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
  • Loading branch information
caojoshua authored and Paul Hohensee committed Aug 17, 2022
1 parent 58076db commit ad2e6e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions test/hotspot/jtreg/compiler/c2/Test8202414.java
Expand Up @@ -26,6 +26,8 @@
* @bug 8202414
* @summary Unsafe write after primitive array creation may result in array length change
* @requires (os.arch != "sparc") & (os.arch != "sparcv9")
* @modules java.base/jdk.internal.misc
* @library /test/lib
* @run main/othervm compiler.c2.Test8202414
*/

Expand All @@ -35,10 +37,18 @@
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
import jtreg.SkippedException;

public class Test8202414 {

public static void main(String[] args) {
// Some CPUs (for example, ARM) does not support unaligned
// memory accesses. This test may cause JVM crash due to
// alignment check failure on such CPUs.
if (!jdk.internal.misc.Unsafe.getUnsafe().unalignedAccess()) {
throw new SkippedException(
"Platform is missing unaligned memory accesses support.");
}
System.err.close();
int count = 0;
while (count++ < 120000) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 SAP SE. All rights reserved.
* Copyright (c) 2016, 2020 SAP SE. 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
Expand All @@ -26,7 +26,7 @@
* @bug 8158260
* @summary Test unaligned Unsafe accesses
* @modules java.base/jdk.internal.misc:+open
*
* @library /test/lib
* @run main/othervm -Diters=20000 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation
* compiler.unsafe.JdkInternalMiscUnsafeUnalignedAccess
* @author volker.simonis@gmail.com
Expand All @@ -38,6 +38,7 @@

import java.lang.reflect.Field;
import java.nio.ByteOrder;
import jtreg.SkippedException;

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

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

memory = UNSAFE.allocateMemory(SIZE);
Expand Down

1 comment on commit ad2e6e4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.