Skip to content

Commit 9f27584

Browse files
committed
gh-117657: initialize_new_array
1 parent a657dd5 commit 9f27584

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Include/internal/pycore_qsbr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ _Py_qsbr_register(struct _PyThreadStateImpl *tstate,
140140

141141
// Disassociates a PyThreadState from the QSBR state and frees the QSBR state.
142142
extern void
143-
_Py_qsbr_unregister(struct _PyThreadStateImpl *tstate);
143+
_Py_qsbr_unregister(PyThreadState *tstate);
144144

145145
extern void
146146
_Py_qsbr_fini(PyInterpreterState *interp);

Python/pystate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,7 @@ tstate_delete_common(PyThreadState *tstate)
17851785
HEAD_UNLOCK(runtime);
17861786

17871787
#ifdef Py_GIL_DISABLED
1788-
_Py_qsbr_unregister((_PyThreadStateImpl *)tstate);
1788+
_Py_qsbr_unregister(tstate);
17891789
#endif
17901790

17911791
// XXX Unbind in PyThreadState_Clear(), or earlier

Python/qsbr.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,21 @@ _Py_qsbr_register(_PyThreadStateImpl *tstate, PyInterpreterState *interp,
231231
}
232232

233233
void
234-
_Py_qsbr_unregister(_PyThreadStateImpl *tstate)
234+
_Py_qsbr_unregister(PyThreadState *tstate)
235235
{
236-
struct _qsbr_shared *shared = tstate->qsbr->shared;
236+
struct _qsbr_shared *shared = &tstate->interp->qsbr;
237+
struct _PyThreadStateImpl *tstate_imp = (_PyThreadStateImpl*) tstate;
237238

238239
PyMutex_Lock(&shared->mutex);
239240
// NOTE: we must load (or reload) the thread state's qbsr inside the mutex
240241
// because the array may have been resized (changing tstate->qsbr) while
241242
// we waited to acquire the mutex.
242-
struct _qsbr_thread_state *qsbr = tstate->qsbr;
243+
struct _qsbr_thread_state *qsbr = tstate_imp->qsbr;
243244

244245
assert(qsbr->seq == 0 && "thread state must be detached");
245-
assert(qsbr->allocated && qsbr->tstate == (PyThreadState *)tstate);
246+
assert(qsbr->allocated && qsbr->tstate == tstate);
246247

247-
tstate->qsbr = NULL;
248+
tstate_imp->qsbr = NULL;
248249
qsbr->tstate = NULL;
249250
qsbr->allocated = false;
250251
qsbr->freelist_next = shared->freelist;

Tools/tsan/suppressions_free_threading.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ race:_PyParkingLot_Park
2424
race:_PyType_HasFeature
2525
race:assign_version_tag
2626
race:gc_restore_tid
27-
race:initialize_new_array
2827
race:insertdict
2928
race:lookup_tp_dict
3029
race:mi_heap_visit_pages

0 commit comments

Comments
 (0)