[3.13] gh-120161: Fix a Crash in the _datetime Module (gh-120182) by miss-islington · Pull Request #120518 · python/cpython · GitHub
Skip to content

[3.13] gh-120161: Fix a Crash in the _datetime Module (gh-120182) - #120518

Merged
ericsnowcurrently merged 1 commit into
python:3.13from
miss-islington:backport-b2e71ff-3.13
Jun 14, 2024
Merged

[3.13] gh-120161: Fix a Crash in the _datetime Module (gh-120182)#120518
ericsnowcurrently merged 1 commit into
python:3.13from
miss-islington:backport-b2e71ff-3.13

Conversation

@miss-islington

@miss-islington miss-islington commented Jun 14, 2024

Copy link
Copy Markdown
Contributor

In gh-120009 I used an atexit hook to finalize the _datetime module's static types at interpreter shutdown. However, atexit hooks are executed very early in finalization, which is a problem in the few cases where a subclass of one of those static types is still alive until the final GC collection. The static builtin types don't have this probably because they are finalized toward the end, after the final GC collection. To avoid the problem for _datetime, I have applied a similar approach here.

Also, credit goes to @mgorny and @neonene for the new tests.

FYI, I would have liked to take a slightly cleaner approach with managed static types, but wanted to get a smaller fix in first for the sake of backporting. I'll circle back to the cleaner approach with a future change on the main branch.
(cherry picked from commit b2e71ff)

Co-authored-by: Eric Snow ericsnowcurrently@gmail.com

In pythongh-120009 I used an atexit hook to finalize the _datetime module's static types at interpreter shutdown.  However, atexit hooks are executed very early in finalization, which is a problem in the few cases where a subclass of one of those static types is still alive until the final GC collection.  The static builtin types don't have this probably because they are finalized toward the end, after the final GC collection.  To avoid the problem for _datetime, I have applied a similar approach here.

Also, credit goes to @mgorny and @neonene for the new tests.

FYI, I would have liked to take a slightly cleaner approach with managed static types, but wanted to get a smaller fix in first for the sake of backporting.  I'll circle back to the cleaner approach with a future change on the main branch.
(cherry picked from commit b2e71ff)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

@ericsnowcurrently

Copy link
Copy Markdown
Member

I'm looking into the buildbot failures. See #120182 (comment).

@ericsnowcurrently

Copy link
Copy Markdown
Member

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants