diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index e97a544e12c..7774cbf1ba6 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -35,6 +35,7 @@ #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/timer_manager.h" #include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/surface/init.h" #include "src/core/lib/surface/server.h" #include "src/core/lib/transport/metadata.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -1200,5 +1201,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_resource_quota_unref(g_resource_quota); grpc_shutdown(); + grpc_maybe_wait_for_async_shutdown(); return 0; } diff --git a/test/core/util/memory_counters.cc b/test/core/util/memory_counters.cc index a16814febbb..8cc0fedbf0d 100644 --- a/test/core/util/memory_counters.cc +++ b/test/core/util/memory_counters.cc @@ -122,9 +122,9 @@ LeakDetector::LeakDetector(bool enable) : enabled_(enable) { } LeakDetector::~LeakDetector() { + // Wait for grpc_shutdown() to finish its async work. + grpc_maybe_wait_for_async_shutdown(); if (enabled_) { - // Wait for grpc_shutdown() to finish its async work. - grpc_maybe_wait_for_async_shutdown(); struct grpc_memory_counters counters = grpc_memory_counters_snapshot(); if (counters.total_size_relative != 0) { gpr_log(GPR_ERROR, "Leaking %" PRIuPTR " bytes",