New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3068 (condition_variable deadlock) #3100
Conversation
hpx/util/unlock_guard.hpp
Outdated
@@ -12,6 +12,8 @@ | |||
/////////////////////////////////////////////////////////////////////////////// | |||
namespace hpx { namespace util | |||
{ | |||
struct already_unlocked_t {}; | |||
constexpr already_unlocked_t already_unlocked = already_unlocked_t{}; | |||
/////////////////////////////////////////////////////////////////////////// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this type used anywhere? AFAICS, the newly added constructor unlock_guard(Mutex& m, already_unlocked_t)
are not called from anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. I at first misread the paper and thought we needed it. It is indeed not used anywhere.
//The following ensures that the inner lock will be unlocked | ||
//before the outer to avoid deadlock (fixes issue #3608) | ||
std::lock_guard <std::unique_lock<mutex_type> > unlock_next | ||
(l, std::adopt_lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use clang-format to adapt the formatting of the newly added lines to our coding guidelines.
abf7ad9
to
6c0f564
Compare
6c0f564
to
1d0e3cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot!
According o @K-ballo, condition_variable_any has even more problems, and condition_variable unnecessarily duplicates its functionality, but this should fix the deadlock bug described in #3068 by alternating the order of destructors.