Hi,
I am investigating an issue, in which test with TLS size set to 32K is
failing with StackOverFlowError. During investigation I found the below
code
/jdk8u-cpu <https://java.se.oracle.com/source/xref/jdk8u-cpu/>/jdk
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/>/src
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/>/solaris
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/>/classes
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/>/java
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/java/>/lang
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/java/lang/>/UNIXProcess.java
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/java/lang/UNIXProcess.java>
227
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/java/lang/UNIXProcess.java#227> ThreadFactory
<https://java.se.oracle.com/source/s?defs=ThreadFactory&project=jdk8u-cpu> threadFactory
<https://java.se.oracle.com/source/s?defs=threadFactory&project=jdk8u-cpu> =grimReaper
<https://java.se.oracle.com/source/s?defs=grimReaper&project=jdk8u-cpu> -> {
228
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/java/lang/UNIXProcess.java#228> // Our thread stack requirement is quite modest.
229
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/java/lang/UNIXProcess.java#229> Thread <https://java.se.oracle.com/source/s?defs=Thread&project=jdk8u-cpu> t =*new* Thread <https://java.se.oracle.com/source/s?defs=Thread&project=jdk8u-cpu>(systemThreadGroup
<https://java.se.oracle.com/source/s?defs=systemThreadGroup&project=jdk8u-cpu>,grimReaper
<https://java.se.oracle.com/source/s?defs=grimReaper&project=jdk8u-cpu>,
230
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/java/lang/UNIXProcess.java#230> "process reaper",32768);
Here reaper thread is created with fixed stack size "32768 ", which
causes StackOverFlowError when TLS is set to 32k around.
If I remove this fixed size and make it default, test works fine.
Thread <https://java.se.oracle.com/source/s?defs=Thread&project=jdk8u-cpu> t =*new* Thread <https://java.se.oracle.com/source/s?defs=Thread&project=jdk8u-cpu>(systemThreadGroup
<https://java.se.oracle.com/source/s?defs=systemThreadGroup&project=jdk8u-cpu>,grimReaper
<https://java.se.oracle.com/source/s?defs=grimReaper&project=jdk8u-cpu>,
230
<https://java.se.oracle.com/source/xref/jdk8u-cpu/jdk/src/solaris/classes/java/lang/UNIXProcess.java#230> "process reaper");
I have run several test with TLS size 32k , 64k ,128k and more .
The interesting part, it works well with 64k and 128k TLS size but not with 32k.
So my questions are as follows:
What is the motivation behind the fixed thread stack size ?
will it be ok to replace the fixed stack size with default or stack size
setting is platform sensitive?
How TLS sizes are interpreted internally, which allows 64k and 128k to work but
not to 32k ?
I would really appreciate, if anyone have any opinion on this.
Regards,
Cheleswer