RFR: 8365317: ZGC: Setting ZYoungGCThreads lower than ZOldGCThreads may result in a crash

Thomas Schatzl tschatzl at openjdk.org
Tue Aug 12 13:00:11 UTC 2025


On Tue, 12 Aug 2025 12:35:57 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

> 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.

Marked as reviewed by tschatzl (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/26745#pullrequestreview-3110491401


More information about the hotspot-gc-dev mailing list