JDK-8227417 : Release Note: Added -XX:+AdjustStackSizeForTLS Flag
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 14
  • Priority: P4
  • Status: Closed
  • Resolution: Delivered
  • Submitted: 2019-07-08
  • Updated: 2020-04-27
  • Resolved: 2019-12-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 14
14Resolved
Description
The `glibc` library allocates some thread-local storage (TLS) in the stack of a newly created thread, leaving less stack than requested for the thread to do its work. This is particularly a problem for threads with small stack sizes. It is an inherited issue from a well-known `glibc` problem, 'Program with large TLS segments fail' [0] and has been observed in Java applications. In one of the reported JVM failure instances, the issue manifests as a `StackOverflowError` on the process reaper thread, which has a small stack size. The `java.lang.Thread` constructor enables users to specify the stack size for a new thread. The created thread may encounter the TLS problem when the specified size is too small to accommodate the on-stack TLS blocks.

In JDK 8, a system property, `jdk.lang.processReaperUseDefaultStackSize`, was introduced to address the TLS issue only for reaper threads. Setting the property gives a bigger stack size to the reaper threads.

To address the issue for all threads, a general purpose workaround was implemented in Java which adjusts thread stack size for TLS. It can be enabled by using the `AdjustStackSizeForTLS` command-line option:

` -XX:+AdjustStackSizeForTLS`

When creating a new thread, if `AdjustStackSizeForTLS` is true, the static TLS area size is added to the user requested stack size. `AdjustStackSizeForTLS` is disabled by default.

Reference:
[0] [Bug 11787 - Program with large TLS segments fail](https://sourceware.org/bugzilla/show_bug.cgi?id=11787)