Skip to content

Commit 1e9b8f2

Browse files
bitdancerkumaraditya303vstinner
authored
gh-131338: Disable computed stack limit checks on non-glibc linux (#134336)
Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 7040aa5 commit 1e9b8f2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Disable computed stack limit checks on non-glibc linux platforms to fix
2+
crashes on deep recursion.

Python/ceval.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,11 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate)
452452
_tstate->c_stack_soft_limit = _tstate->c_stack_hard_limit + _PyOS_STACK_MARGIN_BYTES;
453453
#else
454454
uintptr_t here_addr = _Py_get_machine_stack_pointer();
455-
# if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(_AIX) && !defined(__NetBSD__)
455+
/// XXX musl supports HAVE_PTHRED_GETATTR_NP, but the resulting stack size
456+
/// (on alpine at least) is much smaller than expected and imposes undue limits
457+
/// compared to the old stack size estimation. (We assume musl is not glibc.)
458+
# if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(_AIX) && \
459+
!defined(__NetBSD__) && (defined(__GLIBC__) || !defined(__linux__))
456460
size_t stack_size, guard_size;
457461
void *stack_addr;
458462
pthread_attr_t attr;

0 commit comments

Comments
 (0)