Skip to content

Potential panic in FuturesUnordered #2529

@gperinazzo

Description

@gperinazzo

EDIT(taiki-e): The regression that occurred in 0.3.18 has been fixed in 0.3.19, but the underlying problem that 0.3.18 tried to fix has not been fixed yet. This issue has been reused to track that problem as there is a detailed discussion on that problem.


Hey folks,

After upgrading to futures 0.3.18 from 0.3.17, we've noticed our application is panicking under high load. The panic seems to originate in src/stream/futures_unordered/ready_to_run_queue.rs:104 due to the error message inconsistent in drop:

thread 'tokio-runtime-worker' panicked at 'inconsistent in drop', /usr/local/cargo/registry/src/gitproxy.zycloud.tk-1ecc6299db9ec823/futures-util-0.3.18/src/stream/futures_unordered/abort.rs:11:5

 stack backtrace:
    0: rust_begin_unwind
              at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
    1: std::panicking::begin_panic_fmt
              at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:460:5
    2: futures_util::stream::futures_unordered::abort::abort
    3: <futures_util::stream::futures_unordered::FuturesUnordered<Fut> as core::ops::drop::Drop>::drop
    4: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
    5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
    6: <mysql_async::BoxFuture<T> as core::future::future::Future>::poll
    7: <mysql_async::conn::pool::futures::get_conn::GetConn as core::future::future::Future>::poll
    8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
    9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll

This panic causes a double panic that aborts the application. This seems to only happen when under high load, so it may be a race condition that only happens when there's multiple threads running futures from the FuturesUnordered. I haven't been able to create a minimal project to reproduce.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions