René's URL Explorer Experiment


Title: gh-145615: Fix mimalloc page leak in the free-threaded build by colesbury · Pull Request #145626 · python/cpython · GitHub

Open Graph Title: gh-145615: Fix mimalloc page leak in the free-threaded build by colesbury · Pull Request #145626 · python/cpython

X Title: gh-145615: Fix mimalloc page leak in the free-threaded build by colesbury · Pull Request #145626 · python/cpython

Description: Fix three issues that caused mimalloc pages to be leaked until the owning thread exited: 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. 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. 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. Issue: gh-145615

Open Graph Description: Fix three issues that caused mimalloc pages to be leaked until the owning thread exited: In _PyMem_mi_page_maybe_free(), move pages out of the full queue when relying on QSBR to defer freeing the...

X Description: Fix three issues that caused mimalloc pages to be leaked until the owning thread exited: In _PyMem_mi_page_maybe_free(), move pages out of the full queue when relying on QSBR to defer freeing the...

Opengraph URL: https://github.com/python/cpython/pull/145626

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6a3f4005-8d1a-9f52-252a-68b23bb13c60
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA0FA:3A73AA:3517927:4347F4C:6B021981
html-safe-nonce986caef89113e42f85b24f90a9bc959c778aeb6ec54e99145e6d0e2770373068
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEZBOjNBNzNBQTozNTE3OTI3OjQzNDdGNEM6NkIwMjE5ODEiLCJ2aXNpdG9yX2lkIjoiNjg0NTAzNDk1NTA1MjAzMDMzNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace68b9b71671f7023cd4faba4497e4b063e3bbf685e951fe92cd5e35c8045ff8d
hovercard-subject-tagpull_request:3367856943
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/145626/files
twitter:imagehttps://avatars.githubusercontent.com/u/655866?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/655866?s=400&v=4
og:image:altFix three issues that caused mimalloc pages to be leaked until the owning thread exited: In _PyMem_mi_page_maybe_free(), move pages out of the full queue when relying on QSBR to defer freeing the...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/145626/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F145626%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F145626%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/145626/files
Reloadhttps://github.com/python/cpython/pull/145626/files
Reloadhttps://github.com/python/cpython/pull/145626/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
colesburyhttps://github.com/colesbury
python:mainhttps://github.com/python/cpython/tree/main
colesbury:gh-145615-fix-mimalloc-page-leakhttps://github.com/colesbury/cpython/tree/gh-145615-fix-mimalloc-page-leak
Conversation 9 https://github.com/python/cpython/pull/145626
Commits 4 https://github.com/python/cpython/pull/145626/commits
Checks 60 https://github.com/python/cpython/pull/145626/checks
Files changed https://github.com/python/cpython/pull/145626/files
Please reload this pagehttps://github.com/python/cpython/pull/145626/files
gh-145615: Fix mimalloc page leak in the free-threaded build https://github.com/python/cpython/pull/145626/files#top
Show all changes 4 commits https://github.com/python/cpython/pull/145626/files
218b6bf gh-145615: Fix mimalloc page leak in the free-threaded build colesbury Mar 7, 2026 https://github.com/python/cpython/pull/145626/commits/218b6bfeb600f2b8d9bbcbe5756260deb05c016a
4d059c9 Fix page queue mismatch in mi_heap_page_collect colesbury Mar 7, 2026 https://github.com/python/cpython/pull/145626/commits/4d059c9e6b83e2513d39f18bf5f1ca3726fc55ea
ebd5980 Extract tstate_from_heap helper in obmalloc.c colesbury Mar 7, 2026 https://github.com/python/cpython/pull/145626/commits/ebd5980d09be6fc3e1d73967f9f12a6de5d769a1
2516a1a Fix build error in default build. colesbury Mar 7, 2026 https://github.com/python/cpython/pull/145626/commits/2516a1a739af93585bee30b71753dbef17248a86
Clear filters https://github.com/python/cpython/pull/145626/files
Please reload this pagehttps://github.com/python/cpython/pull/145626/files
Please reload this pagehttps://github.com/python/cpython/pull/145626/files
2026-03-06-21-05-05.gh-issue-145615.NKXXZgDW.rst https://github.com/python/cpython/pull/145626/files#diff-ffc755b7423598b4c92cadf609394840de8912f6edc038d8e1cf9968836ad530
heap.c https://github.com/python/cpython/pull/145626/files#diff-ae0250dd9cdb3494b4cf82a71ded8e6d2248706633bf4cd57232cb1d462cc235
page.c https://github.com/python/cpython/pull/145626/files#diff-77053287ca156d69f2c9e8f7ceaa69a3745c94cfe0318e95290ca716e77591b5
segment.c https://github.com/python/cpython/pull/145626/files#diff-681c38645311cef2625d595f206d32df0ffe84138f6860bf93026f29b330fcef
obmalloc.c https://github.com/python/cpython/pull/145626/files#diff-399a22135f328b4e42b0722ef216587945eedf2d8c103a584a3dca5b30650329
.../NEWS.d/next/Core_and_Builtins/2026-03-06-21-05-05.gh-issue-145615.NKXXZgDW.rsthttps://github.com/python/cpython/pull/145626/files#diff-ffc755b7423598b4c92cadf609394840de8912f6edc038d8e1cf9968836ad530
View file https://github.com/colesbury/cpython/blob/2516a1a739af93585bee30b71753dbef17248a86/Misc/NEWS.d/next/Core_and_Builtins/2026-03-06-21-05-05.gh-issue-145615.NKXXZgDW.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/145626/{{ revealButtonHref }}
Objects/mimalloc/heap.chttps://github.com/python/cpython/pull/145626/files#diff-ae0250dd9cdb3494b4cf82a71ded8e6d2248706633bf4cd57232cb1d462cc235
View file https://github.com/colesbury/cpython/blob/2516a1a739af93585bee30b71753dbef17248a86/Objects/mimalloc/heap.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/145626/{{ revealButtonHref }}
https://github.com/python/cpython/pull/145626/files#diff-ae0250dd9cdb3494b4cf82a71ded8e6d2248706633bf4cd57232cb1d462cc235
https://github.com/python/cpython/pull/145626/files#diff-ae0250dd9cdb3494b4cf82a71ded8e6d2248706633bf4cd57232cb1d462cc235
Objects/mimalloc/page.chttps://github.com/python/cpython/pull/145626/files#diff-77053287ca156d69f2c9e8f7ceaa69a3745c94cfe0318e95290ca716e77591b5
View file https://github.com/colesbury/cpython/blob/2516a1a739af93585bee30b71753dbef17248a86/Objects/mimalloc/page.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/145626/{{ revealButtonHref }}
https://github.com/python/cpython/pull/145626/files#diff-77053287ca156d69f2c9e8f7ceaa69a3745c94cfe0318e95290ca716e77591b5
https://github.com/python/cpython/pull/145626/files#diff-77053287ca156d69f2c9e8f7ceaa69a3745c94cfe0318e95290ca716e77591b5
https://github.com/python/cpython/pull/145626/files#diff-77053287ca156d69f2c9e8f7ceaa69a3745c94cfe0318e95290ca716e77591b5
Objects/mimalloc/segment.chttps://github.com/python/cpython/pull/145626/files#diff-681c38645311cef2625d595f206d32df0ffe84138f6860bf93026f29b330fcef
View file https://github.com/colesbury/cpython/blob/2516a1a739af93585bee30b71753dbef17248a86/Objects/mimalloc/segment.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/145626/{{ revealButtonHref }}
https://github.com/python/cpython/pull/145626/files#diff-681c38645311cef2625d595f206d32df0ffe84138f6860bf93026f29b330fcef
https://github.com/python/cpython/pull/145626/files#diff-681c38645311cef2625d595f206d32df0ffe84138f6860bf93026f29b330fcef
https://github.com/python/cpython/pull/145626/files#diff-681c38645311cef2625d595f206d32df0ffe84138f6860bf93026f29b330fcef
https://github.com/python/cpython/pull/145626/files#diff-681c38645311cef2625d595f206d32df0ffe84138f6860bf93026f29b330fcef
Objects/obmalloc.chttps://github.com/python/cpython/pull/145626/files#diff-399a22135f328b4e42b0722ef216587945eedf2d8c103a584a3dca5b30650329
View file https://github.com/colesbury/cpython/blob/2516a1a739af93585bee30b71753dbef17248a86/Objects/obmalloc.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/145626/{{ revealButtonHref }}
https://github.com/python/cpython/pull/145626/files#diff-399a22135f328b4e42b0722ef216587945eedf2d8c103a584a3dca5b30650329
https://github.com/python/cpython/pull/145626/files#diff-399a22135f328b4e42b0722ef216587945eedf2d8c103a584a3dca5b30650329
https://github.com/python/cpython/pull/145626/files#diff-399a22135f328b4e42b0722ef216587945eedf2d8c103a584a3dca5b30650329
https://github.com/python/cpython/pull/145626/files#diff-399a22135f328b4e42b0722ef216587945eedf2d8c103a584a3dca5b30650329
Please reload this pagehttps://github.com/python/cpython/pull/145626/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.