Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteecafc3

Browse files
authored
Revertgh-127266: avoid data races when updating type slots (gh-131174) (gh-133129)
This is triggering deadlocks in test_opcache. SeeGH-133130 for stack trace.
1 parent219b1f9 commiteecafc3

File tree

10 files changed

+112
-233
lines changed

10 files changed

+112
-233
lines changed

‎Include/internal/pycore_interp_structs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,8 @@ struct _Py_interp_cached_objects {
667667

668668
/* object.__reduce__ */
669669
PyObject*objreduce;
670-
#ifndefPy_GIL_DISABLED
671-
/* resolve_slotdups() */
672670
PyObject*type_slots_pname;
673671
pytype_slotdef*type_slots_ptrs[MAX_EQUIV];
674-
#endif
675672

676673
/* TypeVar and related types */
677674
PyTypeObject*generic_type;

‎Include/internal/pycore_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ extern int _PyDict_CheckConsistency(PyObject *mp, int check_content);
313313
// Fast inlined version of PyType_HasFeature()
314314
staticinlineint
315315
_PyType_HasFeature(PyTypeObject*type,unsigned longfeature) {
316-
return ((type->tp_flags)&feature)!=0;
316+
return ((FT_ATOMIC_LOAD_ULONG_RELAXED(type->tp_flags)&feature)!=0);
317317
}
318318

319319
externvoid_PyType_InitCache(PyInterpreterState*interp);

‎Include/internal/pycore_typeobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ extern int _PyType_AddMethod(PyTypeObject *, PyMethodDef *);
134134
externvoid_PyType_SetFlagsRecursive(PyTypeObject*self,unsigned longmask,
135135
unsigned longflags);
136136

137+
externunsignedint_PyType_GetVersionForCurrentState(PyTypeObject*tp);
137138
PyAPI_FUNC(void)_PyType_SetVersion(PyTypeObject*tp,unsignedintversion);
138139
PyTypeObject*_PyType_LookupByVersion(unsignedintversion);
139140

‎Include/object.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -620,12 +620,6 @@ given type object has a specified feature.
620620
#definePy_TPFLAGS_HAVE_FINALIZE (1UL << 0)
621621
#definePy_TPFLAGS_HAVE_VERSION_TAG (1UL << 18)
622622

623-
// Flag values for ob_flags (16 bits available, if SIZEOF_VOID_P > 4).
624-
#define_Py_IMMORTAL_FLAGS (1 << 0)
625-
#define_Py_STATICALLY_ALLOCATED_FLAG (1 << 2)
626-
#if defined(Py_GIL_DISABLED)&& defined(Py_DEBUG)
627-
#define_Py_TYPE_REVEALED_FLAG (1 << 3)
628-
#endif
629623

630624
#definePy_CONSTANT_NONE 0
631625
#definePy_CONSTANT_FALSE 1
@@ -782,7 +776,11 @@ PyType_HasFeature(PyTypeObject *type, unsigned long feature)
782776
// PyTypeObject is opaque in the limited C API
783777
flags=PyType_GetFlags(type);
784778
#else
785-
flags=type->tp_flags;
779+
# ifdefPy_GIL_DISABLED
780+
flags=_Py_atomic_load_ulong_relaxed(&type->tp_flags);
781+
# else
782+
flags=type->tp_flags;
783+
# endif
786784
#endif
787785
return ((flags&feature)!=0);
788786
}

‎Include/refcount.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ immortal. The latter should be the only instances that require
1919
cleanup during runtime finalization.
2020
*/
2121

22+
#define_Py_STATICALLY_ALLOCATED_FLAG 4
23+
#define_Py_IMMORTAL_FLAGS 1
24+
2225
#ifSIZEOF_VOID_P>4
2326
/*
2427
In 64+ bit systems, any object whose 32 bit reference count is >= 2**31

‎Lib/test/test_opcache.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ class TestRacesDoNotCrash(TestBase):
576576
# Careful with these. Bigger numbers have a higher chance of catching bugs,
577577
# but you can also burn through a *ton* of type/dict/function versions:
578578
ITEMS=1000
579-
SMALL_ITEMS=100
580579
LOOPS=4
581580
WRITERS=2
582581

@@ -620,7 +619,7 @@ class C:
620619
__getitem__=lambdaself,item:None
621620

622621
items= []
623-
for_inrange(self.SMALL_ITEMS):
622+
for_inrange(self.ITEMS):
624623
item=C()
625624
items.append(item)
626625
returnitems
@@ -791,7 +790,7 @@ class C:
791790
__getattribute__=lambdaself,name:None
792791

793792
items= []
794-
for_inrange(self.SMALL_ITEMS):
793+
for_inrange(self.ITEMS):
795794
item=C()
796795
items.append(item)
797796
returnitems

‎Misc/NEWS.d/next/Core_and_Builtins/2025-03-14-13-08-20.gh-issue-127266._tyfBp.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp