From 8c1a6237d2b0e869e717b153078c7b6cc86cb216 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 16 Jun 2026 14:28:43 +0200 Subject: [PATCH] gh-151542: Use at least 2 MiB stack size, instead of 1 MiB Python needs at least 2 MiB stack to run test_threading on Free Threading. --- .../Build/2026-06-16-14-30-41.gh-issue-151542.QrLE0K.rst | 3 +++ configure | 4 ++-- configure.ac | 9 +++++---- 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2026-06-16-14-30-41.gh-issue-151542.QrLE0K.rst diff --git a/Misc/NEWS.d/next/Build/2026-06-16-14-30-41.gh-issue-151542.QrLE0K.rst b/Misc/NEWS.d/next/Build/2026-06-16-14-30-41.gh-issue-151542.QrLE0K.rst new file mode 100644 index 000000000000000..ee17827fd526b2f --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-06-16-14-30-41.gh-issue-151542.QrLE0K.rst @@ -0,0 +1,3 @@ +Python now uses a stack size of at least 2 MiB, instead of 1 MiB. This is +especially needed when Python is linked to musl (ex: Alpine Linux) which +uses a default stack of 128 kiB. Patch by Victor Stinner. diff --git a/configure b/configure index 7608a0493b0ee62..1ebb5f8bbceb3ef 100755 --- a/configure +++ b/configure @@ -9901,7 +9901,7 @@ int main() return 2; } - if (size < 1024 * 1024) { + if (size < 2 * 1024 * 1024) { return 1; } return 0; @@ -9913,7 +9913,7 @@ EOF ./conftest &>/dev/null exitcode=$? if test $exitcode -eq 1; then - ac_cv_thread_stack_size=1048576 + ac_cv_thread_stack_size=2097152 # 2 MiB elif test $exitcode -eq 0; then ac_cv_thread_stack_size="default" fi diff --git a/configure.ac b/configure.ac index 020861b4c823759..1539e156a10413d 100644 --- a/configure.ac +++ b/configure.ac @@ -2463,8 +2463,9 @@ AS_CASE([$ac_sys_system], ) dnl On Linux, check the thread stack size. musl (ex: Alpine Linux) uses -dnl a default thread stack size of 128 kB, whereas the glibc uses 8 MiB. -dnl Python needs at least 1 MiB. +dnl a default thread stack size of 128 kiB, whereas the glibc uses 8 MiB. +dnl Python needs at least 2 MiB to run test_threading on Free Threading +dnl (gh-151542). if test "$ac_sys_system" = "Linux" -a "$cross_compiling" = no; then AC_CACHE_CHECK([for thread stack size], [ac_cv_thread_stack_size], [ cat > conftest.c </dev/null exitcode=$? if test $exitcode -eq 1; then - ac_cv_thread_stack_size=1048576 + ac_cv_thread_stack_size=2097152 # 2 MiB elif test $exitcode -eq 0; then ac_cv_thread_stack_size="default" fi