Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

gh-145615: Fix mimalloc page leak in the free-threaded build#145626

Draft
colesbury wants to merge 1 commit intopython:mainfrom
colesbury:gh-145615-fix-mimalloc-page-leak
Draft

gh-145615: Fix mimalloc page leak in the free-threaded build#145626
colesbury wants to merge 1 commit intopython:mainfrom
colesbury:gh-145615-fix-mimalloc-page-leak

Conversation

@colesbury
Copy link
Contributor

@colesburycolesbury commentedMar 7, 2026
edited by bedevere-appbot
Loading

Fix three issues that caused mimalloc pages to be leaked until the owning thread exited:

  1. In_PyMem_mi_page_maybe_free(), move pages out of the full queue when relying on QSBR to defer freeing the page. Pages in the full queue are never searched bymi_page_queue_find_free_ex(), so a page left there is unusable for allocations.

  2. Move_PyMem_mi_page_clear_qsbr() from_mi_page_free_collect() to_mi_page_thread_free_collect() where it only fires when all blocks on the page are free (used == 0). The previous placement was too broad: it cleared QSBR state whenever local_free was non-NULL, but_mi_page_free_collect() is called from non-allocation paths (e.g., page visiting inmi_heap_visit_blocks) where the page is not being reused.

  3. In_PyMem_mi_page_maybe_free(), use the page's heap tld to find the correct thread state for QSBR list insertion instead ofPyThreadState_GET(). During stop-the-world pauses, the function may process pages belonging to other threads, so the current thread state is not necessarily the owner of the page.

Fix three issues that caused mimalloc pages to be leaked until theowning thread exited:1. In _PyMem_mi_page_maybe_free(), move pages out of the full queue   when relying on QSBR to defer freeing the page. Pages in the full   queue are never searched by mi_page_queue_find_free_ex(), so a page   left there is unusable for allocations.2. Move _PyMem_mi_page_clear_qsbr() from _mi_page_free_collect() to   _mi_page_thread_free_collect() where it only fires when all blocks   on the page are free (used == 0). The previous placement was too   broad: it cleared QSBR state whenever local_free was non-NULL, but   _mi_page_free_collect() is called from non-allocation paths (e.g.,   page visiting in mi_heap_visit_blocks) where the page is not being   reused.3. In _PyMem_mi_page_maybe_free(), use the page's heap tld to find the   correct thread state for QSBR list insertion instead of   PyThreadState_GET(). During stop-the-world pauses, the function may   process pages belonging to other threads, so the current thread   state is not necessarily the owner of the page.
@colesburycolesbury added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelMar 7, 2026
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@colesbury for commit218b6bf 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F145626%2Fmerge

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelMar 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@colesbury@bedevere-bot

[8]ページ先頭

©2009-2026 Movatter.jp