diff --git a/src/core/lib/channel/channel_tracer.cc b/src/core/lib/channel/channel_tracer.cc index 8c58ea2fcce..5f8563fdb9c 100644 --- a/src/core/lib/channel/channel_tracer.cc +++ b/src/core/lib/channel/channel_tracer.cc @@ -89,6 +89,7 @@ ChannelTracer::ChannelTracer(size_t max_nodes) void ChannelTracer::FreeNode(TraceEvent* node) { GRPC_ERROR_UNREF(node->error_); + node->referenced_tracer_.reset(nullptr); grpc_slice_unref_internal(node->data_); gpr_free(node); } diff --git a/test/core/channel/channel_tracer_test.cc b/test/core/channel/channel_tracer_test.cc index 8a107ec5ec5..6166b85ea87 100644 --- a/test/core/channel/channel_tracer_test.cc +++ b/test/core/channel/channel_tracer_test.cc @@ -100,6 +100,7 @@ static void test_basic_channel_tracing(size_t max_nodes) { add_simple_trace(tracer); validate_tracer(tracer, 10, max_nodes); validate_tracer_data_matches_uuid_lookup(tracer); + tracer.reset(nullptr); } // Calls basic test with various values for max_nodes (including 0, which turns @@ -151,6 +152,9 @@ static void test_complex_channel_tracing(size_t max_nodes) { add_simple_trace(tracer); add_simple_trace(tracer); validate_tracer_data_matches_uuid_lookup(tracer); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); } // Calls the complex test with a sweep of sizes for max_nodes. @@ -195,6 +199,10 @@ static void test_nesting() { GRPC_ERROR_NONE, GRPC_CHANNEL_IDLE, sc1); validate_children(tracer, 2); add_simple_trace(tracer); + tracer.reset(nullptr); + sc1.reset(nullptr); + sc2.reset(nullptr); + conn1.reset(nullptr); } int main(int argc, char** argv) {