bpo-32307: thread: fix stack size on musl platforms. by ericonr · Pull Request #26224 · python/cpython (original) (raw)

Python/thread_pthread.h hardcodes "known good" thread stack sizes for
several platforms it knows about, and assumes all other platforms will
follow glibc's behavior of allocating big enough thread stacks.

Instead, we force a default value of 2MB (much bigger than musl's 128kB
default) which should be safe on most platforms, and override it for the
specific platforms which need even more (or less, as in vxworks's case).
This also allows us to remove AIX's special case, since it now matches
the default.

Instead of hardcoding yet more values here, users should be encouraged
to set their own using CFLAGS. Alternatively, they can set
THREAD_STACK_SIZE to 0 and use the platform's default.

This way, test_threading no longer crashes on musl systems.

Since we are here, it is not necessary to check if THREAD_STACK_SIZE is
defined in this part of the header, because the first few lines after
'#ifdef _POSIX_THREAD_ATTR_STACKSIZE' ensure it's always defined.

https://bugs.python.org/issue32307