mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
Fix failing test.
This commit is contained in:
parent
5c7c2f093b
commit
0fb953bc21
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2026, Oracle and/or its affiliates. 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
|
||||
@ -113,8 +113,14 @@ public class TestDwarf {
|
||||
new DwarfConstraint(0, "foo", "libTestDwarf.c", 42),
|
||||
new DwarfConstraint(1, "Java_TestDwarf_crashNativeMultipleMethods", "libTestDwarf.c", 70));
|
||||
}
|
||||
runAndCheck(new Flags(TestDwarf.class.getCanonicalName(), "nativeDereferenceNull"),
|
||||
new DwarfConstraint(0, "dereference_null", "libTestDwarfHelper.h", 46));
|
||||
// Null pointer dereferences exhibit different behaviour depending on if GCC or Clang is used.
|
||||
// When using GCC, the VM will crash gracefully and generate a hs_err which can be parsed.
|
||||
// On the contrary, with Clang the process exits immediately without hs_err.
|
||||
// Since runAndCheck needs an hs_err file, we have to skip this subtest.
|
||||
if (!isUsingClang()) {
|
||||
runAndCheck(new Flags(TestDwarf.class.getCanonicalName(), "nativeDereferenceNull"),
|
||||
new DwarfConstraint(0, "dereference_null", "libTestDwarfHelper.h", 46));
|
||||
}
|
||||
}
|
||||
|
||||
// A full pattern could check for lines like:
|
||||
@ -240,6 +246,7 @@ public class TestDwarf {
|
||||
private static native void crashNativeDivByZero();
|
||||
private static native void crashNativeDereferenceNull();
|
||||
private static native void crashNativeMultipleMethods(int x);
|
||||
private static native boolean isUsingClang();
|
||||
}
|
||||
|
||||
class UnsupportedDwarfVersionException extends RuntimeException { }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2026, Oracle and/or its affiliates. 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
|
||||
@ -28,8 +28,8 @@ int zero = 0;
|
||||
int result = 0;
|
||||
int limit = 20;
|
||||
|
||||
// Just big enough by doing some random things such that it is not inlined.
|
||||
void foo(int x) {
|
||||
// Explicitly don't inline: foo is large enough that GCC won't inline it, but Clang might.
|
||||
__attribute__((noinline)) void foo(int x) {
|
||||
printf("foo3:");
|
||||
printf(" %d\n", x);
|
||||
for (int i = 0; i < limit; i++) {
|
||||
@ -76,3 +76,12 @@ JNIEXPORT void JNICALL Java_TestDwarf_crashNativeMultipleMethods(JNIEnv* env, jc
|
||||
}
|
||||
}
|
||||
|
||||
// Need to tell if Clang was used to build libTestDwarf.
|
||||
JNIEXPORT jboolean JNICALL Java_TestDwarf_isUsingClang(JNIEnv* env, jobject obj) {
|
||||
#if defined(__clang__)
|
||||
return JNI_TRUE;
|
||||
#else
|
||||
return JNI_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2026, Oracle and/or its affiliates. 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
|
||||
@ -41,7 +41,7 @@ void unused4() {
|
||||
void unused5() {
|
||||
}
|
||||
|
||||
EXPORT void dereference_null() {
|
||||
__attribute__((noinline)) EXPORT void dereference_null() {
|
||||
int* x = (int*)0;
|
||||
*x = 34; // Crash
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user