-
- Downloads
Fix wake_with()
wake_with(action) was implemented using thread_handle, as the following: thread_handle h(handle()); action(); h.wake(); This implementation is wrong: It only takes the RCU lock (which prevents the destruction of _detached_state) during h.wake(), meaning that if the thread is not sleeping, and action() causes it to exit, _detached_state may also be destructed, and h.wake() will crash. thread_handle is simply not needed for wake_with(), and was designed with a completely different use case in mind (long-term holding of a thread handler). We just need to use, in-line, the appropriate rcu lock which keeps _detached_state alive. The resulting code is even simpler, and nicely parallels the existing code of wake(). This patch fixes a real bug, but unfortunately we don't have a concrete test-case which it is known to fix. Signed-off-by:Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Avi Kivity <avi@cloudius-systems.com>
Please register or sign in to comment