Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find "dangerous" blocking constructs in async contexts (.wait(), block_on, etc.) #4427

Open
emk opened this issue Aug 21, 2019 · 1 comment
Labels
A-lint Area: New lints T-async-await Type: Issues related to async/await

Comments

@emk
Copy link

emk commented Aug 21, 2019

This is related to #4377, which proposed warning about blocking operations like println! inside an async context. That is definitely a promising idea, but it's also very ambitious, because almost anything could block.

But there's also a specific set of blocking constructs that can potentially deadlock the entire tokio (or other) runtime. These include things like calling block_on or .wait inside an async context. There are easy to include by mistake when converting non-async code to async. And there are fewer of these dangerous calls, which would make them easier to lint for.

@emk emk changed the title Find "dangerous" blocking constructs in async contexts Find "dangerous" blocking constructs in async contexts (.wait(), block_on, etc.) Aug 21, 2019
emk added a commit to dbcrossbar/dbcrossbar that referenced this issue Aug 21, 2019
Inside an `async` block, we're support to call `my_future.await`, and
_never_ use the sync-mode blocking equivalent `my_future.wait()`.
Apparently, doing this can deadlock the entire `tokio` runtime, or at
least the portions touching file I/O.

Fixes #16. Fixes #46.

We've also submitted a "lint" proposal to the clippy project which would
automatically detect errors of this class in the future:
rust-lang/rust-clippy#4427
@flip1995 flip1995 added A-lint Area: New lints T-async-await Type: Issues related to async/await labels Aug 26, 2019
@michaelsproul
Copy link
Contributor

Hi @emk! I've built a prototype of this lint which I've been running on CI for the last few months: #9857.

I'm looking for some help to get it to a merge-ready state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints T-async-await Type: Issues related to async/await
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants