From 0196483f1b0cd6bbe3dae7a85db822de1c54edf2 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Tue, 10 Aug 2021 12:46:27 +0200 Subject: [PATCH] fix potential leak in replay, as a temporary buffer may be created and never freed. This was seen with a reduce scatter collective from mpich, which creates derived datatypes internally. --- src/smpi/mpi/smpi_request.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 880763c869..2ab04d595b 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -161,7 +161,8 @@ bool Request::match_common(MPI_Request req, MPI_Request sender, MPI_Request rece void Request::init_buffer(int count){ // FIXME Handle the case of a partial shared malloc. // This part handles the problem of non-contiguous memory (for the unserialization at the reception) - if ((((flags_ & MPI_REQ_RECV) != 0) && ((flags_ & MPI_REQ_ACCUMULATE) != 0)) || (type_->flags() & DT_FLAG_DERIVED)) { + if (not smpi_process()->replaying() && + ((((flags_ & MPI_REQ_RECV) != 0) && ((flags_ & MPI_REQ_ACCUMULATE) != 0)) || (type_->flags() & DT_FLAG_DERIVED))) { // This part handles the problem of non-contiguous memory old_buf_ = buf_; if (count==0){ @@ -924,9 +925,9 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status) MPI_Datatype datatype = req->type_; // FIXME Handle the case of a partial shared malloc. - if (((req->flags_ & MPI_REQ_ACCUMULATE) != 0) || - (datatype->flags() & DT_FLAG_DERIVED)) { // && (not smpi_is_shared(req->old_buf_))){ - if (not smpi_process()->replaying() && smpi_switch_data_segment(simgrid::s4u::Actor::self(), req->old_buf_)) + if (not smpi_process()->replaying() && + (((req->flags_ & MPI_REQ_ACCUMULATE) != 0) || (datatype->flags() & DT_FLAG_DERIVED))) { + if (smpi_switch_data_segment(simgrid::s4u::Actor::self(), req->old_buf_)) XBT_VERB("Privatization : We are unserializing to a zone in global memory Switch data segment "); if(datatype->flags() & DT_FLAG_DERIVED){ -- 2.20.1