emscripten-core / emscripten-core/emscripten
musl default pthread stack stack does not match DEFAULT_PTHREAD_STACK_SIZE
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
We have a build setting called `DEFAULT_PTHREAD_STACK_SIZE` (default to 2Mb) which kicks in when a thread is created without any attributes.
However if one create a default set of attributes using `pthread_attr_init` musl will configure it with its own internal default which is 80k: https://github.com/emscripten-core/emscripten/blob/592dec1c71516c3c7535443e6d88ff5ad28db304/system/lib/libc/musl/src/internal/pthread_impl.h#L182
Possible solutions:
1. Have musl call back out the JS to know the actual default desired by the user (not know at libc compile time)
2. Remove `DEFAULT_PTHREAD_STACK_SIZE` and users who want a custom stack size can do so programmatically using `pthread_attr_setstacksize`
3. Set musl's `DEFAULT_STACK_SIZE` to match the default `DEFAULT_PTHREAD_STACK_SIZE` so most users will never notice (only users who override `DEFAULT_PTHREAD_STACK_SIZE` would see this behaviour).
(3) is the safest thing to do right away which will fix at least one know issue I found in the lsan codebase.
Contributor guide
Assessment
This issue has not been assessed yet.