RFR: 8375314: Parallel: Crash iterating over unloaded classes for ObjectCountAfterGC event [v2]

Thomas Schatzl tschatzl at openjdk.org
Wed Jan 21 16:32:21 UTC 2026


> Hi all,
> 
>   please review this change that avoids crashes when gathering `ObjectCountAfterGC` JFR statisics.
> 
> The cause for the crash is that the code purges metaspace after class unloading/purging after https://bugs.openjdk.org/browse/JDK-8361404. The heap iteration code walks the heap with classes that were unloaded and purged, eventually crashing if for some reason the data is invalid due to metaspace purging potentially uncommitting memory.
> 
> Since it is somewhat ugly that we walk objects with dead klasses in them (as it was before the mentioned change), I moved the iteration to after the heap has been compacted, skipping filler objects that might be in there.
> 
> Unfortunately I did not manage to write a good reproducer.
> 
> Testing: gha, tier1-5, test case succeeding
> 
> Thanks,
>   Thomas

Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:

  * remove WhiteBox references from test, not needed any more

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/29318/files
  - new: https://git.openjdk.org/jdk/pull/29318/files/16118b68..595e04b1

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29318&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29318&range=00-01

  Stats: 8 lines in 1 file changed: 0 ins; 7 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/29318.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29318/head:pull/29318

PR: https://git.openjdk.org/jdk/pull/29318


More information about the hotspot-gc-dev mailing list