Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[3.14] gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (GH-139668) #141661

Merged
encukou merged 9 commits intopython:3.14python/cpython:3.14from
encukou:backport-b99db92-3.14encukou/cpython:backport-b99db92-3.14Copy head branch name to clipboard
Nov 25, 2025
Merged

[3.14] gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (GH-139668) #141661
encukou merged 9 commits intopython:3.14python/cpython:3.14from
encukou:backport-b99db92-3.14encukou/cpython:backport-b99db92-3.14Copy head branch name to clipboard

Conversation

rokm and others added 5 commits November 17, 2025 14:16
… limit on macOS (pythonGH-139232)

Use `pthread_get_stackaddr_np()` and `pthread_get_stacksize_np()` to determine the stack address and size.
…honGH-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>
…pythonGH-141551)

These checks were invalid and failed randomly on FreeBSD
and Alpine Linux.
@encukou encukou requested a review from vstinner November 17, 2025 13:32
@encukou encukou changed the title gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (GH-139668) [3.14] gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (GH-139668) Nov 17, 2025
@encukou encukou requested a review from hugovk November 17, 2025 13:50
@encukou
Copy link
Member Author

encukou commented Nov 17, 2025

@hugovk, this will change the internal ABI.

@vstinner
Copy link
Member

I would prefer to wait to see how the discussion https://discuss.python.org/t/python-3-14-0-is-incompatible-with-stack-switching-systems-what-do-we-do/104880 goes and see if this API solves the issue, or if we need another solution.

@vstinner
Copy link
Member

If this API cannot be used by most projects and a better fix can be designed, I would even suggest to remove this API from the main branch.

@vstinner
Copy link
Member

#141404 has been merged causing conflicts.

Can you please update your PR to solve conflicts?

Doc/c-api/init.rst Outdated Show resolved Hide resolved
@vstinner
Copy link
Member

I would prefer to wait to see how the discussion https://discuss.python.org/t/python-3-14-0-is-incompatible-with-stack-switching-systems-what-do-we-do/104880 goes and see if this API solves the issue, or if we need another solution.

If this API cannot be used by most projects and a better fix can be designed, I would even suggest to remove this API from the main branch.

#141711 has been merged: it should fix #139653 for most impacted projects. But according to @markshannon, PyUnstable_ThreadState_SetStackProtection() remains useful for these projects. So let's backport this function to the 3.14 branch.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@encukou encukou merged commit 32a38a2 into python:3.14 Nov 25, 2025
57 checks passed
@encukou encukou deleted the backport-b99db92-3.14 branch November 25, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.