Need help to understand TLS behavior

cheleswer sahu cheleswer.sahu at
Mon Dec 14 12:34:14 UTC 2015


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

  ThreadFactory threadFactory = grimReaper -> {
                 // Our thread stack requirement is quite modest.
                 Thread t = new Thread(systemThreadGroup, grimReaper,
                                       "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 t = new Thread(systemThreadGroup, grimReaper,
                                       "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.


More information about the core-libs-dev mailing list