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

Conversation

@colesbury

@colesbury colesbury 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)

  • 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
[3.12] pythongh-122527: Fix a crash on deallocation of `PyStructSeque…
e9b8e16
…nce` (pythonGH-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]>
@colesbury
colesbury requested a review from encukou August 2, 2024 16:22
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 core review label Aug 2, 2024
serhiy-storchaka
serhiy-storchaka approved these changes Aug 12, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Aug 12, 2024
@ambv
ambv merged commit 1bfb58c into python:3.12 Sep 6, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 6, 2024
@colesbury
colesbury deleted the backport-4b63cd1-3.12 branch December 4, 2024 20:23
@kibertoad kibertoad mentioned this pull request Oct 15, 2026
fix(disc-archiver): leave no parsed date in pycdlib's cache at exit kibertoad/refurbished-dinosaurs-toolkit#535
Merged
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

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.

3 participants

@colesbury @serhiy-storchaka @ambv
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 01402520 — 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.