RFR: 8365317: ZGC: Setting ZYoungGCThreads lower than ZOldGCThreads may result in a crash
Joel Sikström
jsikstro at openjdk.org
Tue Aug 12 12:48:23 UTC 2025
Hello,
Setting ZYoungGCThreads lower than ZOldGCThreads may result in a crash, for example using `-XX:ZYoungGCThreads=4` and `-XX:ZOldGCThreads=8`. The problem is in `select_worker_threads()` in zDirector.cpp, where the number of young threads may be set to the number of old threads in an attempt to speed up the young collection so that the old collection can begin faster in a major collection. If the number of old threads exceed the maximum number of young threads, i.e. ZYoungGCThreads, a crash may occur. See the JBS issue for details on the crash.
Even though it may not be common, or reasonable in all scenarios, to set the maximum number of young threads to less than the maximum number of old threads, the combination should be possible and not result in a crash. To solve this issue, I suggest we clamp or otherwise limit the number of young threads to the maximum amount of young threads (i.e., `ZYoungGCThreads`).
Testing:
* I will run this through Oracle's testing.
* I can no longer observe the intermittent crashes in release builds after 1000 runs.
-------------
Commit messages:
- 8365317: ZGC: Setting ZYoungGCThreads lower than ZOldGCThreads may result in a crash
Changes: https://git.openjdk.org/jdk/pull/26745/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26745&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8365317
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/26745.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26745/head:pull/26745
PR: https://git.openjdk.org/jdk/pull/26745
More information about the hotspot-gc-dev
mailing list