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

Fix leak in LocalSet #3978

Merged
merged 4 commits into from Jul 22, 2021
Merged

Fix leak in LocalSet #3978

merged 4 commits into from Jul 22, 2021

Conversation

Darksonn
Copy link
Contributor

@Darksonn Darksonn commented Jul 21, 2021

If a task is woken during shutdown, it is possible for it to remain in the shared queue after shutting down the LocalSet, which would be a leak due to a ref-count cycle. This PR provides a fix. The Enable loom test commit was pushed first without the fix to show that the test really fails.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-task Module: tokio/task labels Jul 21, 2021
Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

Makes sense to me. I asked @hawkw to take a quick look as well.

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

this looks right to me, good catch!

use std::task::Poll;

#[test]
fn wake_during_shutdown() {
Copy link
Member

Choose a reason for hiding this comment

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

it would be nice to have a comment explaining what the failure modes of this test are, for future reference? not a blocker though.

Comment on lines +564 to +567
.queue
.lock()
.as_mut()
.and_then(|queue| queue.pop_front())
Copy link
Member

Choose a reason for hiding this comment

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

TIOLI: it seems like queue.lock().as_mut().and_then(|queue| queue.pop_front()) could be worth making a method on Shared, but 🤷‍♀️

@Darksonn Darksonn mentioned this pull request Jul 22, 2021
@Darksonn Darksonn merged commit 998dc5a into master Jul 22, 2021
@Darksonn Darksonn deleted the local-set-leak branch July 22, 2021 10:05
Darksonn added a commit that referenced this pull request Jul 22, 2021
@Darksonn Darksonn mentioned this pull request Jul 22, 2021
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-task Module: tokio/task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants