<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>I filed a bug for this issue and pushed a fixed to the "premain"
      branch</p>
    <p><a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8335492">https://bugs.openjdk.org/browse/JDK-8335492</a> "Some hidden classes
      are not archived for ArchiveInvokeDynamic"</p>
    <p>Thanks</p>
    <p>- Ioi<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 6/28/24 7:21 PM, <a class="moz-txt-link-abbreviated" href="mailto:ioi.lam@oracle.com">ioi.lam@oracle.com</a>
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:d7dc8954-8f10-475f-bb2a-7d996efe20cc@oracle.com">
      
      <p><font face="monospace">FYI<br>
        </font></p>
      <p><font face="monospace">I am working on a related problem where
          some hidden classes are incorrectly excluded. They have names
          that look like:</font></p>
      <p><font face="monospace">io/vertx/core/impl/VertxImpl$$InjectedInvoker+0x8000000c6<br>
java/util/logging/Level$KnownLevel$$InjectedInvoker+0x800000028<br>
        </font></p>
      <p><font face="monospace">or<br>
          <br>
org/openjdk/bench/java/lang/StringConcat$$StringConcat+0x800000022<br>
        </font></p>
      <p><font face="monospace">The root cause is different than what
          Ashutosh reported -- we have resolved CP entries that
          transitively point to Method* of hidden classes. So far this
          problem is not reproducible with existing test cases in the
          premain branch. I am testing a fix now.</font></p>
      <p><font face="monospace">Thanks</font></p>
      <p><font face="monospace">- Ioi<br>
        </font></p>
      <p><font face="monospace"><br>
        </font></p>
      <div class="moz-cite-prefix"><font face="monospace">On 6/27/24
          8:14 PM, Ashutosh Mehra wrote:<br>
        </font></div>
      <blockquote type="cite" cite="mid:CAKt0pyR698qrOewyzmJmZHrfuzFfu=BwUMWtdO1XHKtHOPwzYw@mail.gmail.com">
        <div dir="ltr"><font face="monospace">I encountered a crash when
            dumping the cds map with 1-step workflow.</font>
          <div><font face="monospace">The crash happens in the forked
              JVM during the assembly phase of the training run.</font></div>
          <div><font face="monospace">To recreate the crash, execute the
              training run
              with -Xlog:cds+map=trace:file=cds.map:none:filesize=0
              option.</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">#<br>
              # A fatal error has been detected by the Java Runtime
              Environment:<br>
              #<br>
              #  SIGSEGV (0xb) at pc=0x00007f4e8a209cb6, pid=152509,
              tid=152510<br>
              #<br>
              # JRE version: OpenJDK Runtime Environment (23.0)
              (slowdebug build 23-internal-adhoc.asmehra.leyden)<br>
              # Java VM: OpenJDK 64-Bit Server VM (slowdebug
              23-internal-adhoc.asmehra.leyden, mixed mode, sharing,
              tiered, compressed oops, compressed class ptrs, g1 gc,
              linux-amd64)<br>
              # Problematic frame:<br>
              # V  [libjvm.so+0x409cb6]  Klass::is_instance_klass()
              const+0x10<br>
              #<br>
              # Core dump will be written. Default location:
/home/asmehra/data/ashu-mehra/leyden/test/hotspot/jtreg/premain/quarkus-getting-started/core.152509<br>
              #<br>
              # An error report file with more information is saved as:<br>
              #
/home/asmehra/data/ashu-mehra/leyden/test/hotspot/jtreg/premain/quarkus-getting-started/hs_err_pid152509.log<br>
              #<br>
              # If you would like to submit a bug report, please visit:<br>
              #   <a href="https://bugreport.java.com/bugreport/crash.jsp" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">https://bugreport.java.com/bugreport/crash.jsp</a><br>
              #<br>
              [75.250s][error  ][cds] Child process finished; status =
              134<br>
              <br>
            </font></div>
          <div><font face="monospace">Backtrace for the crashing thread:</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">#11 0x00007f4e8a209cb6 in
              Klass::is_instance_klass (this=0x0) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/oops/klass.hpp:683<br>
              #12 0x00007f4e8afa8894 in Klass::external_name (this=0x0)
              at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/oops/klass.cpp:905<br>
              #13 0x00007f4e8b126447 in Method::print_external_name
              (os=0x7f4e89dfd130, klass=0x0, method_name=0x8011e8588,
              signature=0x8011ab858) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/oops/method.cpp:228<br>
              #14 0x00007f4e8b1263b6 in Method::external_name
              (klass=0x0, method_name=0x8011e8588,
              signature=0x8011ab858) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/oops/method.cpp:222<br>
              #15 0x00007f4e8b1262e1 in Method::external_name
              (this=0x800fd1920) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/oops/method.cpp:213<br>
              #16 0x00007f4e8a492b0d in
              ArchiveBuilder::CDSMapLogger::log_method (m=0x800fd1920,
              runtime_dest=0x801039cd8 "", type_name=0x7f4e8b7d40fc
              "Method", bytes=128, current=0x7f4e8401d900)<br>
                  at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/cds/archiveBuilder.cpp:1194<br>
              #17 0x00007f4e8a492d66 in
              ArchiveBuilder::CDSMapLogger::log_metaspace_objects
              (region=0x7f4e89dfe740, src_objs=0x7f4e89dfe860) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/cds/archiveBuilder.cpp:1228<br>
              #18 0x00007f4e8a492a2b in
              ArchiveBuilder::CDSMapLogger::log_metaspace_region
              (name=0x7f4e8b7d8af0 "rw region", region=0x7f4e89dfe740,
              src_objs=0x7f4e89dfe860) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/cds/archiveBuilder.cpp:1182<br>
              #19 0x00007f4e8a4940f4 in
              ArchiveBuilder::CDSMapLogger::log (builder=0x7f4e89dfe630,
              mapinfo=0x7f4e85017bb0, heap_info=0x7f4e89dfd4f0,
              bitmap=0x7f4e857bf850
              "\t\222\004I\222$\t\210\210\210\001\b\200",
              bitmap_size_in_bytes=655824)<br>
                  at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/cds/archiveBuilder.cpp:1502<br>
              #20 0x00007f4e8a48f2a5 in ArchiveBuilder::write_archive
              (this=0x7f4e89dfe630, mapinfo=0x7f4e85017bb0,
              heap_info=0x7f4e89dfd4f0) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/cds/archiveBuilder.cpp:1560<br>
              #21 0x00007f4e8b11d249 in
              MetaspaceShared::write_static_archive
              (builder=0x7f4e89dfe630, mapinfo=0x7f4e85017bb0,
              heap_info=0x7f4e89dfd4f0) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/cds/metaspaceShared.cpp:988<br>
              #22 0x00007f4e8b11d1ac in
              MetaspaceShared::preload_and_dump_impl (builder=...,
              __the_thread__=0x7f4e8401d900) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/cds/metaspaceShared.cpp:976<br>
              #23 0x00007f4e8b11c5fd in
              MetaspaceShared::preload_and_dump () at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/cds/metaspaceShared.cpp:767<br>
              #24 0x00007f4e8b53bca2 in Threads::create_vm
              (args=0x7f4e89dfedd0, canTryAgain=0x7f4e89dfecd3) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/runtime/threads.cpp:900<br>
              #25 0x00007f4e8ada2821 in JNI_CreateJavaVM_inner
              (vm=0x7f4e89dfee20, penv=0x7f4e89dfee28,
              args=0x7f4e89dfedd0) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/prims/jni.cpp:3581<br>
              #26 0x00007f4e8ada2c81 in JNI_CreateJavaVM
              (vm=0x7f4e89dfee20, penv=0x7f4e89dfee28,
              args=0x7f4e89dfedd0) at
/home/asmehra/data/ashu-mehra/leyden/src/hotspot/share/prims/jni.cpp:3672<br>
              #27 0x00007f4e8ce0f84f in InitializeJVM
              (pvm=0x7f4e89dfee20, penv=0x7f4e89dfee28,
              ifn=0x7f4e89dfee70) at
/home/asmehra/data/ashu-mehra/leyden/src/java.base/share/native/libjli/java.c:1550</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">Checking up the CDS map generated
              for the cds preimage shows some methods for which their
              InstanceKlass is null. </font></div>
          <div><font face="monospace">This results in the crash seen
              above when such methods are printed as part of the CDS map
              file during the assembly phase.</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">These methods are of the form:</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">java.lang.Object
              java.lang.invoke.LambdaForm$MH/0x800000090.invoke(java.lang.Object,
              java.lang.Object)<br>
            </font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">Interestingly -Xlog:cds=info shows
              such classes are skipped when generating the preimage as
              they are hidden classes:</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">Skipping
              java/lang/invoke/LambdaForm$MH+0x800000090: Hidden class<br>
            </font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">In the CDS map file for the
              preimage I also noticed that such methods are only
              referenced through MethodTrainingData -> _final_profile
              -> _method.<br>
              So it looks like although we excluded such classes from
              the CDS archive, we don't exclude their training data.<br>
              There is code for cleaning up the training data [0] , but
              it doesn't remove the training data for classes that have
              been excluded, unless I misunderstood the code.<br>
              Not sure if it is intentional or a bug.<br>
            </font></div>
          <div><font face="monospace">If we do need to keep the training
              data for such methods, then we would need to handle the
              case of null InstanceKlass in the CDSMapLogger to avoid
              crashing.</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">[0] <a href="https://github.com/openjdk/leyden/blob/8716f47ef49c829e2384474577ff468a732b9c66/src/hotspot/share/oops/trainingData.cpp#L573" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/leyden/blob/8716f47ef49c829e2384474577ff468a732b9c66/src/hotspot/share/oops/trainingData.cpp#L573</a><br>
            </font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">Thanks,<br>
            </font>
            <div>
              <div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
                <div dir="ltr"><font face="monospace">- Ashutosh Mehra</font></div>
              </div>
            </div>
          </div>
        </div>
      </blockquote>
    </blockquote>
  </body>
</html>