FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-159879: Do not limit the C stack below what the interpreter assumes by serhiy-storchaka · Pull Request #159883 · python/cpython · GitHub

Repository navigation

gh-159879: Do not limit the C stack below what the interpreter assumes - #159883

Draft
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-159879-limited-c-stack
Draft

serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-159879-limited-c-stack

Conversation

serhiy-storchaka commented Oct 20, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

Where hardware_stack_limits() cannot query the running thread's stack (AIX, NetBSD, non-glibc Linux), the interpreter assumes Py_C_STACK_SIZE. A test thread created with less than that overflows before the recursion guard notices, so the test crashes instead of getting RecursionError. test_lazy_import asks for 256 KiB and does exactly that on Alpine.

run_with_limited_c_stack() now probes once whether the real size is visible — two threads of different sizes report the same headroom only when the fixed estimate is in use — and raises a too-small size to C_STACK_SIZE when it is not.

Verified both ways: on Alpine the probe returns False, the clamp applies and test_lazy_import passes with an unpatched ceval.c; on glibc it returns True, nothing is clamped, and the tests using the helper are unaffected.

Independent of #159882, which fixes the detection itself.

🤖 Generated with Claude Code

…assumes

Where a thread's stack size cannot be queried, the interpreter assumes
Py_C_STACK_SIZE, and a smaller thread overflows instead of raising
RecursionError.  run_with_limited_c_stack() now raises such a size to
C_STACK_SIZE.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhiy-storchaka force-pushed the gh-159879-limited-c-stack branch from 72165f3 to b65f636 Compare October 20, 2026 12:49
serhiy-storchaka marked this pull request as draft October 20, 2026 12:49
serhiy-storchaka added the needs backport to 3.15 bugs and security fixes label Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport to 3.15 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL