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
Draft
serhiy-storchaka wants to merge 1 commit into
serhiy-storchaka wants to merge 1 commit into
Conversation
serhiy-storchaka
force-pushed
the
gh-159876-musl-stack
branch
from
October 20, 2026 12:47
cdb134f to
ae222a3
Compare
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
force-pushed
the
gh-159876-musl-stack
branch
from
October 20, 2026 12:49
ae222a3 to
42f6138
Compare
serhiy-storchaka
marked this pull request as draft
October 20, 2026 12:49
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
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.
hardware_stack_limits()skippedpthread_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 assumingPy_C_STACK_SIZEeverywhere, 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_remainingfrom 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 intest_lazy_import) toResult: SUCCESS. No change on glibc.🤖 Generated with Claude Code