Skip to content

gh-159320: use pthread_getattr_np for stack limit checks even on musl - #159376

Open
Yhg1s wants to merge 2 commits into
python:mainfrom
Yhg1s:musl-stack-check
Open

Yhg1s wants to merge 2 commits into
python:mainfrom
Yhg1s:musl-stack-check

Conversation

@Yhg1s

@Yhg1s Yhg1s commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Adjust the use of pthread_getattr_np for stack size limit detection to avoid the problem on musl of it reporting the stack limit of the main thread incorrectly. On platforms where pthread_getattr_np underreports the main thread's stack size, use RLIMIT_STACK for the main thread instead. (Cross-compiles targeting musl will have to pass ac_cv_unreliable_pthread_getattr_np=yes to configure.)

reporting the stack limit of the main thread incorrectly. On platforms where
pthread_getattr_np underreports the main thread's stack size, use
RLIMIT_STACK for the main thread instead.
@Yhg1s

Yhg1s commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

This is a more general fix than #159321, and incidentally also lets us have proper stack overflow protections on musl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant