What I have found is the final reference to a stream being dropped after the maybe_close_connection_if_no_streams but before the inner.poll() completes can lead to the connection dangling forever without any forward progress. No streams/references are alive, but the connection is not complete and never wakes up again. This seems like a classic TOCTOU race condition.
In this fix, I check again at the end of poll and if this state is detected, wake up the task again.
See https://github.com/hyperium/hyper/issues/3652.
What I have found is the final reference to a stream being dropped after the
maybe_close_connection_if_no_streams
but before theinner.poll()
completes can lead to the connection dangling forever without any forward progress. No streams/references are alive, but the connection is not complete and never wakes up again. This seems like a classic TOCTOU race condition.In this fix, I check again at the end of poll and if this state is detected, wake up the task again.
Wth the test in https://github.com/hyperium/hyper/pull/3655, on my machine, it fails about 5% of the time:
With that PR, this test is 100% reliable
Note: we also have reproduced this using
h2
directly outside ofhyper
, which is what gives me confidence this issue lies inh2
and nothyper
.