Skip to content
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

Merged
merged 1 commit into from Jan 16, 2018

Conversation

brjsp
Copy link
Contributor

@brjsp brjsp commented Jan 14, 2018

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.

@@ -12,6 +12,8 @@
///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace util
{
struct already_unlocked_t {};
constexpr already_unlocked_t already_unlocked = already_unlocked_t{};
///////////////////////////////////////////////////////////////////////////
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Member

@hkaiser hkaiser left a 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!

@msimberg msimberg merged commit 26fa6ed into STEllAR-GROUP:master Jan 16, 2018
@brjsp brjsp deleted the cv_deadlock_fix branch January 16, 2018 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants