From 36c1b72b7fce07b7a1797808df3c8808c12694c1 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 16 Nov 2017 00:14:09 +0100 Subject: [PATCH] Fix segfault seen with mpich3-test/perf/nestvec2. --- src/smpi/mpi/smpi_datatype.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/smpi/mpi/smpi_datatype.cpp b/src/smpi/mpi/smpi_datatype.cpp index 4db6870198..2457c8ffdd 100644 --- a/src/smpi/mpi/smpi_datatype.cpp +++ b/src/smpi/mpi/smpi_datatype.cpp @@ -251,7 +251,8 @@ void Datatype::set_name(char* name){ int Datatype::pack(void* inbuf, int incount, void* outbuf, int outcount, int* position,MPI_Comm comm){ if (outcount - *position < incount*static_cast(size_)) return MPI_ERR_BUFFER; - Datatype::copy(inbuf, incount, this, static_cast(outbuf) + *position, outcount, MPI_CHAR); + Datatype::copy(inbuf == MPI_BOTTOM ? nullptr : inbuf, incount, this, static_cast(outbuf) + *position, outcount, + MPI_CHAR); *position += incount * size_; return MPI_SUCCESS; } @@ -283,9 +284,9 @@ int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, if (not smpi_process()->replaying()) memcpy(recvbuf, sendbuf, count); } else if (not(sendtype->flags() & DT_FLAG_DERIVED)) { - recvtype->unserialize( sendbuf, recvbuf, recvcount/recvtype->size(), MPI_REPLACE); + recvtype->unserialize(sendbuf, recvbuf, count / recvtype->size(), MPI_REPLACE); } else if (not(recvtype->flags() & DT_FLAG_DERIVED)) { - sendtype->serialize(sendbuf, recvbuf, sendcount/sendtype->size()); + sendtype->serialize(sendbuf, recvbuf, count / sendtype->size()); }else{ void * buf_tmp = xbt_malloc(count); -- 2.20.1