8000 gh-115103: Enable internal mimalloc assertions in debug builds (#116343) · python/cpython@72714c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 72714c0

Browse files
authored
gh-115103: Enable internal mimalloc assertions in debug builds (#116343)
This sets `MI_DEBUG` to `2` in debug builds to enable `mi_assert_internal()` calls. Expensive internal assertions are not enabled. This also disables an assertion in free-threaded builds that would be triggered by the free-threaded GC because we traverse heaps that are not owned by the current thread.
1 parent dab85e0 commit 72714c0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Include/internal/pycore_mimalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef enum {
2727
# define MI_DEBUG_FREED PYMEM_DEADBYTE
2828
# define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
2929
#ifdef Py_DEBUG
30-
# define MI_DEBUG 1
30+
# define MI_DEBUG 2
3131
#else
3232
# define MI_DEBUG 0
3333
#endif

Objects/mimalloc/alloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,10 @@ bool _mi_free_delayed_block(mi_block_t* block) {
609609
// get segment and page
610610
const mi_segment_t* const segment = _mi_ptr_segment(block);
611611
mi_assert_internal(_mi_ptr_cookie(segment) == segment->cookie);
612+
#ifndef Py_GIL_DISABLED
613+
// The GC traverses heaps of other threads, which can trigger this assert.
612614
mi_assert_internal(_mi_thread_id() == segment->thread_id);
615+
#endif
613616
mi_page_t* const page = _mi_segment_page_of(segment, block);
614617

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

0 commit comments

Comments
 (0)
0