Skip to content

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

Open
encukou wants to merge 11 commits into
python:mainfrom
encukou:musl-stack-check
Open

encukou wants to merge 11 commits into
python:mainfrom
encukou:musl-stack-check

Conversation

@encukou

@encukou encukou commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

This builds on @Yhg1s's #159376, trying some more things:

  • Report unreliable_pthread_getattr_np even if configure runs with unlimited stack, by limiting it artificially.
  • Adjust the base, not the top

@encukou

encukou commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

!buildbot Alpine

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit 7b773d3 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F161749%2Fmerge

The command will test the builders whose names match following regular expression: Alpine

The builders matched are:

  • AMD64 Alpine Linux NoGIL PR
  • AMD64 Alpine Linux PR

@encukou

encukou commented Nov 12, 2026

Copy link
Copy Markdown
Member Author

This fixes the test_lazy_import failure; the remaining test_profiling one looks unrelated.
@vstinner or @Yhg1s, does the code look reasonable?

@aozmekik aozmekik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Alpine 3.22 (musl) x86_64 and aarch64, debug build, against the merge base:

  • configure sets _Py_HAVE_UNRELIABLE_PTHREAD_GETATTR_NP on both.
  • Main thread get_c_recursion_remaining(): 1450 -> 12650 with ulimit -s 8192 (same as glibc), 102250 with 64 MiB, and still 1450 with an unlimited stack. New threads stay at 1450.
  • test_lazy_import, test_typing, test_json, test_ast, test_compile, test_exceptions, test_pickle and test_threading pass; one of them fails on the merge base.

Nit: on musl configure prints checking whether pthread_getattr_np reports the main thread stack reliably... yes, since the cached value is the inverse. Also, cross builds default to no, so a musl cross build keeps the old limit unless ac_cv_unreliable_pthread_getattr_np=yes is passed. Might be worth defaulting from $host there.

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.

4 participants