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-135106: [crash repro] Randomly deposit objects in `_Py_Dealloc` by colesbury · Pull Request #135589 · python/cpython

Conversation

@colesbury

@colesbury colesbury commented Jun 16, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Returns 1 a little less than 1% of the time in
_Py_RecursionLimit_GetMargin() to force the use of the trashcan mechanism.

This isn't intended to be merged. It's just to:

  1. Demonstrate the crash
  2. Test on a variety of platforms and configs from the CI
  • Issue: test_weakref.test_threaded_weak_key_dict_deepcopy crash: merged objects should have ob_tid == 0 #135106

Sorry, something went wrong.

Uh oh!

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

All reactions
@colesbury
pythongh-135106: Randomly return 1 in _Py_RecursionLimit_GetMargin
030abcd
Returns `1` a little less than 1% of the time in
_Py_RecursionLimit_GetMargin() to force the use of the trashcan
mechanism.
@bedevere-app bedevere-app Bot mentioned this pull request Jun 16, 2025
test_weakref.test_threaded_weak_key_dict_deepcopy crash: merged objects should have ob_tid == 0 #135106
Closed
@colesbury colesbury added the skip news label Jun 16, 2025
AA-Turner
AA-Turner reviewed Jun 16, 2025
View reviewed changes
Comment thread Include/internal/pycore_pystate.h Resolved

Uh oh!

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

@colesbury colesbury added the DO-NOT-MERGE label Jun 16, 2025
@colesbury colesbury changed the title gh-135106: Randomly return 1 in _Py_RecursionLimit_GetMargin gh-135106: [crash repro] Randomly return 1 in _Py_RecursionLimit_GetMargin Jun 16, 2025
@colesbury @AA-Turner
Update Include/internal/pycore_pystate.h
92e82ac
Co-authored-by: Adam Turner <[email protected]>
@markshannon

markshannon commented Jun 17, 2025

Copy link
Copy Markdown
Member

I don't think this shows anything more than that randomly changing the stack limit causes crashes.

The trashcan mechanism relies on the margin being larger for frames higher up the call stack. This breaks that invariant.

You could try changing margin > 2 and margin >= 4 to much larger numbers to see if that provokes a failure.

All reactions

Sorry, something went wrong.

Uh oh!

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

@hugovk
hugovk force-pushed the gh-135106-crash-demo branch from f0ef510 to 92e82ac Compare June 17, 2025 07:32
@hugovk

This comment was marked as resolved.

Sign in to view
@colesbury colesbury changed the title gh-135106: [crash repro] Randomly return 1 in _Py_RecursionLimit_GetMargin gh-135106: [crash repro] Randomly deposit objects in _Py_Dealloc Jun 17, 2025
@colesbury
Update test so that RNG is in _Py_Dealloc
7c86a25
@colesbury
colesbury force-pushed the gh-135106-crash-demo branch from da82cbb to 7c86a25 Compare June 17, 2025 17:08
@colesbury

colesbury commented Jun 17, 2025

Copy link
Copy Markdown
Contributor Author

I don't think this shows anything more than that randomly changing the stack limit causes crashes.

The only thing that matters here is the condition to deposit objects -- there's no invariant to be broken. I've updated the test to make that more clear. It should always be safe to deposit an object conservatively (i.e., to treat the available stack as smaller).

Here's the equivalent test with the old trashcan behavior, which works without crashing:
https://github.com/colesbury/cpython/tree/gh-135106-test-old-behavior

All reactions

Sorry, something went wrong.

Uh oh!

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

@colesbury colesbury closed this Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner AA-Turner left review comments
@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
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity will be requested when the pull request is marked ready for review ZeroIntensity is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 will be requested when the pull request is marked ready for review FFY00 is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

DO-NOT-MERGE 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.

4 participants

@colesbury @markshannon @hugovk @AA-Turner
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.