Skip to content

Commit 7bda1e4

Browse files
colesburyDinoV
authored andcommitted
mimalloc: minimal changes for use in Python
- remove debug spam for freeing large allocations - use same bytes (0xDD) for freed allocations in CPython and mimalloc This is important for the test_capi debug memory tests
1 parent d3a3a12 commit 7bda1e4

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Include/mimalloc/mimalloc/types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ struct mi_heap_s {
524524
#define MI_DEBUG_UNINIT (0xD0)
525525
#endif
526526
#if !defined(MI_DEBUG_FREED)
527-
#define MI_DEBUG_FREED (0xDF)
527+
#define MI_DEBUG_FREED (0xDD)
528528
#endif
529529
#if !defined(MI_DEBUG_PADDING)
530530
#define MI_DEBUG_PADDING (0xDE)

Objects/mimalloc/alloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static inline mi_segment_t* mi_checked_ptr_segment(const void* p, const char* ms
533533
mi_segment_t* const segment = _mi_ptr_segment(p);
534534
mi_assert_internal(segment != NULL);
535535

536-
#if (MI_DEBUG>0)
536+
#if 0 && (MI_DEBUG>0)
537537
if mi_unlikely(!mi_is_in_heap_region(p)) {
538538
#if (MI_INTPTR_SIZE == 8 && defined(__linux__))
539539
if (((uintptr_t)p >> 40) != 0x7F) { // linux tends to align large blocks above 0x7F000000000 (issue #640)

Objects/mimalloc/os.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ static void* mi_os_prim_alloc_aligned(size_t size, size_t alignment, bool commit
240240
}
241241
else {
242242
// if not aligned, free it, overallocate, and unmap around it
243-
_mi_warning_message("unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x%zx bytes, address: %p, alignment: 0x%zx, commit: %d)\n", size, p, alignment, commit);
243+
// NOTE(sgross): this warning causes issues in Python tests
244+
// _mi_warning_message("unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x%zx bytes, address: %p, alignment: 0x%zx, commit: %d)\n", size, p, alignment, commit);
244245
mi_os_prim_free(p, size, commit, stats);
245246
if (size >= (SIZE_MAX - alignment)) return NULL; // overflow
246247
const size_t over_size = size + alignment;

0 commit comments

Comments
 (0)