Skip to content

bugfix: Keep registered types until after Py_Finalize(). Fix #4459 - #4486

Merged
Skylion007 merged 2 commits into
pybind:masterfrom
Skylion007:skylion007/allow-atexit-use-registered-types
Feb 6, 2023
Merged

bugfix: Keep registered types until after Py_Finalize(). Fix #4459#4486
Skylion007 merged 2 commits into
pybind:masterfrom
Skylion007:skylion007/allow-atexit-use-registered-types

Conversation

@Skylion007

@Skylion007Skylion007 commented Feb 2, 2023

Copy link
Copy Markdown
Collaborator

Description

NOTE: rolled back with PR #4501

Fix#4459 . Keep types registered until after atexit is called.

TODO / help wanted: unit test exercising the atexit situation.

Suggested changelog entry:

* Fix bug where cpptypes were unregistered before atexit was called.

rwgk
rwgk approved these changes Feb 2, 2023

@rwgkrwgk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK to let the testing slip, in the interest of getting the fix in sooner rather than later, but it would be best to mention that clearly in the PR description, e.g.:

TODO / help wanted: unit test exercising the atexit situation.

Comment threadinclude/pybind11/embed.h Outdated

// Local internals contains data managed by the current interpreter, so we must clear them to
// avoid undefined behaviors when initializing another interpreter
// Must be cleared after Py_Finalize() so atexit and other hooks can use registered_types

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Must be cleared only after Py_Finalize() so atexit and other hooks can still use use registered_types

?

Extra "only" and "still", to emphasize the importance.

@Skylion007Skylion007 changed the title (bugfix): Keep registered types until after Py_Finalize(). Fix #4459bugfix: Keep registered types until after Py_Finalize(). Fix #4459Feb 4, 2023
@Skylion007
Skylion007 merged commit b2c1978 into pybind:masterFeb 6, 2023
@github-actionsgithub-actionsBot added the needs changelog Possibly needs a changelog entry label Feb 6, 2023
rwgk added a commit to rwgk/pybind11 that referenced this pull request Feb 8, 2023
rwgk added a commit that referenced this pull request Feb 8, 2023
@rwgkrwgk removed the needs changelog Possibly needs a changelog entry label Feb 8, 2023
@rwgkrwgk mentioned this pull request Feb 11, 2023
Sign up for freeto 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.

[BUG]: Python atexit broken with pybind11 version >= 2.9.2

2 participants

@Skylion007@rwgk