FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-158194: Pin the type lock in PyType_Freeze() by nascheme · Pull Request #158674 · python/cpython · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fix :c:func:`PyType_Freeze` releasing the type lock while waiting for a
stop-the-world pause in the :term:`free-threaded build`. Another thread could
modify the type before the frozen type's caches were invalidated, and the
release could deadlock against a thread waiting for the pause with the type
lock held.
3 changes: 3 additions & 0 deletions Objects/typeobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -12463,10 +12463,13 @@ PyType_Freeze(PyTypeObject *type)
return -1;
}

pinned_mutexes_t pinned;
BEGIN_TYPE_LOCK();
type_lock_prevent_release(&pinned);
types_stop_world();
type_add_flags(type, Py_TPFLAGS_IMMUTABLETYPE);
types_start_world();
type_lock_allow_release(&pinned);
ASSERT_TYPE_LOCK_HELD();
_PyType_Modified_Unlocked(type);
END_TYPE_LOCK();
Expand Down
Loading

Back | FazBrowse Home | New Git URL