JDK-8316968 : Add an option that allows to set the stack size of Process reaper threads
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P3
  • Status: New
  • Resolution: Unresolved
  • OS: linux
  • Submitted: 2023-09-26
  • Updated: 2023-09-29
Related Reports
Relates :  
Description
A reaper thread gets created when java.lang.ProcessBuilder API is used to create a new process. By default, reaper threads are created with a stack size of 128K.

50 final class ProcessHandleImpl implements ProcessHandle {
51      /**
52       * Default size of stack for reaper processes.
53       */
54      private static long REAPER_DEFAULT_STACKSIZE = 128 * 1024;

However, when a large TLS (Thread local storage) size is used (example: when JVM is created from JNI code and TLS is declared using "__thread"), reaper threads can encounter stack overflow error and can cause the JVM to hang.

The change for https://bugs.openjdk.org/browse/JDK-8130425 added a property -Djdk.lang.processReaperUseDefaultStackSize, which when set to true allows reaper threads to use the system default stack size rather than the hardcoded 128K.

However, this property does not provide the flexibility to set the stack size for reaper threads. It will be good to have a way for the users to set the stack size of reaper threads to a specific value. For example, -XX:ReaperThreadStackSize=n.