openj9
openj9 copied to clipboard
java.lang.IllegalAccessException thrown for jdk.internal.misc.Unsafe.theUnsafe in Valhalla vt_standard testing
Many test failures are seen in recent PR sanity.functional testing with {x|z|a|p}linuxvalst (i.e., vt_standard) for pull requests #20112 and #20332. In most, if not all, cases IllegalAccessExceptions are thrown. I was able to reproduce this in an internal personal build with the latest merged source.
12:45:24 openjdk version "24-internal" 2025-03-18
12:45:24 OpenJDK Runtime Environment (build 24-internal-adhoc.jenkins.BuildJDKnextx86-64linuxvtstandardPersonal)
12:45:24 Eclipse OpenJ9 VM (build master-d51176e7598, JRE 24 Linux amd64-64-Bit Compressed References 20241016_390 (JIT enabled, AOT enabled)
12:45:24 OpenJ9 - d51176e7598
12:45:24 OMR - 0de486a739f
12:45:24 JCL - 972edea3789 based on jdk-24+12)
13:00:49 Testing: Create and Restore Criu Checkpoint Image once - CheckpointDeadlock
13:00:49 Test start time: 2024/10/16 10:00:48 Pacific Standard Time
13:00:49 Running command: bash /home/jenkins/workspace/Test_openjdknext_j9_sanity.functional_x86-64_linux_vt_standard_Personal_testList_1/aqa-tests/TKG/../../jvmtest/functional/cmdLineTests/criu/criuScript.sh /home/jenkins/workspace/Test_openjdknext_j9_sanity.functional_x86-64_linux_vt_standard_Personal_testList_1/aqa-tests/TKG/../../jvmtest/functional/cmdLineTests/criu /home/jenkins/workspace/Test_openjdknext_j9_sanity.functional_x86-64_linux_vt_standard_Personal_testList_1/jdkbinary/j2sdk-image/bin/java " -Xjit -XX:+CRIURestoreNonPortableMode --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/openj9.internal.criu=ALL-UNNAMED" org.openj9.criu.DeadlockTest CheckpointDeadlock 1 false false
13:00:49 Time spent starting: 2 milliseconds
13:00:51 Time spent executing: 2266 milliseconds
13:00:51 Test result: FAILED
13:00:51 Output from test:
13:00:51 [OUT] start running script
13:00:51 [OUT] export GLIBC_TUNABLES=glibc.cpu.hwcaps=-XSAVEC,-XSAVE,-AVX2,-ERMS,-AVX,-AVX_Fast_Unaligned_Load
13:00:51 [OUT] export LD_BIND_NOT=on
13:00:51 [OUT] /home/jenkins/workspace/Test_openjdknext_j9_sanity.functional_x86-64_linux_vt_standard_Personal_testList_1/jdkbinary/j2sdk-image/bin/java -XX:+EnableCRIUSupport -Xjit -XX:+CRIURestoreNonPortableMode --add-opens java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/openj9.internal.criu=ALL-UNNAMED -cp /home/jenkins/workspace/Test_openjdknext_j9_sanity.functional_x86-64_linux_vt_standard_Personal_testList_1/aqa-tests/TKG/../../jvmtest/functional/cmdLineTests/criu/criu.jar org.openj9.criu.DeadlockTest CheckpointDeadlock 1
13:00:51 [OUT] Exception in thread "main" java.lang.InternalError: java.lang.IllegalAccessException: static final field has no write access: jdk.internal.misc.Unsafe.theUnsafe/jdk.internal.misc.Unsafe/putStatic, from class java.lang.Object (module java.base)
13:00:51 [OUT] at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newFieldAccessor(MethodHandleAccessorFactory.java:207)
13:00:51 [OUT] at java.base/jdk.internal.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:144)
13:00:51 [OUT] at java.base/java.lang.reflect.Field.acquireOverrideFieldAccessor(Field.java:1212)
13:00:51 [OUT] at java.base/java.lang.reflect.Field.getOverrideFieldAccessor(Field.java:1181)
13:00:51 [OUT] at java.base/java.lang.reflect.Field.get(Field.java:454)
13:00:51 [OUT] at org.openj9.criu.DeadlockTest.<clinit>(DeadlockTest.java:356)
13:00:51 [OUT] Caused by: java.lang.IllegalAccessException: static final field has no write access: jdk.internal.misc.Unsafe.theUnsafe/jdk.internal.misc.Unsafe/putStatic, from class java.lang.Object (module java.base)
13:00:51 [OUT] at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:913)
13:00:51 [OUT] at java.base/java.lang.invoke.MethodHandles$Lookup.unreflectField(MethodHandles.java:3608)
13:00:51 [OUT] at java.base/java.lang.invoke.MethodHandles$Lookup.unreflectSetter(MethodHandles.java:3599)
13:00:51 [OUT] at java.base/java.lang.invoke.MethodHandleImpl$1.unreflectField(MethodHandleImpl.java:1621)
13:00:51 [OUT] at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newFieldAccessor(MethodHandleAccessorFactory.java:185)
13:00:51 [OUT] ... 5 more
13:00:51 [OUT] initiate restore
13:00:51 [OUT] Error (criu/protobuf.c:72): Unexpected EOF on (empty-image)
13:00:51 [OUT] Removed test output files
13:00:51 [OUT] finished script
@theresa-m, @a7ehuo - FYI
Issue Number: 20372 Status: Open Recommended Components: comp:test, comp:vm, comp:gc Recommended Assignees: jasonfengj9, tajila, babsingh
The failed line is: https://github.com/eclipse-openj9/openj9/blob/64cb0dbf2bbba87a294e5b5a5c3a7e5d92ec0514/test/functional/cmdLineTests/criu/src/org/openj9/criu/DeadlockTest.java#L356
@JasonFengJ9 Do you know if this fails on regular JDK24 build ?
Do you know if this fails on regular JDK24 build ?
Currently, there are no JDK24 nightly builds. Last openjdknext_j9_sanity.functional_aarch64_mac passed on Oct. 3rd. Launched a JDKnext_x86-64_linux.
Those failed tests in openjdknext_j9_sanity.functional_x86-64_linux_vt_standard passed in a regular openjdkNext_j9_sanity.functional_x86-64_linux
cmdLineTester_criu_nonPortableRestore_0_PASSED
...
cmdLineTester_libpathTestRtf_0_PASSED
...
FYI @hangshao0
Have you seen this failure before ? @babsingh @fengxue-IS
The https://github.com/ibmruntimes/openj9-openjdk-jdk.valuetypes repo is a few weeks behind https://github.com/ibmruntimes/openj9-openjdk-jdk though.
Two possible solutions come to mind:
- update https://github.com/ibmruntimes/openj9-openjdk-jdk.valuetypes - perhaps this is already fixed upstream
- change the way the
Unsafeinstance is acquired in tests - we're already using--add-opensto gain access to the package so we could just useUnsafe.getUnsafe()rather than reflection
Have you seen this failure before ?
It seems new. I haven't seen it before.
I tried the failing code with old Valhalla nightly builds and it started failing after the https://github.com/ibmruntimes/openj9-openjdk-jdk.valuetypes update in early May.
I looked through the merge commits of these files from the May extensions update but did not see anything inconsistent with the https://github.com/ibmruntimes/openj9-openjdk-jdk repository. This list is a subset of files identified as having had conflicts in https://github.com/ibmruntimes/openj9-openjdk-jdk.valuetypes/pull/10, https://github.com/ibmruntimes/openj9-openjdk-jdk.valuetypes/pull/11, https://github.com/ibmruntimes/openj9-openjdk-jdk.valuetypes/pull/12
src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
src/java.base/share/classes/java/lang/reflect/Modifier.java
src/java.base/share/classes/java/lang/invoke/MethodHandles.java
src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java
src/java.base/share/classes/jdk/internal/misc/Unsafe.java
src/java.base/share/classes/sun/invoke/util/Wrapper.java
src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java
src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
I'm inclined to believe that openjdk hasn't finished updating the Field implementation. The usage pattern (seen in the description) should not require generation of a setter, but an override field is never considered read-only. See ReflectionFactory.java.
ValueType changed Field.java's boolean trustedfinal to int flags to allow for multiple flags.
Inorder to match the expected behaviour, we need to update reflecthelp.c:840 to set the correct bits instead of JNI_TRUE for value type builds.
see
https://github.com/ibmruntimes/openj9-openjdk-jdk.valuetypes/blob/f488e607b7b61b5e4e9c088fb88b627531d9b1a6/src/java.base/share/classes/java/lang/reflect/Field.java#L1243-L1244
for flag constant.
Thanks @fengxue-IS !
I tested this out locally and it seems to solve the issue, I will work on testing further and submitting a fix.
Issue Number: 20372 Status: Closed Actual Components: comp:vm, project:valhalla Actual Assignees: No one :( PR Assignees: theresa-m, JasonFengJ9