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

waddrmgr/multi: fix scoped mgr reentry deadlock #18

Merged
merged 1 commit into from
Mar 9, 2018

Conversation

cfromknecht
Copy link

@cfromknecht cfromknecht commented Mar 8, 2018

This commit resolves a deadlock observed when attempting
to generate addresses. There were a few cases, particularly
in chainAddressRowToManaged and loadAccountInfo, which accessed
the public IsLocked() method of the Manager, even though the
shared mutex had already been acquired.

The solution is to create an internal isLocked() method, which
can be safely called assuming the Manager's mutex has already been
acquired. As the comments above both of the methods in question
specify, this is a safe assumption internal to the above methods.

This commit also reduces some unnecessary code duplication, since
the recent changes left both a Locked() and IsLocked() method that
perform the same functionality. IsLocked() was favored as it more
clearly indicates that the returned value is a boolean.

This commit resolves a deadlock observed when attempting
to generate addresses. There were a few cases, particularly
in chainAddressRowToManaged and loadAccountInfo, which accessed
the public IsLocked() method of the Manager, even though the
shared mutex had already been acquired.

The solution is to create an internal isLocked() method, which
can be safely called assuming the manager's mutex has already been
acquired. As the comments above both of the methods in question
specify, we can assume the Manager's mutex *is* already acquired.

This commit also reduces some unnecessary code duplication, since
the recent changes left both a Locked() and IsLocked() method that
perform the same functionality. IsLocked() was favored as it more
clearly indicates that the returned value is a boolean.
Copy link
Owner

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 📈

@Roasbeef Roasbeef merged commit f7f0a70 into Roasbeef:master Mar 9, 2018
cfromknecht added a commit to cfromknecht/lnd that referenced this pull request Mar 9, 2018
This commit bumps the version of btcwallet used in lnd
to incorporate a fix for a reentry deadlock observed during
address creation.

For more information see:
  Roasbeef/btcwallet#18
Mehrrun pushed a commit to Mehrrun/lnd that referenced this pull request Mar 21, 2018
This commit bumps the version of btcwallet used in lnd
to incorporate a fix for a reentry deadlock observed during
address creation.

For more information see:
  Roasbeef/btcwallet#18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants