[fuzzing] Fix failures found by max_connection_idle_fuzzer (#33487)

In chttp2: a pending but not yet sent goaway should block incoming
requests just like a sent one (we will sent that data momentarily!)

In the test:
- handle the case of the connection idle timeout happening before the
  request arrives at the server
- disable retries, as these cause the request to get stuck (as we don't
  have an additional server to retry on)

Fix b/287897932

---------

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/33494/head
Craig Tiller 1 year ago committed by GitHub
parent 223117fc85
commit b28c4048f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  2. 4
      src/core/ext/transport/chttp2/transport/parsing.cc
  3. 601
      test/core/end2end/end2end_test_corpus/max_connection_idle/clusterfuzz-testcase-minimized-max_connection_idle_fuzzer-5373851475181568
  4. 32
      test/core/end2end/tests/max_connection_idle.cc

@ -1818,8 +1818,9 @@ static void send_goaway(grpc_chttp2_transport* t, grpc_error_handle error,
} else if (t->sent_goaway_state == GRPC_CHTTP2_NO_GOAWAY_SEND ||
t->sent_goaway_state == GRPC_CHTTP2_GRACEFUL_GOAWAY) {
// We want to log this irrespective of whether http tracing is enabled
gpr_log(GPR_DEBUG, "%s: Sending goaway err=%s",
gpr_log(GPR_DEBUG, "%s %s: Sending goaway last_new_stream_id=%d err=%s",
std::string(t->peer_string.as_string_view()).c_str(),
t->is_client ? "CLIENT" : "SERVER", t->last_new_stream_id,
grpc_core::StatusToString(error).c_str());
t->sent_goaway_state = GRPC_CHTTP2_FINAL_GOAWAY_SEND_SCHEDULED;
grpc_chttp2_goaway_append(

@ -625,7 +625,9 @@ static grpc_error_handle init_header_frame_parser(grpc_chttp2_transport* t,
t->settings[GRPC_ACKED_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS])) {
return GRPC_ERROR_CREATE("Max stream count exceeded");
} else if (t->sent_goaway_state == GRPC_CHTTP2_FINAL_GOAWAY_SENT) {
} else if (t->sent_goaway_state == GRPC_CHTTP2_FINAL_GOAWAY_SENT ||
t->sent_goaway_state ==
GRPC_CHTTP2_FINAL_GOAWAY_SEND_SCHEDULED) {
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_INFO,
"transport:%p SERVER peer:%s Final GOAWAY sent. Ignoring new "

@ -0,0 +1,601 @@
event_engine_actions {
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 0
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 0
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
run_delay: 4143972351
connections {
write_size: 0
write_size: 126
write_size: 1241513984
write_size: 7299840
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 10
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 536870912
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 10
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 11993088
write_size: 0
write_size: 0
write_size: 0
write_size: 2785017857
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 126
}
connections {
write_size: 0
write_size: 126
write_size: 7299840
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 1
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 536870912
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 128
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 3080192
write_size: 126
}
connections {
write_size: 2785017857
}
connections {
write_size: 0
write_size: 126
write_size: 7299840
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 1
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 536870912
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 2785017857
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 128
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 0
write_size: 3080192
write_size: 126
}
}

@ -30,8 +30,8 @@
namespace grpc_core {
namespace {
void SimpleRequestBody(CoreEnd2endTest& test) {
auto c = test.NewClientCall("/foo").Timeout(Duration::Seconds(30)).Create();
bool SimpleRequestBody(CoreEnd2endTest& test) {
auto c = test.NewClientCall("/foo").Timeout(Duration::Minutes(1)).Create();
EXPECT_NE(c.GetPeer(), absl::nullopt);
CoreEnd2endTest::IncomingMetadata server_initial_metadata;
CoreEnd2endTest::IncomingStatusOnClient server_status;
@ -43,8 +43,25 @@ void SimpleRequestBody(CoreEnd2endTest& test) {
.RecvInitialMetadata(server_initial_metadata)
.RecvStatusOnClient(server_status);
auto s = test.RequestCall(101);
test.Expect(101, true);
// Connection timeout may expire before we receive the request at the server,
// in which case we'll complete the client call but not the incoming call
// request from the server.
bool saw_request_at_server = false;
bool finished_client = false;
test.Expect(101, CoreEnd2endTest::Maybe{&saw_request_at_server});
test.Expect(1, CoreEnd2endTest::Maybe{&finished_client});
test.Step();
if (finished_client) {
EXPECT_FALSE(saw_request_at_server);
EXPECT_EQ(server_status.status(), GRPC_STATUS_UNAVAILABLE);
test.ShutdownServerAndNotify(1000);
test.Expect(1000, true);
test.Expect(101, false);
test.Step();
return false;
}
EXPECT_FALSE(finished_client);
EXPECT_TRUE(saw_request_at_server);
EXPECT_NE(s.GetPeer(), absl::nullopt);
EXPECT_NE(c.GetPeer(), absl::nullopt);
CoreEnd2endTest::IncomingCloseOnServer client_close;
@ -59,6 +76,7 @@ void SimpleRequestBody(CoreEnd2endTest& test) {
EXPECT_EQ(server_status.message(), "xyz");
EXPECT_EQ(s.method(), "/foo");
EXPECT_FALSE(client_close.was_cancelled());
return true;
}
CORE_END2END_TEST(RetryHttp2Test, MaxConnectionIdle) {
@ -69,8 +87,9 @@ CORE_END2END_TEST(RetryHttp2Test, MaxConnectionIdle) {
.Set(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS,
Duration::Seconds(1).millis())
.Set(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, Duration::Seconds(1).millis())
.Set(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS,
Duration::Seconds(5).millis()));
.Set(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, Duration::Seconds(5).millis())
// Avoid transparent retries for this test.
.Set(GRPC_ARG_ENABLE_RETRIES, false));
InitServer(
ChannelArgs()
.Set(GRPC_ARG_MAX_CONNECTION_IDLE_MS, kMaxConnectionIdle.millis())
@ -90,7 +109,7 @@ CORE_END2END_TEST(RetryHttp2Test, MaxConnectionIdle) {
GRPC_CHANNEL_TRANSIENT_FAILURE));
}
// Use a simple request to cancel and reset the max idle timer
SimpleRequestBody(*this);
if (SimpleRequestBody(*this)) {
// wait for the channel to reach its maximum idle time
WatchConnectivityState(GRPC_CHANNEL_READY,
Duration::Seconds(3) + kMaxConnectionIdle, 99);
@ -104,6 +123,7 @@ CORE_END2END_TEST(RetryHttp2Test, MaxConnectionIdle) {
Expect(1000, true);
Step();
}
}
} // namespace
} // namespace grpc_core

Loading…
Cancel
Save