Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.concurrency

Do not hold a Mutex guard across await

Holding a std::sync::Mutex guard across an await point can deadlock the async executor.

#Metadata

Rule ID
rust.correctness.mutex-held-across-await
Severity
high
Confidence
0.85
Languages
rust
Presets
strict
Stability
stable
Applies to
block
Tags
concurrency, correctness, rules-catalog, rust

#Why it matters

A `std::sync::Mutex` guard must not be held while the task yields at `.await`. Use an async mutex or release the guard before awaiting.

#Remediation

Drop the guard before awaiting or switch to `tokio::sync::Mutex` for async code.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/rust/rust.correctness.mutex-held-across-await.rule.yaml.