hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.42k stars 1.59k forks source link

h2/client(1.0.0-rc4): panic on a double poll on Select #3289

Closed lucab closed 1 year ago

lucab commented 1 year ago

Version

hyper 1.0.0-rc4

Platform

Linux 5.15.109+ SMP x86_64 GNU/Linux

Description

Deno is currently using the RC versions of hyper 1.0 and it recently upgraded from -rc3 to -rc4: https://github.com/denoland/deno/pull/19987.

After that we started seeing occasional but frequent panics due to a double poll on a Select future:

thread 'main' panicked at 'cannot poll Select twice', ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/select.rs:112:42
stack backtrace:
   0: rust_begin_unwind
             at ./rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at ./rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:67:14
   2: core::panicking::panic_display
             at ./rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:150:5
   3: core::panicking::panic_str
             at ./rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:134:5
   4: core::option::expect_failed
             at ./rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/option.rs:1932:5
   5: <futures_util::future::select::Select<A,B> as core::future::future::Future>::poll
   6: <hyper::proto::h2::client::H2ClientFuture<B,T> as core::future::future::Future>::poll
   7: tokio::runtime::task::harness::Harness<T,S>::poll
   8: tokio::runtime::scheduler::current_thread::Context::run_task
   9: tokio::macros::scoped_tls::ScopedKey<T>::set
  10: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
  11: tokio::runtime::runtime::Runtime::block_on
  12: <omitted>::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I don't have a reproducer or a test for this, which I think is the result of a race.

lucab commented 1 year ago

I can't bisect this, but looking through the git-log I think this is a regression introduced in https://github.com/hyperium/hyper/pull/3184.

I put together https://github.com/hyperium/hyper/pull/3290 to hopefully fix this.