From 222aa616ba2ef470cf8147e88c2787644c73aef3 Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Mon, 8 Jun 2026 05:29:00 -0400 Subject: [PATCH 1/2] Copy fix from mimalloc upstream. --- Objects/mimalloc/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/mimalloc/init.c b/Objects/mimalloc/init.c index 81b241063ff40f..7711c827a58b1c 100644 --- a/Objects/mimalloc/init.c +++ b/Objects/mimalloc/init.c @@ -183,9 +183,9 @@ mi_heap_t* _mi_heap_main_get(void) { // note: in x64 in release build `sizeof(mi_thread_data_t)` is under 4KiB (= OS page size). typedef struct mi_thread_data_s { - mi_heap_t heap; // must come first due to cast in `_mi_heap_done` + mi_heap_t heap; // must come first due to cast in `_mi_heap_done` mi_tld_t tld; - mi_memid_t memid; + mi_memid_t memid; // must come last due to zero'ing } mi_thread_data_t; @@ -231,7 +231,7 @@ static mi_thread_data_t* mi_thread_data_zalloc(void) { } if (td != NULL && !is_zero) { - _mi_memzero_aligned(td, sizeof(*td)); + _mi_memzero_aligned(td, offsetof(mi_thread_data_t,memid)); } return td; } From d91dd5fbf8c9432655c57cc44437111e1608fe1a Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Mon, 8 Jun 2026 05:31:26 -0400 Subject: [PATCH 2/2] Add blurb. --- .../2026-06-08-05-31-22.gh-issue-151065._o_31F.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-05-31-22.gh-issue-151065._o_31F.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-05-31-22.gh-issue-151065._o_31F.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-05-31-22.gh-issue-151065._o_31F.rst new file mode 100644 index 00000000000000..e46c96ef784cc9 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-08-05-31-22.gh-issue-151065._o_31F.rst @@ -0,0 +1 @@ +Fix memory leak when using the :ref:`mimalloc memory allocator `.