Add memory safety guard on SpdyHeaderBlock iterator

This CL  is the result of a multi-day investigation into a test crash. The test was the QUIC end-to-end test, and it had the following line:
EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
Since response_headers() and find() are const, I had a hard time understanding why this line was corrupting memory. As it turns out, dereferencing a SpdyHeaderBlock::iterator actually modifies internal state in order to collapse all header fragments. Except if this is called on invalid memory, the collapsing can do significant damage. So in this test, if the response header did not contain the ":status" header, then it would corrupt memory.

This CL adds a mechanism to help detect this kind of bug, only in debug or asan builds. This CL does not modify behavior at all for opt builds, and does not modify behavior for well-formed programs in debug or asan.

The mechanism works by observing when the SpdyHeaderBlock is about to return an iterator that is out of bounds (equal to end()) , and setting a bool that will be checked on dereference.

This solution might be considered slightly overkill, but I really think it will save debugging time down the road.

Debug/asan-only change

PiperOrigin-RevId: 319248515
Change-Id: I2dc60b48efc97e4b3d1749c5bdae5d53de7cf48f
1 file changed
tree: ce2b407111591e19c31ae85005273f8c4b772f8a
  1. common/
  2. epoll_server/
  3. http2/
  4. quic/
  5. spdy/
  6. CONTRIBUTING.md
  7. LICENSE
  8. README.md
README.md

QUICHE

QUICHE (QUIC, Http/2, Etc) is Google‘s implementation of QUIC and related protocols. It powers Chromium as well as Google’s QUIC servers and some other projects.