Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a deadlock in the :term:`free threaded <free threading>` build when
setting ``__abstractmethods__`` on a type while another thread holds the
type lock.
3 changes: 3 additions & 0 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,14 +1706,17 @@ type_set_abstractmethods(PyObject *tp, PyObject *value, void *Py_UNUSED(closure)
return -1;
}

pinned_mutexes_t pinned;
BEGIN_TYPE_LOCK();
_PyType_Modified_Unlocked(type);
type_lock_prevent_release(&pinned);
types_stop_world();
if (abstract)
type_add_flags(type, Py_TPFLAGS_IS_ABSTRACT);
else
type_clear_flags(type, Py_TPFLAGS_IS_ABSTRACT);
types_start_world();
type_lock_allow_release(&pinned);
ASSERT_TYPE_LOCK_HELD();
END_TYPE_LOCK();

Expand Down
Loading