RFR: 8350148: Native stack overflow when writing Java heap objects into AOT cache

Igor Veresov iveresov at openjdk.org
Wed Mar 5 22:38:03 UTC 2025


On Sun, 16 Feb 2025 05:16:17 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> Please review this patch that fixes a problem that was found in the Leyden repo: when finding all cacheable heap objects with recursive calls to `HeapShared::archive_reachable_objects_from()`, very deep reference chains could cause overflow on the native stack. 
> 
> The fix is to do the recursion using a side table, without making any recursive calls.
> 
> Note: the kind of deep reference chains do not seem to happen with the mainline. It happened in the Leyden repo only after we enabled the caching of `WeakReference` objects, which are not cacheable in the mainline.

Looks good

src/hotspot/share/cds/heapShared.cpp line 1351:

> 1349: 
> 1350: // Push all oops that are referenced by _referencing_obj onto the _stack.
> 1351: class HeapShared::ReferentPusher: public BasicOopIterateClosure {

Suggestion:

class HeapShared::ReferentPusher : public BasicOopIterateClosure {

-------------

Marked as reviewed by iveresov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23654#pullrequestreview-2662640308
PR Review Comment: https://git.openjdk.org/jdk/pull/23654#discussion_r1982273300


More information about the hotspot-runtime-dev mailing list