Fix heap-use-after-free bug of gcs pub sub testcase (#8968)

This commit is contained in:
fangfengbin 2020-06-16 21:00:37 +08:00 committed by GitHub
parent b68fede30b
commit 4facac023f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,