deno
15fdc6e6 - fix(core): make uv_compat ready queues thread-safe (#35175)

Commit
130 days ago
fix(core): make uv_compat ready queues thread-safe (#35175) The per-handle waker ready queues in the libuv compat layer used RefCell/Cell behind an unsafe Send/Sync assertion that the event loop is single-threaded. On Windows that invariant does not hold: TTY readiness is delivered by a thread pool wait callback registered with RegisterWaitForSingleObject, and line-mode console reads complete on a dedicated reader thread; both invoke the per-handle waker off the loop thread. A wake racing the run_io drain panicked with "RefCell already borrowed" at uv_compat.rs:609, and was a genuine data race since RefCell's borrow flag is not atomic. This switches the ready queues to Mutex<VecDeque>, the per-handle ptr/in_queue fields to atomics, and drops the unsafe Send/Sync impls so thread safety is enforced by the compiler. The mutexes are uncontended on the single-threaded hot path. A regression test hammers a waker from multiple threads while draining, mirroring the run_io loop. Fixes #35171
Author
Parents
Loading