You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The EventLoop shutdown sequence has race conditions that could cause it to shut
down right before a `removeClient` `write(m_post_fd, ...)` call is about to
happen, if threads run in an unexpected order, and cause the write to fail.
Cases where this can happen are described in
bitcoin/bitcoin#31151 (comment) and the
possible causes are that (1) `EventLoop::m_mutex` is not used to protect some
EventLoop member variables that are accessed from multiple threads,
particularly (`m_num_clients` and `m_async_fns`) and (2) the `removeClient`
method can do unnecessary `write(m_post_fd, ...)` calls before the loop is
supposed to exit because it is not checking the `m_async_fns.empty()`
condition, and these multiple write calls can make the event loop exit early
and cause the final `write()` call to fail. In practice, only the second cause
seems to actually trigger this bug, but PR fixes both possible causes.
Fixesbitcoin/bitcoin#31151
Co-authored-by: Vasil Dimov <[email protected]>
0 commit comments