Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix thread safety of suspended coroutines
Summary: Currently we handle `suspended_coroutines` in a non-thread safe way. When we're starting a co-routine we'll use this linked list to see if a task is already suspended. But we then go and run arbitrary Python code after putting an item on this list, and that can swap out the GIL. Then another task can go through this same code path, stomping on the linked list. Because this is a effectively a thread-local operation I just mark variable as being thread-local to fix it. We can't really upstream it in this state (can't rely on optional C11 features), but we can't really upstream it in the previous state either. So this fix seems reasonable for now. I also cleaned up `_is_coro_suspended` so that we treat `Ci_PyGen_IsSuspended` as being definitive and don't consult the list. Reviewed By: AlbertDachiChen Differential Revision: D44713397 fbshipit-source-id: f4c6eb2b055a482354ceb2b489fc57918965cc69
- Loading branch information