diff --git a/Lib/test/test_interpreters/test_api.py b/Lib/test/test_interpreters/test_api.py index 01856d9bf67657..9c02efe71683f6 100644 --- a/Lib/test/test_interpreters/test_api.py +++ b/Lib/test/test_interpreters/test_api.py @@ -703,6 +703,7 @@ def test_not_shareable(self): with self.assertRaises(ExecutionFailed): interp.exec('print(spam)') + @support.skip_if_sanitizer('gh-129824: file descriptor race', thread=True) def test_running(self): interp = interpreters.create() interp.prepare_main({'spam': True}) @@ -1530,6 +1531,7 @@ def test_whence(self): whence = eval(text) self.assertEqual(whence, _interpreters.WHENCE_LEGACY_CAPI) + @support.skip_if_sanitizer('gh-129824: file descriptor race', thread=True) def test_is_running(self): def check(interpid, expected): with self.assertRaisesRegex(InterpreterError, 'unrecognized'): diff --git a/Objects/exceptions.c b/Objects/exceptions.c index e30fea0f37a925..1c603078c43a96 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -4350,7 +4350,8 @@ _PyExc_InitTypes(PyInterpreterState *interp) return -1; } if (exc->tp_new == BaseException_new - && exc->tp_init == BaseException_init) + && exc->tp_init == BaseException_init + && _Py_IsMainInterpreter(interp)) { exc->tp_vectorcall = BaseException_vectorcall; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index bc840ed51ffe4c..7549e766c23f08 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -235,10 +235,10 @@ managed_static_type_state_init(PyInterpreterState *interp, PyTypeObject *self, ? index : index + _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES; - assert((initial == 1) == - (_PyRuntime.types.managed_static.types[full_index].interp_count == 0)); - (void)_Py_atomic_add_int64( + int64_t prev_interp_count = _Py_atomic_add_int64( &_PyRuntime.types.managed_static.types[full_index].interp_count, 1); + assert((initial == 1) == (prev_interp_count == 0)); + (void)prev_interp_count; if (initial) { assert(_PyRuntime.types.managed_static.types[full_index].type == NULL); @@ -8581,12 +8581,22 @@ type_ready_set_new(PyTypeObject *type, int initial) } else { // tp_new is NULL: inherit tp_new from base - type->tp_new = base->tp_new; + if (initial) { + type->tp_new = base->tp_new; + } + else { + assert(type->tp_new == base->tp_new); + } } } else { // Py_TPFLAGS_DISALLOW_INSTANTIATION sets tp_new to NULL - type->tp_new = NULL; + if (initial) { + type->tp_new = NULL; + } + else { + assert(type->tp_new == NULL); + } } return 0; }