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.13] gh-122527: Fix a crash on deallocation of `PyStructSequence` (GH-122577) by miss-islington · Pull Request #122625 · python/cpython

Conversation

@miss-islington

@miss-islington miss-islington commented Aug 2, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

The PyStructSequence destructor would crash if it was deallocated after
its type's dictionary was cleared by the GC, because it couldn't compute
the "real size" of the instance. This could occur with relatively
straightforward code in the free-threaded build or with a reference
cycle involving the type in the default build, due to differing orders
in which tp_clear() was called.

Account for the non-sequence fields in tp_basicsize and use that,
along with Py_SIZE(), to compute the "real" size of a
PyStructSequence in the dealloc function. This avoids the accesses to
the type's dictionary during dealloc, which were unsafe.
(cherry picked from commit 4b63cd1)

Co-authored-by: Sam Gross [email protected]

  • Issue: Crash on deallocator of type 'time.struct_time' during finalizing for free-threaded Python #122527

Sorry, something went wrong.

Uh oh!

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

All reactions
@colesbury @miss-islington
pythongh-122527: Fix a crash on deallocation of PyStructSequence (p…
5ff87cc
…ythonGH-122577)

The `PyStructSequence` destructor would crash if it was deallocated after
its type's dictionary was cleared by the GC, because it couldn't compute
the "real size" of the instance. This could occur with relatively
straightforward code in the free-threaded build or with a reference
cycle involving the type in the default build, due to differing orders
in which `tp_clear()` was called.

Account for the non-sequence fields in `tp_basicsize` and use that,
along with `Py_SIZE()`, to compute the "real" size of a
`PyStructSequence` in the dealloc function. This avoids the accesses to
the type's dictionary during dealloc, which were unsafe.
(cherry picked from commit 4b63cd1)

Co-authored-by: Sam Gross <[email protected]>
This was referenced Aug 2, 2024
Crash on deallocator of type 'time.struct_time' during finalizing for free-threaded Python #122527
Closed
gh-122527: Fix a crash on deallocation of PyStructSequence #122577
Merged
@bedevere-app bedevere-app Bot added the awaiting review label Aug 2, 2024
@colesbury
colesbury requested review from Yhg1s and encukou August 2, 2024 16:17
serhiy-storchaka
serhiy-storchaka approved these changes Aug 12, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Aug 12, 2024
@XuehaiPan

XuehaiPan commented Aug 31, 2024

Copy link
Copy Markdown
Contributor

Out of curious, would this patch be included in Python 3.13.0rc2?

All reactions

Sorry, something went wrong.

Uh oh!

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

@XuehaiPan XuehaiPan mentioned this pull request Sep 1, 2024
deps(python): enable Python 3.13t support metaopt/optree#137
Merged
8 of 12 tasks
@Yhg1s
Yhg1s merged commit 57ba3b0 into python:3.13 Sep 2, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 2, 2024
@Yhg1s

Yhg1s commented Sep 2, 2024

Copy link
Copy Markdown
Member

Out of curious, would this patch be included in Python 3.13.0rc2?

Yes.

XuehaiPan reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@miss-islington
miss-islington deleted the backport-4b63cd1-3.13 branch January 2, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@encukou encukou Awaiting requested review from encukou
@Yhg1s Yhg1s Awaiting requested review from Yhg1s

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.

5 participants

@miss-islington @XuehaiPan @Yhg1s @serhiy-storchaka @colesbury
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.