Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138660

QHttp2Stream: dtor missing sendRST_STREAM for some state(s)

    XMLWordPrintable

Details

    • 3
    • d98fd12ca (dev), a79c09d3b (6.10), 4b54ab7e3 (6.9), 499a1ccc0 (tqtc/lts-6.8)

    Description

      It was observed that the stream was not calling "sendRST_STREAM" in its destructor.

       

      Consider following case: 

      stream->sendHEADERS(initialHeaders, false)

      stream->sendDATA(message, closeStream) with closeStream = true

      Now the stream is in "State::HalfClosedLocal" state. Note that "QHttp2Stream::headersReceived" has not been received yet. If this stream dies for whatever reason it will result in an connection error as it's destructor removed it from the m_streams member but didn't sent any RST_STREAM due to its state: 

      QHttp2Stream::~QHttp2Stream() noexcept {
          if (auto *connection = getConnection()) {
              if (m_state == State::Open || m_state == State::HalfClosedRemote) {
                  ...
                  // Check if we can still send data, then send RST_STREAM:
                  if (connection->getSocket()) {
                      if (isUploadingDATA())
                          sendRST_STREAM(CANCEL);
                      else
                          sendRST_STREAM(HTTP2_NO_ERROR);
                  }
              }
      
              connection->m_streams.remove(streamID());
          }
      } 

      Now the code that handles the received headers will not find the stream (it's not marked as reset locally due to the missing call):

       

          } else if (auto it = m_streams.constFind(streamID); it == m_streams.cend()) {
              // RFC 9113, 6.2: HEADERS frames MUST be associated with a stream.
              // A connection error is not required but it seems to be the right thing to do.
              qCDebug(qHttp2ConnectionLog, "[%p] Received HEADERS on non-existent stream %d"this,
                      streamID);
              return connectionError(PROTOCOL_ERROR, "HEADERS on invalid stream");
          } 

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            manordheim Mårten Nordheim
            dennisoberst Dennis Oberst
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes