Skip to content

Commit e6109fb

Browse files
committed
Fix additional data races
1 parent a7df3c2 commit e6109fb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Objects/exceptions.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4231,7 +4231,8 @@ _PyExc_InitTypes(PyInterpreterState *interp)
42314231
return -1;
42324232
}
42334233
if (exc->tp_new == BaseException_new
4234-
&& exc->tp_init == (initproc)BaseException_init)
4234+
&& exc->tp_init == (initproc)BaseException_init
4235+
&& _Py_IsMainInterpreter(interp))
42354236
{
42364237
exc->tp_vectorcall = BaseException_vectorcall;
42374238
}

Objects/typeobject.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,9 @@ managed_static_type_state_init(PyInterpreterState *interp, PyTypeObject *self,
234234
? index
235235
: index + _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES;
236236

237-
assert((initial == 1) ==
238-
(_PyRuntime.types.managed_static.types[full_index].interp_count == 0));
239-
(void)_Py_atomic_add_int64(
237+
int64_t prev_interp_count = _Py_atomic_add_int64(
240238
&_PyRuntime.types.managed_static.types[full_index].interp_count, 1);
239+
assert((initial == 1) == (prev_interp_count == 0));
241240

242241
if (initial) {
243242
assert(_PyRuntime.types.managed_static.types[full_index].type == NULL);
@@ -8526,7 +8525,12 @@ type_ready_set_new(PyTypeObject *type, int initial)
85268525
}
85278526
else {
85288527
// tp_new is NULL: inherit tp_new from base
8529-
type->tp_new = base->tp_new;
8528+
if (initial) {
8529+
type->tp_new = base->tp_new;
8530+
}
8531+
else {
8532+
assert(type->tp_new == base->tp_new);
8533+
}
85308534
}
85318535
}
85328536
else {

0 commit comments

Comments
 (0)