<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
<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;">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;">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;">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>
</body>
</html>