Skip to content

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

Merged
vstinner merged 1 commit into
python:3.9from
miss-islington:backport-f1c6ae3-3.9
Jan 22, 2022
Merged

vstinner merged 1 commit into
python:3.9from
miss-islington:backport-f1c6ae3-3.9

Conversation

@miss-islington

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

Copy link
Copy Markdown
Contributor

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 vstinner@python.org

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 <vstinner@python.org>
@miss-islington

Copy link
Copy Markdown
Contributor Author

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

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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 <vstinner@python.org>

Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants