<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Hi Anton,</p>
    <p>Thanks for the bug report. I have created
      <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8377512">https://bugs.openjdk.org/browse/JDK-8377512</a></p>
    <p>(I am not sure if you have permission to edit the bug, but I
      think some of your colleagues at Azul should have permission).</p>
    <p>Do you have more information, such as an hs_err file?</p>
    <p>My guess is we have a ResolvedMethodName object that points to a
      method of an excluded class</p>
    <p>void HeapShared::mark_native_pointers(oop orig_obj) {<br>
        if (java_lang_Class::is_instance(orig_obj)) {<br>
          ArchiveHeapWriter::mark_native_pointer(orig_obj,
      java_lang_Class::klass_offset());<br>
          ArchiveHeapWriter::mark_native_pointer(orig_obj,
      java_lang_Class::array_klass_offset());<br>
        } else if
      (java_lang_invoke_ResolvedMethodName::is_instance(orig_obj)) {<br>
          ArchiveHeapWriter::mark_native_pointer(orig_obj,
      java_lang_invoke_ResolvedMethodName::vmtarget_offset());<br>
        }<br>
      }</p>
    <p>However, we should exclude all resolved lambda sites that
      reference an excluded class. As a result, we should never archive
      such a ResolvedMethodName:</p>
    <p> 0 AOTConstantPoolResolver::check_methodtype_signature <br>
       1
      AOTConstantPoolResolver::check_lambda_metafactory_methodtype_arg <br>
       2 AOTConstantPoolResolver::is_indy_resolution_deterministic <br>
       3 AOTConstantPoolResolver::is_resolution_deterministic <br>
       4
      ConstantPoolCache::remove_resolved_indy_entries_if_non_deterministic <br>
       5 ConstantPoolCache::remove_unshareable_info <br>
       6 ConstantPool::remove_unshareable_entries <br>
       7 ConstantPool::remove_unshareable_info <br>
       8 ArchiveBuilder::make_klasses_shareable <br>
       9 VM_PopulateDumpSharedSpace::doit <br>
      10 VM_Operation::evaluate <br>
    </p>
    <p>We have test cases in here:</p>
    <p>LambdaContainsOldInf.java:               
      output.shouldMatch("Cannot aot-resolve Lambda proxy because
      OldProvider is excluded");<br>
      resolvedConstants/ResolvedConstants.java:             
       .shouldContain("Cannot aot-resolve Lambda proxy of interface type
      InterfaceWithClinit")<br>
      resolvedConstants/AOTLinkedLambdas.java:       
      dumpOut.shouldContain("Can aot-resolve Lambda proxy of interface
      type IA");</p>
    <p>If you can find a way to reproduce the problem it would be great.
      You can find more information about the failure with this:</p>
    <p>diff --git a/src/hotspot/share/cds/archiveHeapWriter.cpp
      b/src/hotspot/share/cds/archiveHeapWriter.cpp<br>
      index ee1e334e84b..7f68e648431 100644<br>
      --- a/src/hotspot/share/cds/archiveHeapWriter.cpp<br>
      +++ b/src/hotspot/share/cds/archiveHeapWriter.cpp<br>
      @@ -754,6 +754,14 @@ void
      ArchiveHeapWriter::compute_ptrmap(ArchiveHeapInfo* heap_info) {<br>
           Metadata** buffered_field_addr =
      requested_addr_to_buffered_addr(requested_field_addr);<br>
           Metadata* native_ptr = *buffered_field_addr;<br>
           guarantee(native_ptr != nullptr, "sanity");<br>
      +    if
      (!ArchiveBuilder::current()->has_been_buffered((address)native_ptr))
      {<br>
      +      ResourceMark rm;<br>
      +      tty->print_cr("Marking native pointer for oop %p (type =
      %s, offset = %d)",<br>
      +                    cast_from_oop<void*>(src_obj),
      src_obj->klass()->external_name(), field_offset);<br>
      +      src_obj->print_on(tty);<br>
      +      tty->cr();<br>
      +    }<br>
      +<br>
      <br>
    </p>
    <p>Thanks</p>
    <p>- Ioi</p>
    <div class="moz-cite-prefix">On 2/9/26 7:24 AM, Anton Voznia wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:DM4PR11MB77604617D519C2130CDD373FD365A@DM4PR11MB7760.namprd11.prod.outlook.com">
      
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">Hi
          all,</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">I
          have a question about a potential bug in AOT heap archiving.</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">We
          observe a crash (guarantee failure) while creating the AOT
          cache with JDK 25, at:</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 120, 212);"><u><a href="https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/archiveHeapWriter.cpp#L757" title="https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/archiveHeapWriter.cpp#L757" data-outlook-id="478c3444-d29e-46a5-bb6f-6c2e670312c6" style="color: rgb(0, 120, 212); margin-top: 0px; margin-bottom: 0px;" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/archiveHeapWriter.cpp#L757</a></u></span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">The
          failure happens because:</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">get_buffered_addr(src_addr)
          == nullptr</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">What
          means that a native pointer is present in _native_pointers but
          there is no corresponding buffered address, even though the
          SourceObjInfo was successfully added to _src_obj_table.</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">The
          failing check is:</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">guarantee(ArchiveBuilder::current()->has_been_buffered((address)native_ptr),</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
                  "Metadata %p should have been archived", native_ptr);</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">further
          investigation showed that we collect pointers into
          _native_pointers without checking whether the corresponding
          class was excluded (via class exclusion or link-time
          verification failures):</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 120, 212);"><u><a href="https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/heapShared.cpp#L308" title="https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/heapShared.cpp#L308" data-outlook-id="35991546-7537-4d67-85fc-c7377ca863a3" style="color: rgb(0, 120, 212); margin-top: 0px; margin-bottom: 0px;" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/heapShared.cpp#L308</a></u></span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">However,
          the SourceObjInfo::_buffered_addr seems to be assigned only
          for objects that are actually copied (i.e., not excluded).</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">In
          particular, this SourceObjInfo didn’t end up in _ro_src_objs
          or _rw_src_objs because it didn’t satisfy the following
          condition:</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 120, 212);"><u><a href="https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/archiveBuilder.cpp#L467" title="https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/archiveBuilder.cpp#L467" data-outlook-id="95b7cde7-41af-4767-a2f7-14fcc4bf6292" style="color: rgb(0, 120, 212); margin-top: 0px; margin-bottom: 0px;" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/openjdk/jdk25u-dev/blob/40ec273de548b47fc08d02bbe7c1cb3b48ebad17/src/hotspot/share/cds/archiveBuilder.cpp#L467</a></u></span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
          if (created && src_info.should_copy()) {</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
            if (read_only) {</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
              _ro_src_objs.append(p);</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
            } else {</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
              _rw_src_objs.append(p);</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
            }</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
            return true; // Need to recurse into this ref only if we are
          copying it</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"> 
          }</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">created
          is true (object exists in _src_obj_table), but
          src_info.should_copy() is false because _follow_mode is
          set_to_null (not make_a_copy).</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">So
          it looks like we may end up with an item in _native_pointers
          for which we will never assign a buffered address.</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">However,
          later we expect every item in _native_pointers to have one
          buffered address.</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">Is
          this logic correct, or am I missing a step that guarantees
          buffering for all _native_pointers items?</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">It
          seems, we have to check for a class exclusion before adding
          into _native_pointers.</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">Unfortunately,
          I wasn’t able to reproduce the issue locally.</span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px; min-height: 15px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);"><br>
        </span></p>
      <p style="text-align: left; text-indent: 0px; line-height: normal; text-transform: none; margin: 0px;">
        <span style="font-family: "Helvetica Neue"; font-size: 13px; color: rgb(0, 0, 0);">Thanks
          and best regards,<br>
          Anton Voznia</span></p>
      <div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
        <br>
      </div>
      <div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
        <br>
      </div>
    </blockquote>
  </body>
</html>