GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.14] GH-139653: Only raise an exception (or fatal error) when the stack pointer is about to overflow the stack. (GH-141711) by hroncok · Pull Request #141892 · python/cpython

Conversation

@hroncok

@hroncok hroncok commented Nov 24, 2025 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Issue: Python 3.14 stack overflow detection is incompatible with C++ Boost make_fcontext() coroutines #139653

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
rokm and others added 4 commits November 24, 2025 11:32
@rokm @hroncok
pythongh-139231: Fix estimation of available stack size for recursion…
0fca453
… 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)
@markshannon @hroncok
pythonGH-139291: Fix C stack limits by factoring out finding hardware…
42e7abe
… stack limits (pythonGH-139294)

(cherry picked from commit 7094f09)
@vstinner @encukou @hroncok
pythongh-139653: Add PyUnstable_ThreadState_SetStackProtection() (pyt…
b8dfdd2
…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 <[email protected]>
(cherry picked from commit b99db92)
@markshannon @hroncok
pythonGH-139653: Only raise an exception (or fatal error) when the st…
30cdcac
…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)
This was referenced Nov 24, 2025
GH-139653: Only raise an exception (or fatal error) when the stack pointer is about to overflow the stack. #141711
Merged
Python 3.14 stack overflow detection is incompatible with C++ Boost make_fcontext() coroutines #139653
Open
@vstinner

vstinner commented Nov 24, 2025

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hroncok

hroncok commented Nov 24, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hroncok hroncok closed this Nov 24, 2025
@vstinner

vstinner commented Nov 24, 2025

Copy link
Copy Markdown
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.

hroncok reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently will be requested when the pull request is marked ready for review ericsnowcurrently is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon will be requested when the pull request is marked ready for review markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@hroncok @vstinner @rokm @markshannon
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.