Skip to content

Commit fc1a504

Browse files
committed
Only do set defaults in the main interpreter
1 parent ee23043 commit fc1a504

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎Objects/obmalloc.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ mi_page_qsbr_should_delay(mi_page_qsbr_t *page, mi_heap_qsbr_t *heap,
199199
int
200200
_PyMem_InitMimalloc(PyInterpreterState *interp)
201201
{
202-
set_mimalloc_defaults();
202+
// mimalloc options are process-wide. Only set them while creating the
203+
// main interpreter: later, other threads may be reading them concurrently.
204+
if (_Py_IsMainInterpreter(interp)) {
205+
set_mimalloc_defaults();
206+
}
203207

204208
size_t base_offset = offsetof(PyObject, ob_type);
205209
if (_PyMem_DebugEnabled()) {

0 commit comments

Comments
 (0)