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

gh-159876: Detect the C stack size of non-main threads on musl by serhiy-storchaka · Pull Request #159882 · python/cpython · GitHub

Repository navigation

gh-159876: Detect the C stack size of non-main threads on musl - #159882

Draft
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-159876-musl-stack
Draft

serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-159876-musl-stack

Conversation

serhiy-storchaka commented Oct 20, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

hardware_stack_limits() skipped pthread_getattr_np() on any Linux that is neither glibc nor Android, because musl misreports the main thread's stack. musl is accurate for the threads it creates itself, so the blanket exclusion left the interpreter assuming Py_C_STACK_SIZE everywhere, and a thread with a smaller stack overflowed before the recursion guard fired.

Query the stack on every thread except the process main thread, which keeps the old estimate.

On Alpine 3.24 this takes c_recursion_remaining from a constant 1450 to 250 / 12650 for 256 KiB / 8 MiB threads — the same numbers glibc reports — and the full suite goes from 1 failure (a SIGSEGV in test_lazy_import) to Result: SUCCESS. No change on glibc.

🤖 Generated with Claude Code

pthread_getattr_np() was skipped on every non-glibc, non-Android Linux
because musl misreports the main thread's stack.  It is accurate for the
threads musl creates itself, so query those and keep the estimate only
for the main thread.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhiy-storchaka marked this pull request as draft October 20, 2026 12:49
serhiy-storchaka added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels 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.14 bugs and security fixes 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