uwiger / locks

A scalable, deadlock-resolving resource locker
Mozilla Public License 2.0
205 stars 26 forks source link

Message lost of `locks_running` -- may cause deadlock #38

Open xinhaoyuan opened 6 years ago

xinhaoyuan commented 6 years ago

locks_watcher is notified by

https://github.com/uwiger/locks/blob/8e9b2e33deec6ed375a38fc88f67eff792b91504/src/locks_server.erl#L64

However, the message could be lost if a locks_server is started after

https://github.com/uwiger/locks/blob/8e9b2e33deec6ed375a38fc88f67eff792b91504/src/locks_watcher.erl#L23

but the message is sent before the name locks_watcher is registered.

https://github.com/uwiger/locks/blob/8e9b2e33deec6ed375a38fc88f67eff792b91504/src/locks_watcher.erl#L26

uwiger commented 4 years ago

@xinhaoyuan sorry for the long delay, but would you like to inspect the proposed fix?

xinhaoyuan commented 4 years ago

Hi @uwiger, thanks for asking. The fix looks good and should fix the bug reported.

This bug was found using Morpheus, a concurrency testing tool for Erlang. I am no longer working on the project, but I will try to run the tool on the fixed version and let you know if there are any issues.