RFR: 8373096: JFR leak profiler: path-to-gc-roots search should be non-recursive [v5]
Thomas Stuefe
stuefe at openjdk.org
Wed Dec 17 09:55:04 UTC 2025
> A customer reported a crash when producing a JFR recording with `path-to-gc-roots=true`. It was a native stack overflow that occurred during the recursive path-to-gc-root search performed in the context of PathToGcRootsOperation.
>
> We try to avoid this by limiting the maximum search depth (DFSClosure::max_dfs_depth). That solution is brittle, however, since recursion depth is not a good proxy for thread stack usage: it depends on many factors, e.g., compiler inlining decisions and platform specifics. In this case, the VMThread's stack was too small.
>
> This RFE changes the algorithm to be non-recursive.
>
> Note that as a result of this change, the order in which oop maps are walked per oop is reversed : last oops are processed first. That should not matter for the end result, however. The search is still depth-first.
>
> Note that after this patch, we could easily remove the max_depth limitation altogether. I left it in however since this was not the scope of this RFE.
>
> Testing:
>
> - Tested manually with very small (256K) thread stack size for the VMThread - the patched version works where the old version crashes out
> - Compared JFR recordings from both an unpatched version (with a large enough VMThread stack size) and a patched version; made sure that the content of "Old Object Sample" was identical
> - Ran locally all jtreg tests in jdk/jfr
> - GHAs
Thomas Stuefe has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:
- Merge branch 'master' into JFR-leak-profiler-path-to-gc-roots-non-recursive
- final fixes
- revert accidental checkin
- test improvements
- fix
- remove test output
- Copyright
- start
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/28659/files
- new: https://git.openjdk.org/jdk/pull/28659/files/73497c30..10bc510b
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=28659&range=04
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=28659&range=03-04
Stats: 45414 lines in 841 files changed: 30528 ins; 10541 del; 4345 mod
Patch: https://git.openjdk.org/jdk/pull/28659.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28659/head:pull/28659
PR: https://git.openjdk.org/jdk/pull/28659
More information about the hotspot-jfr-dev
mailing list