https://github.com/marschall/jfr-crasher
A reproducer for crashing JFR
https://github.com/marschall/jfr-crasher
bug crash java java-flight-recorder
Last synced: about 1 year ago
JSON representation
A reproducer for crashing JFR
- Host: GitHub
- URL: https://github.com/marschall/jfr-crasher
- Owner: marschall
- Created: 2019-11-14T17:12:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-20T10:49:40.000Z (over 6 years ago)
- Last Synced: 2025-01-16T02:45:06.704Z (over 1 year ago)
- Topics: bug, crash, java, java-flight-recorder
- Language: Java
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
JFR Crasher
===========
A reproducer for a crashing JFR bug.
JFR has a crashing bug when multiple threads call `#defineClass` at the same time for the same class on the same classloader. This can happen with a [parallel capable](https://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html) such as [JBoss Modules](http://jboss-modules.github.io/jboss-modules/manual/).
If you are using a class loader similar to this one an using multiple threads you may be affected.
This bug is [JDK-8232997](https://bugs.openjdk.java.net/browse/JDK-8232997) and has been fixed in Java 14. Running with `-XX:-FlightRecorder` does not help.
```java
public class CustomClassLoader extends ClassLoader {
static {
registerAsParallelCapable();
}
@Override
protected Class> loadClass(String className, boolean resolve) throws ClassNotFoundException {
Class> loadedClass = findLoadedClass(className);
if (loadedClass != null) {
if (resolve) {
resolveClass(loadedClass);
}
return loadedClass;
}
Class> clazz;
try {
clazz = defineClass(className, byteCode, 0, byteCode.length);
} catch (LinkageError e) {
// we lost the race, somebody else loaded the class
clazz = findLoadedClass(className);
}
if (resolve) {
resolveClass(clazz);
}
return clazz;
}
}
```