RFR: 8225035: Thread stack size issue caused by large TLS size

Florian Weimer fweimer at redhat.com
Wed Jun 26 15:05:29 UTC 2019


* Thomas Stüfe:

> Hi Florian,
>
> On Wed, Jun 26, 2019 at 4:47 PM Florian Weimer <fweimer at redhat.com> wrote:
>
>  * Thomas Stüfe:
>
>  > About the attr pointer to pthread_get_minstack(): Since this function
>  > is undocumented, we have no idea what it does to attr. We know that
>  > the implementation Florian posted seems not to do anything with it,
>  > but is that true for all glibc implementations, over all past versions
>  > we want to function on, and on all platforms?
>
>  Ahh, sorry, you are right.  The historic implementation looks like this:
>
>  size_t
>  __pthread_get_minstack (const pthread_attr_t *attr)
>  {
>    struct pthread_attr *iattr = (struct pthread_attr *) attr;
>
>    return (GLRO(dl_pagesize) + __static_tls_size + PTHREAD_STACK_MIN
>           + iattr->guardsize);
>  }
>
>  So you need to pass the attribute you use during thread creation.
>
> But we have not yet called pthread_attr_setguardsize() by the time we
> call __pthread_get_minstack. So attr contains whatever is the default
> set by pthread_attr_init(). Also, some lines below we add the guard
> size manually to the stack size, for similar reasons we now want to
> add the TLS size...
>
> All this outguessing the glibc makes my head hurt :)

Hmm.  I think you should set the guard size first, then call
__pthread_get_minstack, and then set the stack size.  I think that
should work.

>  __pthread_get_minstack was changed when once the guardsize was no longer
>  subtracted from the available stack size, so you should not subtract the
>  guard size in OpenJDK, only sysconf (_SC_PAGESIZE) and
>  PTHREAD_STACK_MIN.
>
> Which versions of glibc have this historic implementation? Do we need
> to care?

Yes, they still matter.

Thanks,
Florian


More information about the hotspot-runtime-dev mailing list