Skip to content

marschall/jfr-crasher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 such as JBoss Modules.

If you are using a class loader similar to this one an using multiple threads you may be affected.

This bug is JDK-8232997 and has been fixed in Java 14. Running with -XX:-FlightRecorder does not help.

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;
  }

}

Releases

No releases published

Packages

No packages published

Languages