On Mon, 30 Mar 2026 20:10:14 GMT, Chris Plummer <[email protected]> wrote:
> First it helpful to know that for hprof files, every java object is given an > ObjectID, and that id is simply the address of the java object in the java > heap. SA does the following to write a field that is reference type into the > hprof file: > > > OopHandle handle = ((OopField)field).getValueAsOopHandle(oop); > writeObjectID(getAddressValue(handle)); > > > The only validation it does is to make sure the address of the field is > valid. Note I'm referring to the address of the field itself, not the address > (oop) stored in the field. If the field is flattened, it may no longer have > an 8-byte alignment requirement. But getAddressValue(handle) does. So if the > field is not 8-byte aligned we get the UnalignedAddressException and you see > in the stack trace that is happening in all of the heap dumping test. If it > is 8-byte aligned, then the contents are just blindly loaded and treated as > an oop, which then gets written as an (invalid) ObjectID into the hprof file. > It then turns up as the hprof verification error that you see in > [JDK-8377387](https://bugs.openjdk.org/browse/JDK-8377387): > > WARNING: Failed to resolve object id 0x10000 for field isRegularFile > (signature L) > > The fix is to not write the (invalid) ObjectID if the field has been > flattened, and instead just write the ObjectID for null as if the field > actually contained a null. This gets us around the issues that cause test > failures, but eventually we need to properly handle the flattened field and > write its scalar contents to the hprof file. I'll file a separate CR for that. > > Tested using --enable-preview with all tier1, tier2 svc, and tier5 svc. This pull request has now been integrated. Changeset: f31be3fb Author: Chris Plummer <[email protected]> URL: https://git.openjdk.org/valhalla/commit/f31be3fba4feecfbc5d44fb1c9a1f0885b7f8e8a Stats: 14 lines in 4 files changed: 5 ins; 8 del; 1 mod 8379925: [lworld] Several SA HeapDump tests fail with `Unrecognized heap dump sub-record type: XX` with --enable-preview 8377387: [lworld] serviceability/sa/TestHeapDumpForInvokeDynamic.java test fails with --enable-preview Reviewed-by: sspitsyn ------------- PR: https://git.openjdk.org/valhalla/pull/2280
