Skip to content

Conversation

@hroncok
Copy link
Contributor

@hroncok hroncok commented Nov 24, 2025

This is my naïve attempt to backport #141711 into the 3.14 branch. I needed to backport several other changes, and at this point am frankly not sure if I know what I am doing :)

Opening as a draft, nevertheless, in case someone wants to take a look.


📚 Documentation preview 📚: https://cpython-previews--141892.org.readthedocs.build/

rokm and others added 4 commits November 24, 2025 11:32
… limit on macOS (pythonGH-139232)

Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.

(cherry picked from commit 7016044)
…hon#139668)

Add PyUnstable_ThreadState_SetStackProtection() and
PyUnstable_ThreadState_ResetStackProtection() functions
to set the stack base address and stack size of a Python
thread state.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
(cherry picked from commit b99db92)
…ack pointer is about to overflow the stack. (pythonGH-141711)

Only raises if the stack pointer is both below the limit *and* above the stack base.
This prevents false positives for user-space threads, as the stack pointer will be outside those bounds
if the stack has been swapped.

(cherry picked from commit c25a070)
@vstinner
Copy link
Member

@encukou prepared #141661 which contains most changes of this PR but fix also the ABI checks.

@hroncok
Copy link
Contributor Author

hroncok commented Nov 24, 2025

I am not sure it includes the Only raise an exception (or fatal error) when the stack pointer is about to overflow the stack commit, but I am happy to close this and finish the work there.

@hroncok hroncok closed this Nov 24, 2025
@vstinner
Copy link
Member

Sure, "Only raise an exception (or fatal error) when the stack pointer is about to overflow the stack" should still be backported. But #141661 is a complex backport for the first part: backport PyUnstable_ThreadState_SetStackProtection() functions and commits preparing this backport.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants