Page MenuHomePhabricator

Prevent deadlock in OS Plugins

Authored by JDevlieghere on Apr 12 2018, 12:57 PM.



When performing a synchronous resume, the API mutex is held until the
process is stopped. This is fine, except for when the OS plugins are processing
an event before the main thread is aware of it, in which case we end up with a
deadlock because in the internal thread we acquire a resource lock first, and
then wait for the API lock, while in the main thread we do the opposite, we
already hold the API mutex but are now waiting for the event mutex to handle
the event.

This patch fixes this by relaxing the need for the API lock in the OS plugins.
We can get away with this because we now this code is executed in the main
thread. As stated in the comment above, we just want to ensure nobody else
messes with the API while we're making a change. In theory it's possible that
the main thread would release the lock while we're executing the function, but
prevent this would require a more structural solution (which we want, but do
not have today).

The same workaround was already present, but this patch generalizes it to the
whole file.

This will allow me to re-land r329891.

Diff Detail


Event Timeline

JDevlieghere created this revision.Apr 12 2018, 12:57 PM

Make things a little more consistent.

clayborg accepted this revision.Apr 12 2018, 2:18 PM
This revision is now accepted and ready to land.Apr 12 2018, 2:18 PM
This revision was automatically updated to reflect the committed changes.