Skip to content

Commit 2bb60d9

Browse files
committed
Add mutex for get_mimalloc_allocated_blocks
1 parent 3c208c2 commit 2bb60d9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Objects/obmalloc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,7 @@ get_mimalloc_allocated_blocks(PyInterpreterState *interp)
14051405
{
14061406
size_t allocated_blocks = 0;
14071407
#ifdef Py_GIL_DISABLED
1408+
INTERP_HEAD_LOCK(interp);
14081409
for (PyThreadState *t = interp->threads.head; t != NULL; t = t->next) {
14091410
_PyThreadStateImpl *tstate = (_PyThreadStateImpl *)t;
14101411
for (int i = 0; i < _Py_MIMALLOC_HEAP_COUNT; i++) {
@@ -1418,6 +1419,7 @@ get_mimalloc_allocated_blocks(PyInterpreterState *interp)
14181419
_mi_abandoned_pool_visit_blocks(pool, tag, false, &count_blocks,
14191420
&allocated_blocks);
14201421
}
1422+
INTERP_HEAD_UNLOCK(interp);
14211423
#else
14221424
// TODO(sgross): this only counts the current thread's blocks.
14231425
mi_heap_t *heap = mi_heap_get_default();

0 commit comments

Comments
 (0)