JFR: TypeLibrary class not thread safe

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 21
    • Affects Version/s: 11, 17, 21
    • Component/s: hotspot
    • None
    • jfr
    • b14

      The TypeLibrary class is not properly protected from concurrent access. This can happen when creating dynamic events. A typical exception can look like this:

      Exception in thread "main" java.lang.ExceptionInInitializerError
        at jdk.jfr/jdk.jfr.EventFactory.create(EventFactory.java:169)
      ...
      Caused by: java.lang.ArrayIndexOutOfBoundsException\cf2 : Index 233 out of bounds for length 233
        at java.base/java.util.LinkedHashMap.valuesToArray(LinkedHashMap.java:555)
        at java.base/java.util.LinkedHashMap$LinkedValues.toArray(LinkedHashMap.java:635)
        at java.base/java.util.ArrayList.<init>(ArrayList.java:181)
        at jdk.jfr/jdk.jfr.internal.TypeLibrary.getTypes(TypeLibrary.java:122)
        at jdk.jfr/jdk.jfr.internal.MetadataRepository.initializeJVMEventTypes(MetadataRepository.java:74)
        at jdk.jfr/jdk.jfr.internal.MetadataRepository.<init>(MetadataRepository.java:69)
        at jdk.jfr/jdk.jfr.internal.MetadataRepository.<clinit>(MetadataRepository.java:56)

      Normally all access to metadata requires the "metadata lock", but there are some exceptions. Problem is that the TypeLibrary can't depend on MetadataRepository class without a recursion. Some of this dealt with by using the TypeLibrary class lock, but not in all places.

            Assignee:
            Erik Gahlin
            Reporter:
            Erik Gahlin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: