Force "Mutex::lock() in async" to be runtime error?

Is there a debug option (okay if it slows down code 10x) to make it a runtime error to call "Mutex::lock()" during an async syntax ?

I'm 99% sure I'm dead locking my code by:
async fn:
* acquire mutex
* get swapped out
--> other async fn: tries to grab mutex, dead locks OS Thread
--> async fn holding the mutex -- can't get swapped back in

As a compile time check instead, the await_holding_lock clippy lint might help. It specifically checks against holding a mutex guard across an await.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.