| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
* Avoid data race in fixup_slot_dispatchers(). * Set _Py_TYPE_REVEALED_FLAG before the type is published * PyType_FromMetaclass() now uses type_ready()/type_ready_publish() rather than PyType_Ready(), like type_new_impl() does, so that it publishes the type the same way. The flag macros are only defined for debug builds now, since that is the only build where the flag exists. * Hold the type lock while iterating tp_subclasses. * Hold the type lock while the slots of a new type are set up. fixup_slot_dispatchers() previously ran without the type lock held. Another thread could assign to a special method of a base between the point where we look up the special methods in the bases and the point where the type is added to the subclasses of its bases. * Do the ready, the slot fixup and the publishing of the type in one type lock critical section. A concurrent assignment to a base now either happens before we look up the special methods, or it finds the type in the subclasses of its bases. The slots are still stored directly rather than with the world stopped, since the type is not reachable by other threads yet. Co-authored-by: lipengyu <lipengyu@kylinos.cn> Assisted-by: Claude Opus 5
We can just always call _PyType_CheckConsistency() since it handles types that are not yet ready.
Call type_ready() and add a 'fix_slots' option. This simplifies code in the callers and makes it harder to use this wrong. Revert changes to TYPE_IS_REVEALED() macro, they are not needed. Make fixup_slot_dispatchers() void again, it cannot fail.
|
Thanks @nascheme for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15. |
Sorry, something went wrong.
|
GH-155821 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.