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

FutureExt::remote_handle causes a silent panic #2900

Open
Hakuyume opened this issue Dec 7, 2024 · 2 comments
Open

FutureExt::remote_handle causes a silent panic #2900

Hakuyume opened this issue Dec 7, 2024 · 2 comments
Labels
A-future Area: futures::future bug

Comments

@Hakuyume
Copy link

Hakuyume commented Dec 7, 2024

The following code causes Exited with status 101.

use futures::FutureExt;

fn main() {
    futures::executor::block_on(async {
        let f = std::future::pending::<()>();
        let (remote, remote_handle) = f.remote_handle();
        // poll remote at least once
        futures::future::select(remote, std::future::ready(())).await;
        remote_handle.await
    });
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d62babe3ab6856b94d7a95fffdb457e4

The expected behavior is pending infinity on remote_handle.await .

@taiki-e
Copy link
Member

taiki-e commented Dec 7, 2024

futures::future::select(remote, std::future::ready(())).await;

I think the panic happened because remote is not cancel-safe and remote_handle was polled after remote was dropped without complete on this line (passing remote by mutable reference works as you expect), but panic without a message is odd anyway.

@taiki-e taiki-e added bug A-future Area: futures::future labels Dec 7, 2024
@Hakuyume
Copy link
Author

Hakuyume commented Dec 7, 2024

I think the panic happened because remote is not cancel-safe

Thank you.

I read the source and found that panic::resume_unwind is used when remote is dropped.

// The oneshot sender was dropped.
Err(e) => panic::resume_unwind(Box::new(e)),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-future Area: futures::future bug
Projects
None yet
Development

No branches or pull requests

2 participants