Title: `_PyMem_mi_page_maybe_free` may insert pages into wrong thread's list · Issue #145614 · python/cpython · GitHub
Open Graph Title: `_PyMem_mi_page_maybe_free` may insert pages into wrong thread's list · Issue #145614 · python/cpython
X Title: `_PyMem_mi_page_maybe_free` may insert pages into wrong thread's list · Issue #145614 · python/cpython
Description: Bug report In the free threading build, _PyMem_mi_page_maybe_free is called on mimalloc pages when they're about to be freed. We delay freeing of some pages in case another thread may be concurrently accessing it. In the meantime, they'r...
Open Graph Description: Bug report In the free threading build, _PyMem_mi_page_maybe_free is called on mimalloc pages when they're about to be freed. We delay freeing of some pages in case another thread may be concurrent...
X Description: Bug report In the free threading build, _PyMem_mi_page_maybe_free is called on mimalloc pages when they're about to be freed. We delay freeing of some pages in case another thread may be concur...
Opengraph URL: https://github.com/python/cpython/issues/145614
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_PyMem_mi_page_maybe_free` may insert pages into wrong thread's list","articleBody":"# Bug report\n\nIn the free threading build, `_PyMem_mi_page_maybe_free` is called on mimalloc pages when they're about to be freed. We delay freeing of some pages in case another thread may be concurrently accessing it. In the meantime, they're stored on the `tstate->mimalloc.page_list` linked list.\n\n`_PyMem_mi_page_maybe_free` inserts the page into the *current thread's* list. However, during GC and other stop-the-world pauses, we may traverse the heaps of other threads. That traversal does some processing of free lists, which can end up calling `_PyMem_mi_page_maybe_free`. In that case, we should insert the page into the *owning thread's* list, **not** the current thread's list. Otherwise, we can end up with a data race later on.\n\nFor more background see:\nhttps://github.com/python/cpython/blob/main/InternalDocs/qsbr.md","author":{"url":"https://github.com/colesbury","@type":"Person","name":"colesbury"},"datePublished":"2026-03-06T21:38:06Z","url":"https://github.com/python/cpython/issues/145614"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:270c640a-0c58-7481-65c9-e89e4856fed5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ECDA:23E48:11108C:159409:6B01FE9E |
| html-safe-nonce | 214c134208f64a96e10d84fa7dd778db58513e1444f5d8588958ad55d27c9070 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0RBOjIzRTQ4OjExMTA4QzoxNTk0MDk6NkIwMUZFOUUiLCJ2aXNpdG9yX2lkIjoiNzE3MTU4MzQ4MzIzMDQyMDYzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 237c2e8306f33f8c0297983bc518107ffb6539efe53d498042e544b136f7c284 |
| hovercard-subject-tag | issue:4036283314 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/145614/issue_layout |
| twitter:image | https://opengraph.githubassets.com/19632a06922e98b21d6f424ad1e3abd851baebcd20c6de34a6d14a73578b1670/python/cpython/issues/145614 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/19632a06922e98b21d6f424ad1e3abd851baebcd20c6de34a6d14a73578b1670/python/cpython/issues/145614 |
| og:image:alt | Bug report In the free threading build, _PyMem_mi_page_maybe_free is called on mimalloc pages when they're about to be freed. We delay freeing of some pages in case another thread may be concurrent... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | colesbury |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width