Skip to content

Panic when receiving a reset on a stream in the process of closing #246

@hawkw

Description

@hawkw

This is the cause of upstream issue linkerd/linkerd2#607.

It appears that when a stream is in the process of transitioning from Half-Closed (remote) to Closed, with a Trailers frame queued to end that stream, and a Reset (Canceled) frame is received, h2 will hit an expect in prioritize.rs and panic.


Here's the expect that fails:
https://github.com/carllerche/h2/blob/f8baeb7211985834acaf7ecc70548aafd5d9ef6d/src/proto/streams/prioritize.rs#L693-L694

And the relevant logs from @bourquep's panicking Conduit instance:

E  TRCE h2::proto::streams::state send_close: HalfClosedRemote => Closed
E  TRCE h2::proto::streams::send send_trailers -- queuing; frame=Headers { stream_id: StreamId(107), stream_dep: None, flags: HeadersFlag { end_stream: true, end_headers: true, padded: false, priority: false } }
E  TRCE h2::proto::streams::prioritize schedule_send; StreamId(107)
E  TRCE h2::proto::streams::store Queue::push
E  TRCE h2::proto::streams::store  -> first entry
E  TRCE h2::proto::streams::prioritize reserve_capacity; stream=StreamId(107); requested=0; effective=0; curr=0
E  TRCE h2::proto::settings send_pending_ack; pending=None
E  TRCE h2::codec::framed_read poll
E  TRCE h2::codec::framed_read poll; bytes=13B
E  TRCE h2::codec::framed_read decoding frame from 13B
E  TRCE h2::codec::framed_read     -> kind=Reset
E  DBUG h2::codec::framed_read received; frame=Frame::Reset(Reset { stream_id: StreamId(107), error_code: CANCEL })
E  TRCE h2::proto::connection recv RST_STREAM; frame=Reset { stream_id: StreamId(107), error_code: CANCEL }
E  TRCE h2::proto::streams::prioritize clear_queue; stream-id=StreamId(107)
E  TRCE h2::proto::streams::prioritize dropping; frame=Frame::Headers(Headers { stream_id: StreamId(107), stream_dep: None, flags: HeadersFlag { end_stream: true, end_headers: true, padded: false, priority: false } })
E  TRCE h2::proto::settings send_pending_ack; pending=None
E  TRCE h2::codec::framed_read poll
E  TRCE h2::proto::streams::prioritize try reclaim frame
E  TRCE h2::proto::streams::prioritize poll_complete
E  TRCE h2::proto::streams::prioritize schedule_pending_open
E  TRCE h2::proto::streams::prioritize pop_frame
E  TRCE h2::proto::streams::prioritize pop_frame; stream=StreamId(107)
E  thread 'main' panicked at 'must be scheduled to reset', /checkout/src/libcore/option.rs:891:5
E  note: Run with `RUST_BACKTRACE=1` for a backtrace.

More information on the specific case where this issue occurs may be found in linkerd/linkerd2#607.

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