Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Filipp Zhinkin committed Sep 7, 2020
1 parent e0d5b5f commit 70d5cac
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 @@ -25,6 +25,8 @@
* @test
* @bug 8202414
* @summary Unsafe write after primitive array creation may result in array length change
* @modules java.base/jdk.internal.misc
* @library /test/lib
* @run main/othervm compiler.c2.Test8202414
*/

Expand All @@ -34,10 +36,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 70d5cac

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 70d5cac Sep 7, 2020

Choose a reason for hiding this comment

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

Review

Issues

Please sign in to comment.