GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@rokm rokm commented Sep 22, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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).

  • Issue: Under-estimated stack size for recursion limit (macOS + python >= 3.14) #139231

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rokm
pythongh-139231: Fix estimation of available stack size for recursion…
978a1aa
… 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.
@rokm
rokm requested a review from markshannon as a code owner September 22, 2025 12:23
@bedevere-app bedevere-app Bot added the awaiting review label Sep 22, 2025
@python-cla-bot

python-cla-bot Bot commented Sep 22, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Sep 22, 2025

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request Sep 22, 2025
Under-estimated stack size for recursion limit (macOS + python >= 3.14) #139231
Closed
markshannon
markshannon reviewed Sep 22, 2025
View reviewed changes
Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@markshannon markshannon added the skip news label Sep 23, 2025
@markshannon
markshannon merged commit 7016044 into python:main Sep 24, 2025
@bedevere-app bedevere-app Bot removed the awaiting review label Sep 24, 2025
@markshannon markshannon added the needs backport to 3.14 bugs and security fixes label Sep 24, 2025
@miss-islington-app

miss-islington-app Bot commented Sep 24, 2025

Copy link
Copy Markdown

Thanks @rokm for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

All reactions

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
@rokm @miss-islington
pythongh-139231: Fix estimation of available stack size for recursion…
9914c15
… 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]>
@bedevere-app

bedevere-app Bot commented Sep 24, 2025

Copy link
Copy Markdown

GH-139290 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 24, 2025
@rokm
rokm deleted the macos-stack-size-fix branch September 24, 2025 11:03
zanieb added a commit to astral-sh/python-build-standalone that referenced this pull request Oct 15, 2025
@zanieb
Revert python/cpython#139232 for testing
212b6a3
This was referenced Oct 15, 2025
Add patch to revert change to macOS stack size estimation on 3.15 astral-sh/python-build-standalone#823
Draft
test_json case test_highly_nested_objects_decoding fails under PGO on Clang 20 #140125
Closed
encukou pushed a commit to encukou/cpython that referenced this pull request Nov 17, 2025
@rokm @encukou
pythongh-139231: Fix estimation of available stack size for recursion…
7752629
… limit on macOS (pythonGH-139232)

Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.
@encukou encukou mentioned this pull request Nov 17, 2025
[3.14] gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (GH-139668) #141661
Merged
hroncok pushed a commit to hroncok/cpython that referenced this pull request Nov 24, 2025
@rokm @hroncok
pythongh-139231: Fix estimation of available stack size for recursion…
0fca453
… 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon markshannon left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Under-estimated stack size for recursion limit (macOS + python >= 3.14)

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@rokm @markshannon
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.