From 026abb119c42096e428a4f98bd3e15925e2d3a94 Mon Sep 17 00:00:00 2001 From: fangfengbin <869218239a@zju.edu.cn> Date: Tue, 14 Apr 2020 10:34:29 +0800 Subject: [PATCH] fix GrpcServer out-of-bounds bug (#7995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 灵洵 --- src/ray/rpc/grpc_server.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ray/rpc/grpc_server.cc b/src/ray/rpc/grpc_server.cc index 8de493c09..071319aa6 100644 --- a/src/ray/rpc/grpc_server.cc +++ b/src/ray/rpc/grpc_server.cc @@ -24,7 +24,7 @@ namespace rpc { GrpcServer::GrpcServer(std::string name, const uint32_t port, int num_threads) : name_(std::move(name)), port_(port), is_closed_(true), num_threads_(num_threads) { - cqs_.reserve(num_threads_); + cqs_.resize(num_threads_); } void GrpcServer::Run() { @@ -52,7 +52,7 @@ void GrpcServer::Run() { // Get hold of the completion queue used for the asynchronous communication // with the gRPC runtime. for (int i = 0; i < num_threads_; i++) { - cqs_.push_back(builder.AddCompletionQueue()); + cqs_[i] = builder.AddCompletionQueue(); } // Build and start server. server_ = builder.BuildAndStart();