GeezerVison is showing github.com — gh-139231: Fix estimation of available stack size for recursion limit on macOS by rokm · Pull Request #139232 · python/cpython
Conversation
rokm
commented
Sep 22, 2025
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
On macOS, use pthread_get_stackaddr_np() and pthread_get_stacksize_np() to determine the stack address and size (used by code handling the recursion limit), rather than falling back to conservative hard-coded default of 4 MB.
Fixes #139231; the output of reproducer script is now:
Stack address: 6089916416 = 0x16AFCC000
Stack size: 16777216 = 16384.0 kB = 16.0 MB
Stack pointer: 0x16AFCA140, depth: 7.69 kB
Testing Recursion Limit
Initial limit: 1000
Recursion level: 1, stack pointer: 0x16AFC9870, depth: 9.89 kB
Recursion level: 2, stack pointer: 0x16AFC8FA0, depth: 12.09 kB
...
Recursion level: 7586, stack pointer: 0x169FD0BA0, depth: 16365.09 kB
Recursion level: 7587, stack pointer: 0x169FD0300, depth: 16367.25 kB
Recursion Limit ok (reached level 7588)
(i.e., stack is fully utilized, as expected).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
… limit on macOS
On macOS, use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()`
to determine the stack address and size (used by code handling the
recursion limit), rather than falling back to conservative hard-coded
default of 4 MB.
|
All commit authors signed the Contributor License Agreement.

|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.
If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @rokm for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Sep 24, 2025
… limit on macOS (pythonGH-139232)
Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.
(cherry picked from commit 7016044)
Co-authored-by: Rok Mandeljc <[email protected]>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
zanieb
added a commit
to astral-sh/python-build-standalone
that referenced
this pull request
Oct 15, 2025
This was referenced Oct 15, 2025
encukou
pushed a commit
to encukou/cpython
that referenced
this pull request
Nov 17, 2025
… limit on macOS (pythonGH-139232)
Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.
hroncok
pushed a commit
to hroncok/cpython
that referenced
this pull request
Nov 24, 2025
… limit on macOS (pythonGH-139232)
Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.
(cherry picked from commit 7016044)
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|