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 — gh-139653: Remove assertions in _Py_InitializeRecursionLimits() by vstinner · Pull Request #141551 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Nov 14, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

These checks were invalid and failed randomly on FreeBSD.

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

Sorry, something went wrong.

Uh oh!

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

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@vstinner
pythongh-139653: Remove assertions in _Py_InitializeRecursionLimits()
cafa933
These checks were invalid and failed randomly on FreeBSD.
@vstinner
vstinner requested a review from markshannon as a code owner November 14, 2025 11:27
@vstinner vstinner added the skip news label Nov 14, 2025
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 14, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Nov 14, 2025
Python 3.14 stack overflow detection is incompatible with C++ Boost make_fcontext() coroutines #139653
Open
@vstinner vstinner mentioned this pull request Nov 14, 2025
gh-140550: Remove PyInit function from test_cext #141511
Draft
@vstinner

vstinner commented Nov 14, 2025

Copy link
Copy Markdown
Member Author

These checks were invalid and failed randomly on FreeBSD.

It also fails on Alpine Linux.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner enabled auto-merge (squash) November 14, 2025 11:58
@vstinner
Merge branch 'main' into init_recursion
7cf4046
@vstinner
vstinner merged commit a415a18 into python:main Nov 14, 2025
50 checks passed

Uh oh!

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

@vstinner
vstinner deleted the init_recursion branch November 14, 2025 14:56
@bedevere-app bedevere-app Bot removed the awaiting core review label Nov 14, 2025
@markshannon

markshannon commented Nov 14, 2025

Copy link
Copy Markdown
Member

If an assertion is failing, fix whatever is causing the invariant to be broken. Don't just remove the assert.

Please revert this change, and make an issue for the failures. Especially if it is "failing randomly".
I don't think #139653 is relevant.

It is a necessary invariant that the stack pointer lie between the top of the stack and the soft limit. If that is not the case, we need to fix it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Nov 14, 2025

Copy link
Copy Markdown
Member Author

This PR is to repair FreeBSD and Alpine buildbots. These buildbot workers were crashing randomly (with an assertion error in fact). I suppose that WASI had the same issue but it was more likely on WASI so I already skipped the assertion on WASI.

If an assertion is failing, fix whatever is causing the invariant to be broken. Don't just remove the assert.

It's the following assertion which fails randomly:

    uintptr_t here_addr = _Py_get_machine_stack_pointer();
    ....
    assert(here_addr < ts->c_stack_top);

The code to get the stack top in hardware_stack_limits() is not reliable:

    uintptr_t top_addr = _Py_SIZE_ROUND_UP(here_addr, 4096);

Maybe one problem is that the assertion is not checked in the same function than hardware_stack_limits().

I don't have time to investigate this issue right now.

I suppose that you should be able to reproduce it if you disable the pthread_attr_getstack() code path in hardware_stack_limits().

All reactions

Sorry, something went wrong.

Uh oh!

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

@markshannon

markshannon commented Nov 17, 2025

Copy link
Copy Markdown
Member

This PR is to repair FreeBSD and Alpine buildbots.

It doesn't repair anything. It just leaves a latent bug to blow up later.

The code to get the stack top in hardware_stack_limits() is not reliable

Then fix that, or make an issue for me to fix. Please don't turn off asserts without any review.

Maybe one problem is that the assertion is not checked in the same function than hardware_stack_limits()

Sure, let's move the assert to make the point of failure clearer.

I suppose that you should be able to reproduce it if you disable the pthread_attr_getstack() code path in hardware_stack_limits()

I'll try that.

All reactions

Sorry, something went wrong.

Uh oh!

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

@markshannon

markshannon commented Nov 17, 2025

Copy link
Copy Markdown
Member

Oh, and please read https://github.com/python/cpython/blob/main/InternalDocs/stack_protection.md

All reactions

Sorry, something went wrong.

Uh oh!

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

encukou pushed a commit to encukou/cpython that referenced this pull request Nov 17, 2025
@vstinner @encukou
pythongh-139653: Remove assertions in _Py_InitializeRecursionLimits() (…
5d2c92c
…pythonGH-141551)

These checks were invalid and failed randomly on FreeBSD
and Alpine Linux.
@encukou encukou mentioned this pull request Nov 17, 2025
[3.14] gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (GH-139668) #141661
Merged
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@vstinner @StanFromIreland
pythongh-139653: Remove assertions in _Py_InitializeRecursionLimits() (…
f137d60
…python#141551)

These checks were invalid and failed randomly on FreeBSD
and Alpine Linux.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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.

2 participants

@vstinner @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.