Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: python/cpython
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: jblespiau/cpython
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fix-asyncio-task-unregister-race
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 13 commits
  • 3 files changed
  • 4 contributors

Commits on Oct 15, 2026

  1. gh-159449: Fix a free-threaded asyncio race that corrupts the task lists

    When a thread exits with pending asyncio Tasks, PyThreadState_Clear() moves them
    onto the shared interp->asyncio_tasks_head list, but each Task still records the
    _Py_ThreadId() of the thread that created it. unregister_task() skips the
    stop-the-world pause whenever that id matches the current thread. That also
    happens for a later thread that reuses the exited thread's pthread_t, and for
    destructors that run later in PyThreadState_Clear(). The resulting unlocked
    llist_remove() calls on the shared list race with each other and can leave an
    already-removed node (next == NULL) linked into it. asyncio.all_tasks(), which
    asyncio.run() calls on shutdown, then crashes with SIGSEGV in
    _asyncio_all_tasks().
    
    Record the unique id (PyThreadState.id) of the creating thread state instead,
    and only take the lock-free path while that thread state is not being cleared.
    
    Also drop the assertion in add_tasks_llist() that every linked Task is pending.
    A Task's state is set before unregister_task() unlinks it, and that removal can
    be waiting for the stop-the-world pause during which the list is walked.
    add_one_task() already filters out Tasks that are done.
    jblespiau committed Oct 15, 2026
    Configuration menu
    Copy the full SHA
    8e75acc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e60bb19 View commit details
    Browse the repository at this point in the history
  3. Remove extra blub-it file.

    jblespiau committed Oct 15, 2026
    Configuration menu
    Copy the full SHA
    acea81d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e79f79e View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2026

  1. Configuration menu
    Copy the full SHA
    78ffcac View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    58c83fc View commit details
    Browse the repository at this point in the history
  3. Merge branch 'main' of https://github.com/python/cpython into fix-asy…

    …ncio-task-unregister-race
    jblespiau committed Nov 2, 2026
    Configuration menu
    Copy the full SHA
    3f23308 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0def8d4 View commit details
    Browse the repository at this point in the history
  5. Restore original comments.

    jblespiau committed Nov 2, 2026
    Configuration menu
    Copy the full SHA
    5a64c43 View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2026

  1. Configuration menu
    Copy the full SHA
    12ea214 View commit details
    Browse the repository at this point in the history
  2. fix comments

    kumaraditya303 committed Nov 5, 2026
    Configuration menu
    Copy the full SHA
    ab6f461 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d472986 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d8ed8d2 View commit details
    Browse the repository at this point in the history
Loading