From 4facac023f936c4840eff1ae7a9f486751aba13e Mon Sep 17 00:00:00 2001 From: fangfengbin <869218239a@zju.edu.cn> Date: Tue, 16 Jun 2020 21:00:37 +0800 Subject: [PATCH] Fix heap-use-after-free bug of gcs pub sub testcase (#8968) --- src/ray/gcs/pubsub/test/gcs_pub_sub_test.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ray/gcs/pubsub/test/gcs_pub_sub_test.cc b/src/ray/gcs/pubsub/test/gcs_pub_sub_test.cc index d0aa3943e..46a9c01bd 100644 --- a/src/ray/gcs/pubsub/test/gcs_pub_sub_test.cc +++ b/src/ray/gcs/pubsub/test/gcs_pub_sub_test.cc @@ -45,9 +45,13 @@ class GcsPubSubTest : public ::testing::Test { pub_sub_.reset(); client_->Disconnect(); io_service_.stop(); - client_.reset(); thread_io_service_->join(); thread_io_service_.reset(); + + // Note: If we immediately reset client_ after io_service_ stop, because client_ still + // has thread executing logic, such as unsubscribe's callback, the problem of heap + // used after free will occur. + client_.reset(); } void Subscribe(const std::string &channel, const std::string &id,