Skip to content

Commit

Permalink
pythongh-115103: Enable internal mimalloc assertions in debug builds
Browse files Browse the repository at this point in the history
This sets `MI_DEBUG` to `2` in debug builds to enable
`mi_assert_internal()` calls. Expensive internal assertions are not
neabled.
  • Loading branch information
colesbury committed Mar 4, 2024
1 parent 88b5c66 commit 01d5d49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Include/internal/pycore_mimalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef enum {
# define MI_DEBUG_FREED PYMEM_DEADBYTE
# define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
#ifdef Py_DEBUG
# define MI_DEBUG 1
# define MI_DEBUG 2
#else
# define MI_DEBUG 0
#endif
Expand Down
3 changes: 3 additions & 0 deletions Objects/mimalloc/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,10 @@ bool _mi_free_delayed_block(mi_block_t* block) {
// get segment and page
const mi_segment_t* const segment = _mi_ptr_segment(block);
mi_assert_internal(_mi_ptr_cookie(segment) == segment->cookie);
#ifndef Py_GIL_DISABLED
// The GC traverses heaps of other threads, which can trigger this assert.
mi_assert_internal(_mi_thread_id() == segment->thread_id);
#endif
mi_page_t* const page = _mi_segment_page_of(segment, block);

// Clear the no-delayed flag so delayed freeing is used again for this page.
Expand Down

0 comments on commit 01d5d49

Please sign in to comment.