A DESCRIPTION OF THE PROBLEM :
On JDKs 20 and 21, the JVM crashes when a java agent is active during CDS archive creation, if
a) the started application calls ManagementFactory.getGarbageCollectorMXBeans() and
b) the class file transformer installed by the agent returns the original class bytes from its 'transform' method.
The error goes away, if the transformer instead returns null, indicating no transformation took place.
The crash does *not* occur on JDKs 13 to 19, but on 20 and 21.
REGRESSION : Last worked in version 19
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Go to https://github.com/kriegaex/cds-javaagent-bug and clone the reproducer Maven project.
2. Run the build on JDK 20 or 21: mvn clean verify
===================================
HOWTO - if your JDK is location at $MYJDK:
- you need to install maven (mvn) and git first, then
$ git clone https://github.com/kriegaex/cds-javaagent-bug
$ cd cds-javaagent-bug
$ PATH=$MYJDK/bin:$PATH JAVA_HOME=$MYJDK mvn -v
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 23-internal, vendor: Oracle Corporation, runtime: /jdk3/bld/pan/images/jdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-33-generic", arch: "amd64", family: "unix"
$ PATH=$MYJDK/bin:$PATH JAVA_HOME=$MYJDK mvn -B -X clean verify 2>&1 | tee log.txt
Then in log.txt, search for "demo.jsa", you will find three occurrences. The second and third occurrences are the command lines to execute to reproduce the error. You need to cut-and-paste, replace "," with a space, and ";" with ":"
This fails with my JDK 23 development build
$ java -classpath /jdk3/tmp/8325536/cds-javaagent-bug/cds-javaagent-test/../cds-javaagent-app/target/cds-javaagent-app-1.0-SNAPSHOT.jar;/jdk3/tmp/8325536/cds-javaagent-bug/cds-javaagent-test/../cds-javaagent-agent/target/cds-javaagent-agent-1.0-SNAPSHOT.jar -XX:+UnlockDiagnosticVMOptions -Xshare:on -XX:ArchiveClassesAtExit=demo.jsa -XX:+AllowArchivingWithJavaAgent -javaagent:/jdk3/tmp/8325536/cds-javaagent-bug/cds-javaagent-test/../cds-javaagent-agent/target/cds-javaagent-agent-1.0-SNAPSHOT.jar=XXXreturnNull dev.aspectj.Application
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (systemDictionaryShared.cpp:575), pid=3019215, tid=3019223
# guarantee(!k->is_shared_unregistered_class()) failed: Class loader type must be set for BUILTIN class java/lang/invoke/BoundMethodHandle$Species_LLLL
#
# JRE version: Java(TM) SE Runtime Environment (23.0) (build 23-internal-adhoc.iklam.pan)
# Java VM: JavaHotSpot(TM) 64-Bit Server VM (23-internal-adhoc.iklam.pan, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xe8974a] SystemDictionaryShared::validate_before_archiving(InstanceKlass*)+0x21a
#
====================================
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The build passes and the CDS archive is written successfully..
ACTUAL -
The build fails and a hs_err_pid*.log is written, because during phase 'verify' Maven Invoker Plugin tries to run the program with the active java agent, while trying to create a CDS archive.
---------- BEGIN SOURCE ----------
See https://github.com/kriegaex/cds-javaagent-bug
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Two options:
1. Run on JDK 13-19. It works without changes.
2. On JDK 20/21, edit file cds-javaagent-test/pom.xml and remove the "XXX" substring from the line that looks like this:
<argument>-javaagent:${project.basedir}/../cds-javaagent-agent/target/cds-javaagent-agent-1.0-SNAPSHOT.jar=XXXreturnNull</argument>
After 1 or 2, run the same build again: mvn clean verify
Now, it works without crash, and the created CDS archive 'demo.jsa' can subsequently be used normally.
FREQUENCY : always
On JDKs 20 and 21, the JVM crashes when a java agent is active during CDS archive creation, if
a) the started application calls ManagementFactory.getGarbageCollectorMXBeans() and
b) the class file transformer installed by the agent returns the original class bytes from its 'transform' method.
The error goes away, if the transformer instead returns null, indicating no transformation took place.
The crash does *not* occur on JDKs 13 to 19, but on 20 and 21.
REGRESSION : Last worked in version 19
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Go to https://github.com/kriegaex/cds-javaagent-bug and clone the reproducer Maven project.
2. Run the build on JDK 20 or 21: mvn clean verify
===================================
HOWTO - if your JDK is location at $MYJDK:
- you need to install maven (mvn) and git first, then
$ git clone https://github.com/kriegaex/cds-javaagent-bug
$ cd cds-javaagent-bug
$ PATH=$MYJDK/bin:$PATH JAVA_HOME=$MYJDK mvn -v
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 23-internal, vendor: Oracle Corporation, runtime: /jdk3/bld/pan/images/jdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-33-generic", arch: "amd64", family: "unix"
$ PATH=$MYJDK/bin:$PATH JAVA_HOME=$MYJDK mvn -B -X clean verify 2>&1 | tee log.txt
Then in log.txt, search for "demo.jsa", you will find three occurrences. The second and third occurrences are the command lines to execute to reproduce the error. You need to cut-and-paste, replace "," with a space, and ";" with ":"
This fails with my JDK 23 development build
$ java -classpath /jdk3/tmp/8325536/cds-javaagent-bug/cds-javaagent-test/../cds-javaagent-app/target/cds-javaagent-app-1.0-SNAPSHOT.jar;/jdk3/tmp/8325536/cds-javaagent-bug/cds-javaagent-test/../cds-javaagent-agent/target/cds-javaagent-agent-1.0-SNAPSHOT.jar -XX:+UnlockDiagnosticVMOptions -Xshare:on -XX:ArchiveClassesAtExit=demo.jsa -XX:+AllowArchivingWithJavaAgent -javaagent:/jdk3/tmp/8325536/cds-javaagent-bug/cds-javaagent-test/../cds-javaagent-agent/target/cds-javaagent-agent-1.0-SNAPSHOT.jar=XXXreturnNull dev.aspectj.Application
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (systemDictionaryShared.cpp:575), pid=3019215, tid=3019223
# guarantee(!k->is_shared_unregistered_class()) failed: Class loader type must be set for BUILTIN class java/lang/invoke/BoundMethodHandle$Species_LLLL
#
# JRE version: Java(TM) SE Runtime Environment (23.0) (build 23-internal-adhoc.iklam.pan)
# Java VM: JavaHotSpot(TM) 64-Bit Server VM (23-internal-adhoc.iklam.pan, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0xe8974a] SystemDictionaryShared::validate_before_archiving(InstanceKlass*)+0x21a
#
====================================
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The build passes and the CDS archive is written successfully..
ACTUAL -
The build fails and a hs_err_pid*.log is written, because during phase 'verify' Maven Invoker Plugin tries to run the program with the active java agent, while trying to create a CDS archive.
---------- BEGIN SOURCE ----------
See https://github.com/kriegaex/cds-javaagent-bug
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Two options:
1. Run on JDK 13-19. It works without changes.
2. On JDK 20/21, edit file cds-javaagent-test/pom.xml and remove the "XXX" substring from the line that looks like this:
<argument>-javaagent:${project.basedir}/../cds-javaagent-agent/target/cds-javaagent-agent-1.0-SNAPSHOT.jar=XXXreturnNull</argument>
After 1 or 2, run the same build again: mvn clean verify
Now, it works without crash, and the created CDS archive 'demo.jsa' can subsequently be used normally.
FREQUENCY : always
- duplicates
-
JDK-8325283 crash on exit when using AppCDS with aspectj javaagent
-
- Closed
-