rust_sched_driver race may cause spurious wakeups on Windows #4818
Labels
A-concurrency
Area: Concurrency
A-runtime
Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows
O-windows
Operating system: Windows
I believe
rust_sched_driver
has a race that may cause spurious (but harmless) wakeups on Windows:https://github.com/mozilla/rust/blob/12c32e944d3dbadb6a114a6e0bc51b065b4f42c1/src/rt/rust_sched_driver.cpp#L53
Order of events:
signal()
is called whenstart_main_loop()
is not blocked inlock.wait()
.signal()
will setsignalled = true
and signal the lock (which calls Windows'SetEvent()
API).start_main_loop()
later acquires the lock,signalled
is true, sostart_main_loop()
skips thewait()
and resetssignalled
to false.signalled
is false but the lock's event object is still in the signalled state!start_main_loop()
next acquires the lock,signalled
is false, so the function callswait()
which will return immediately because the event is still in the signalled state.To avoid this problem,
start_main_loop()
would need to callResetEvent()
in step 3.The text was updated successfully, but these errors were encountered: