GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `_PyMem_mi_page_maybe_free` may insert pages into wrong thread's list · Issue #145614 · python/cpython

_PyMem_mi_page_maybe_free may insert pages into wrong thread's list #145614

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
_PyMem_mi_page_maybe_free may insert pages into wrong thread's list#145614
Copy link
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@colesbury
colesbury
opened on Mar 6, 2026
Issue body actions

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're stored on the tstate->mimalloc.page_list linked list.

_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.

For more background see:
https://github.com/python/cpython/blob/main/InternalDocs/qsbr.md

Activity

  1. colesbury
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-free-threading
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    on Mar 6, 2026
  2. colesbury commented on Mar 6, 2026

    @colesbury
    colesbury
    on Mar 6, 2026
    ContributorAuthor
    More actions

    I will put up a PR soon

  3. colesbury commented on Mar 7, 2026

    @colesbury
    colesbury
    on Mar 7, 2026
    ContributorAuthor
    More actions

    I'm going to combine this with #145615 since they're related.

  4. colesbury
    closed this as a duplicateof Free threading memory leak #145615 on Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.