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

[Wallet] Avoid using re-entrant locks #1767

Open
tmpolaczyk opened this issue Dec 4, 2020 · 0 comments
Open

[Wallet] Avoid using re-entrant locks #1767

tmpolaczyk opened this issue Dec 4, 2020 · 0 comments
Labels
wallet 👛 Issues related to witnet_wallet crate.

Comments

@tmpolaczyk
Copy link
Contributor

tmpolaczyk commented Dec 4, 2020

We have already found a few hard to debug issues because of re-entrant locks in the wallet. This happens when one thread calls RwLock::read one time, and then calls it again without dropping the first handle. This operation will succeed as long as there are no writers waiting for the lock (on Linux, this behavior may change in other platforms).

The simplest solution would be to replace the RwLock with a variant that panics on re-entry. This way we would convert the deadlocks into panics. Unfortunately I don't known of any library that provides something like that, so we would need to do a quick assessment.

The other solution would be to re-think the architecture of the wallet so that the RwLock is not needed, this way we would avoid the problem of deadlocks entirely.

@mariocao mariocao added the wallet 👛 Issues related to witnet_wallet crate. label Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wallet 👛 Issues related to witnet_wallet crate.
Projects
None yet
Development

No branches or pull requests

2 participants