Skip to content

[3.9] bpo-46417: Fix race condition on setting type __bases__ (GH-30788) #30790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2022

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jan 22, 2022

Fix a race condition on setting a type bases attribute: the
internal function add_subclass() now gets the
PyTypeObject.tp_subclasses member after calling PyWeakref_NewRef()
which can trigger a garbage collection which can indirectly modify
PyTypeObject.tp_subclasses.
(cherry picked from commit f1c6ae3)

Co-authored-by: Victor Stinner [email protected]

https://bugs.python.org/issue46417

Fix a race condition on setting a type __bases__ attribute: the
internal function add_subclass() now gets the
PyTypeObject.tp_subclasses member after calling PyWeakref_NewRef()
which can trigger a garbage collection which can indirectly modify
PyTypeObject.tp_subclasses.
(cherry picked from commit f1c6ae3)

Co-authored-by: Victor Stinner <[email protected]>
@miss-islington
Copy link
Contributor Author

@vstinner: Status check is done, and it's a success ✅ .

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM, good bot.

@vstinner vstinner merged commit f1796f2 into python:3.9 Jan 22, 2022
@miss-islington miss-islington deleted the backport-f1c6ae3-3.9 branch January 22, 2022 14:28
@miss-islington
Copy link
Contributor Author

@vstinner: Status check is done, and it's a success ✅ .

hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…) (pythonGH-30790)

Fix a race condition on setting a type __bases__ attribute: the
internal function add_subclass() now gets the
PyTypeObject.tp_subclasses member after calling PyWeakref_NewRef()
which can trigger a garbage collection which can indirectly modify
PyTypeObject.tp_subclasses.
(cherry picked from commit f1c6ae3)

Co-authored-by: Victor Stinner <[email protected]>

Co-authored-by: Victor Stinner <[email protected]>
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.

4 participants