Comment 41 for bug 1757517

Revision history for this message
In , Bugdal (bugdal) wrote :

For what it's worth, the strategy we're using in musl seems to work well:

1. For implementation-allocated stacks, the requested size is always available to the application. TLS and guard size are added onto that for the allocation.

2. For application-provided stacks, if the size of TLS is greater than 2k or greater than 1/8 of the provided stack space, additional space for the TCB/TLS/etc. is allocated and the provided stack is used only for actual stack. This ensures that application expectations are met: automatic variables in the thread have addresses in the specified range, and the amount of stack space available is "close enough" to what the application requested that, if it overflows, it's reasonable to say it's the application's fault for not leaving a better margin of error.

I'm not sure how easy it would be to make glibc/NPTL use separate regions for the stack and TLS though...