# Bug report 1. `fi_freelist` isn't thread-safe (move to `pycore_freelist.h` and follow that pattern) 2. `enter_task`, `leave_task`, and `swap_current_task` aren't thread-safe due to shared `state->current_tasks` and borrowed references. 3. `register_task` and `unregister_task` aren't thread-safe due to shared `state->asyncio_tasks` linked list 4. `_asyncio_all_tasks_impl` isn't thread-safe due the the `asyncio_tasks` linked list. For 2, 3, and 4, we can consider using critical sections to protect the accesses to `state->current_tasks` and `state->asyncio_tasks`. Longer term, moving data to per-loop will probably help with multi-threaded scaling. <!-- gh-linked-prs --> ### Linked PRs * gh-122132 * gh-122138 * gh-122139 * gh-122152 * gh-122186 * gh-122317 * gh-122612 * gh-122801 <!-- /gh-linked-prs -->