Skip to content

Commit 1878fe8

Browse files
miss-islingtonbitdancerkumaraditya303vstinner
authored
[3.14] gh-131338: Disable computed stack limit checks on non-glibc linux (GH-134336) (#137175)
Co-authored-by: R. David Murray <[email protected]> Co-authored-by: Kumar Aditya <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
1 parent f180fb9 commit 1878fe8

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
@@ -439,7 +439,11 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate)
439439
_tstate->c_stack_soft_limit = _tstate->c_stack_hard_limit + _PyOS_STACK_MARGIN_BYTES;
440440
#else
441441
uintptr_t here_addr = _Py_get_machine_stack_pointer();
442-
# if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(_AIX) && !defined(__NetBSD__)
442+
/// XXX musl supports HAVE_PTHRED_GETATTR_NP, but the resulting stack size
443+
/// (on alpine at least) is much smaller than expected and imposes undue limits
444+
/// compared to the old stack size estimation. (We assume musl is not glibc.)
445+
# if defined(HAVE_PTHREAD_GETATTR_NP) && !defined(_AIX) && \
446+
!defined(__NetBSD__) && (defined(__GLIBC__) || !defined(__linux__))
443447
size_t stack_size, guard_size;
444448
void *stack_addr;
445449
pthread_attr_t attr;

0 commit comments

Comments
 (0)