Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a78f2c0

Browse filesBrowse files
colesburydiegorusso
authored andcommitted
pythongh-115103: Enable internal mimalloc assertions in debug builds (python#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 b50e523 commit a78f2c0
Copy full SHA for a78f2c0

File tree

Expand file treeCollapse file tree

2 files changed

+4
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-1
lines changed

‎Include/internal/pycore_mimalloc.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_mimalloc.h
+1-1Lines 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

Copy file name to clipboardExpand all lines: Objects/mimalloc/alloc.c
+3Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.