diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 5ed593b0d2f8e..21ecebaa93a06 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -281,6 +281,15 @@ WB_ENTRY(void, WB_PrintHeapSizes(JNIEnv* env, jobject o)) { } WB_END +WB_ENTRY(jboolean, WB_isUbsanEnabled(JNIEnv* env, jobject o)) { +#if defined(UNDEFINED_BEHAVIOR_SANITIZER) + return true; +#else + return false; +#endif +} +WB_END + WB_ENTRY(void, WB_ReadFromNoaccessArea(JNIEnv* env, jobject o)) size_t granularity = os::vm_allocation_granularity(); ReservedHeapSpace rhs(100 * granularity, granularity, os::vm_page_size()); @@ -2684,8 +2693,8 @@ static JNINativeMethod methods[] = { (void*)&WB_AddToBootstrapClassLoaderSearch}, {CC"addToSystemClassLoaderSearch0", CC"(Ljava/lang/String;)V", (void*)&WB_AddToSystemClassLoaderSearch}, - {CC"getCompressedOopsMaxHeapSize", CC"()J", - (void*)&WB_GetCompressedOopsMaxHeapSize}, + {CC"getCompressedOopsMaxHeapSize", CC"()J", (void*)&WB_GetCompressedOopsMaxHeapSize}, + {CC"isUbsanEnabled", CC"()Z", (void*)&WB_isUbsanEnabled}, {CC"printHeapSizes", CC"()V", (void*)&WB_PrintHeapSizes }, {CC"readFromNoaccessArea",CC"()V", (void*)&WB_ReadFromNoaccessArea}, {CC"stressVirtualSpaceResize",CC"(JJJ)I", (void*)&WB_StressVirtualSpaceResize}, diff --git a/test/hotspot/jtreg/containers/docker/DockerBasicTest.java b/test/hotspot/jtreg/containers/docker/DockerBasicTest.java index 357eb3db49727..567128f1446dd 100644 --- a/test/hotspot/jtreg/containers/docker/DockerBasicTest.java +++ b/test/hotspot/jtreg/containers/docker/DockerBasicTest.java @@ -30,20 +30,29 @@ * @modules java.base/jdk.internal.misc * java.management * jdk.jartool/sun.tools.jar - * @build HelloDocker - * @run driver DockerBasicTest + * @build HelloDocker jdk.test.whitebox.WhiteBox + * + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI DockerBasicTest */ import jdk.test.lib.containers.docker.Common; import jdk.test.lib.containers.docker.DockerRunOptions; import jdk.test.lib.containers.docker.DockerTestUtils; import jdk.test.lib.Platform; import jdk.test.lib.Utils; +import jdk.test.whitebox.WhiteBox; public class DockerBasicTest { private static final String imageNameAndTag = Common.imageName("basic"); public static void main(String[] args) throws Exception { + WhiteBox wb = WhiteBox.getWhiteBox(); + if (wb.isUbsanEnabled()) { + System.out.println("ubsan is enabled, avoid docker tests"); + return; + } + if (!DockerTestUtils.canTestDocker()) { return; } diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index 3b930aec16f29..a813028c8c852 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -72,6 +72,8 @@ public synchronized static WhiteBox getWhiteBox() { // Arguments public native void printHeapSizes(); + public native boolean isUbsanEnabled(); + // Memory private native long getObjectAddress0(Object o); public long getObjectAddress(Object o) {