gh-127266: avoid data races when updating type slots (gh-131174)

In the free-threaded build, avoid data races caused by updating type slots
or type flags after the type was initially created.  For those (typically
rare) cases, use the stop-the-world mechanism.  Remove the use of atomics
when reading or writing type flags.  The use of atomics is not sufficient to
avoid races (since flags are sometimes read without a lock and without
atomics) and are no longer required.
This commit is contained in:
Neil Schemenauer 2025-04-28 13:28:44 -07:00 committed by GitHub
parent 22f0730d40
commit e414a2d81c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 233 additions and 112 deletions

View file

@ -19,9 +19,6 @@ immortal. The latter should be the only instances that require
cleanup during runtime finalization.
*/
#define _Py_STATICALLY_ALLOCATED_FLAG 4
#define _Py_IMMORTAL_FLAGS 1
#if SIZEOF_VOID_P > 4
/*
In 64+ bit systems, any object whose 32 bit reference count is >= 2**31