8000 gh-115103: Enable internal mimalloc assertions in debug builds by colesbury · Pull Request #116343 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-115103: Enable internal mimalloc assertions in debug builds #116343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-115103: Enable internal mimalloc assertions in debug builds
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.
  • Loading branch information
colesbury committed Mar 4, 2024
commit d336146d9b0619853f6d7b8a313c3f0fd896f653
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