Skip to content

task: disallow blocking in LocalSet::{poll,drop} #7372

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Darksonn
Copy link
Contributor

Closes: #7368

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-task Module: tokio/task M-blocking Module: tokio/task/blocking labels May 28, 2025
@Darksonn Darksonn changed the title task: disallow blocking in LocalSet::{poll,drop} task: disallow blocking in LocalSet::{poll,drop} May 28, 2025
let reset = CONTEXT.with(|c| {
let reset = CONTEXT.try_with(|c| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth aligning here too?

CONTEXT.with(|c| {

I think drop still gets panic if CONTEXT.try_with returns Err when constructing a DisallowBlockInPlaceGuard.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the first try_with fails, then the guard stores false so the if makes us skip that CONTEXT.with call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that if condition, never mind.

Copy link
Member

@mox692 mox692 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-blocking Module: tokio/task/blocking M-task Module: tokio/task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

block_in_place doesn't panic on a spawn_local task
2 participants