Skip to content

Commit f2228c5

Browse files
[3.14] gh-151065: Copy fix for memory leak from mimalloc upstream (GH-151066) (GH-151384)
Applies microsoft/mimalloc@d7a72c4 to our copy of mimalloc. (cherry picked from commit 80f9467) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
1 parent bd314c5 commit f2228c5

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix memory leak when using the :ref:`mimalloc memory allocator <mimalloc>`.

Objects/mimalloc/init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ mi_heap_t* _mi_heap_main_get(void) {
183183

184184
// note: in x64 in release build `sizeof(mi_thread_data_t)` is under 4KiB (= OS page size).
185185
typedef struct mi_thread_data_s {
186-
mi_heap_t heap; // must come first due to cast in `_mi_heap_done`
186+
mi_heap_t heap; // must come first due to cast in `_mi_heap_done`
187187
mi_tld_t tld;
188-
mi_memid_t memid;
188+
mi_memid_t memid; // must come last due to zero'ing
189189
} mi_thread_data_t;
190190

191191

@@ -231,7 +231,7 @@ static mi_thread_data_t* mi_thread_data_zalloc(void) {
231231
}
232232

233233
if (td != NULL && !is_zero) {
234-
_mi_memzero_aligned(td, sizeof(*td));
234+
_mi_memzero_aligned(td, offsetof(mi_thread_data_t,memid));
235235
}
236236
return td;
237237
}

0 commit comments

Comments
 (0)