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

Lost waker false positive when task has detatched #380

Closed
davidlattimore opened this issue Sep 25, 2022 · 2 comments
Closed

Lost waker false positive when task has detatched #380

davidlattimore opened this issue Sep 25, 2022 · 2 comments
Labels
S-bug Severity: bug

Comments

@davidlattimore
Copy link
Sponsor

What crate(s) in this repo are involved in the problem?

tokio-console, console-subscriber

What is the issue?

I see there have been false positives in the past, but since #149 is resolved, I'll file a fresh issue for this specific case.

I'm seeing tokio-console reporting that tasks have lost their waker, when in fact the task has finished.

This seems to happen if the task in question spawned another task, but then dropped the join handle for the subtask. The parent task then only shows as complete once the subtask finishes.

How can the bug be reproduced?

The following code is able to reproduce the problem. The warning shows for 10 seconds, then goes away for the next 10 seconds before the program terminates.

use anyhow::Result;
use futures_channel::oneshot;
use std::time::Duration;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
    console_subscriber::init();

    let (send, recv) = oneshot::channel::<()>();

    const DELAY: Duration = Duration::from_secs(10);

    tokio::task::spawn(async move {
        tokio::time::sleep(DELAY).await;
        drop(send);
    });

    // The following task (outer task) finishes almost instantly (the println
    // below is reached). However tokio-console says that it has lost its waker
    // and will never be woken. Only once the inner task finishes is the outer
    // task marked as terminated.
    tokio::task::spawn(async move {
        tokio::task::spawn(async move {
            let _ = recv.await;
        });
    })
    .await
    .unwrap();

    println!("Waiting to finish");

    tokio::time::sleep(DELAY * 2).await;
    Ok(())
}
[package]
name = "t1"
version = "0.1.0"
edition = "2021"

[dependencies]
tokio = { version = "1.20.1" }
console-subscriber = "0.1.8"
anyhow = "1.0.65"
futures-channel = "0.3.24"

Logs, error output, etc

No response

Versions

$
cargo tree | grep console-
├── console-subscriber v0.1.8
│   ├── console-api v0.4.0

$ tokio-console -V
tokio-console 0.1.7

Possible solution

No response

Additional context

No response

Would you like to work on fixing this bug?

maybe

@davidlattimore davidlattimore added the S-bug Severity: bug label Sep 25, 2022
@hds
Copy link
Collaborator

hds commented Apr 17, 2023

This looks like a duplicate of #345.

@hawkw shall we close this one?

@hds
Copy link
Collaborator

hds commented Nov 17, 2023

Closing this as a duplicate of #345. We'll update that issue with further progress.

@hds hds closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-bug Severity: bug
Projects
None yet
Development

No branches or pull requests

2 participants