mirror of
https://github.com/python/cpython.git
synced 2026-06-28 03:41:13 +00:00
gh-151546: Fix stack limits on musl (#151548)
If the thread stack size is set by linker flags, pass the stack size
to Python/ceval.c via the new _Py_LINKER_THREAD_STACK_SIZE variable
to set Py_C_STACK_SIZE macro.
(cherry picked from commit 9a61d1c0c8)
This commit is contained in:
parent
ff6e973c3b
commit
a5c5edddbc
5 changed files with 16 additions and 1 deletions
|
|
@ -0,0 +1,3 @@
|
|||
Fix the stack limit check if Python is linked to musl (ex: Alpine Linux).
|
||||
Use the stack size set by the linker to compute the stack limits. Patch by
|
||||
Victor Stinner.
|
||||
|
|
@ -63,7 +63,9 @@ _Py_EnterRecursiveCallUnchecked(PyThreadState *tstate)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(__s390x__)
|
||||
#if defined(_Py_LINKER_THREAD_STACK_SIZE)
|
||||
# define Py_C_STACK_SIZE _Py_LINKER_THREAD_STACK_SIZE
|
||||
#elif defined(__s390x__)
|
||||
# define Py_C_STACK_SIZE 320000
|
||||
#elif defined(_WIN32)
|
||||
// Don't define Py_C_STACK_SIZE, ask the O/S
|
||||
|
|
|
|||
4
configure
generated
vendored
4
configure
generated
vendored
|
|
@ -9918,6 +9918,10 @@ printf "%s\n" "$ac_cv_thread_stack_size" >&6; }
|
|||
|
||||
if test "$ac_cv_thread_stack_size" != "default" -a "$ac_cv_thread_stack_size" != "unknown"; then
|
||||
LDFLAGS="$LDFLAGS -Wl,-z,stack-size=$ac_cv_thread_stack_size"
|
||||
# Stack size used by Python/ceval.c to set Py_C_STACK_SIZE
|
||||
|
||||
printf "%s\n" "#define _Py_LINKER_THREAD_STACK_SIZE $ac_cv_thread_stack_size" >>confdefs.h
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -2507,6 +2507,9 @@ EOF
|
|||
|
||||
if test "$ac_cv_thread_stack_size" != "default" -a "$ac_cv_thread_stack_size" != "unknown"; then
|
||||
LDFLAGS="$LDFLAGS -Wl,-z,stack-size=$ac_cv_thread_stack_size"
|
||||
# Stack size used by Python/ceval.c to set Py_C_STACK_SIZE
|
||||
AC_DEFINE_UNQUOTED([_Py_LINKER_THREAD_STACK_SIZE], [$ac_cv_thread_stack_size],
|
||||
[Thread stack size set by the linker (in bytes).])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -2067,6 +2067,9 @@
|
|||
/* Define if you have the 'PR_SET_VMA_ANON_NAME' constant. */
|
||||
#undef _Py_HAVE_PR_SET_VMA_ANON_NAME
|
||||
|
||||
/* Thread stack size set by the linker (in bytes). */
|
||||
#undef _Py_LINKER_THREAD_STACK_SIZE
|
||||
|
||||
/* Define to 1 if the machine stack grows down (default); 0 if it grows up. */
|
||||
#undef _Py_STACK_GROWS_DOWN
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue