You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any way to detect the deadlock? It would be nice for FutureGuard to return Deadlocked error (just like Canceled error) if there's any prior FutureGuard which belongs to current task. In that case, above example will return Error(Deadlocked) on f.wait() instead of hanging on deadlock.
The text was updated successfully, but these errors were encountered:
As someone who has struggled plenty with deadlocks, I have often considered ways of implementing some sort of detection system. It wouldn't be too hard to add a feature-gated system to detect deadlocks caused by other Qutex/QrwLocks (as in your example) and I would be completely open to adding one. Most deadlocks, however, come from interactions with other, outside, queues and scheduling systems (threads and event loops). Developing a system to detect deadlocks caused by interactions with those systems would be quite an undertaking.
What I often do in my applications is to use a dependency graph to plan out ahead of time, in which order things will be enqueued. Here is a simple example of this. Here is a more complicated example which is rebuildable. If implemented correctly, using graphs like this to schedule tasks which require exclusive access to resources (usually a region of memory, aka. a buffer) will prevent deadlocks from happening in the first place.
I'm interested to hear any other ideas you may have as to what else could/should be done and how they could be implemented.
Here's example code which causes deadlock without unsafe code.
Is there any way to detect the deadlock? It would be nice for
FutureGuard
to returnDeadlocked
error (just likeCanceled
error) if there's any priorFutureGuard
which belongs to current task. In that case, above example will returnError(Deadlocked)
onf.wait()
instead of hanging on deadlock.The text was updated successfully, but these errors were encountered: