Closed
Description
I believe rust_sched_driver
has a race that may cause spurious (but harmless) wakeups on Windows:
Order of events:
- Assume
signal()
is called whenstart_main_loop()
is not blocked inlock.wait()
. signal()
will setsignalled = true
and signal the lock (which calls Windows'SetEvent()
API).- When
start_main_loop()
later acquires the lock,signalled
is true, sostart_main_loop()
skips thewait()
and resetssignalled
to false. - At this point,
signalled
is false but the lock's event object is still in the signalled state! - When
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 call ResetEvent()
in step 3.