From 6b4bf75dc5f18f192d479a96d7e4be3bd8763ba2 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 8 Sep 2023 16:07:38 +0000 Subject: [PATCH] fix use-after-free in test shutdown --- test/core/client_channel/lb_policy/lb_policy_test_lib.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/core/client_channel/lb_policy/lb_policy_test_lib.h b/test/core/client_channel/lb_policy/lb_policy_test_lib.h index b82e9d9f50355..369804e45df48 100644 --- a/test/core/client_channel/lb_policy/lb_policy_test_lib.h +++ b/test/core/client_channel/lb_policy/lb_policy_test_lib.h @@ -649,6 +649,9 @@ class LoadBalancingPolicyTest : public ::testing::Test { grpc_event_engine::experimental::GetDefaultEventEngine())) {} void TearDown() override { + // Some policies may hop into the WorkSerializer to unref subchannels. + // Need to make sure this gets flushed before the test fixture is destroyed. + WaitForWorkSerializerToFlush(); // Note: Can't safely trigger this from inside the FakeHelper dtor, // because if there is a picker in the queue that is holding a ref // to the LB policy, that will prevent the LB policy from being