Avoid crash in QuicDispatcher
Before this CL, when the dispatcher's call to CreateQuicSession returned nullptr, we would crash. This CL changes that to instead log a QUIC_BUG and return. This makes debugging QuicDispatcher tests a lot easier because they now log a test failure instead of crashing and disabling test results.
No behavior change, crash not ever seen in production now logs a gfe_bug instead
PiperOrigin-RevId: 317697386
Change-Id: I21245840870495ac0b4b7b3cef27f10e27ba7cd3
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index ca3f50d..b261690 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -985,7 +985,13 @@
std::unique_ptr<QuicSession> session =
CreateQuicSession(packet_info->destination_connection_id,
packet_info->peer_address, alpn, packet_info->version);
- DCHECK(session);
+ if (QUIC_PREDICT_FALSE(session == nullptr)) {
+ QUIC_BUG << "CreateQuicSession returned nullptr for "
+ << packet_info->destination_connection_id << " from "
+ << packet_info->peer_address << " ALPN \"" << alpn << "\" version "
+ << packet_info->version;
+ return;
+ }
if (original_connection_id != packet_info->destination_connection_id) {
session->connection()->SetOriginalDestinationConnectionId(
original_connection_id);