Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix some potential memory issues with _block MPI datatypes
authordegomme <augustin.degomme@unibas.ch>
Fri, 10 Feb 2017 23:27:03 +0000 (00:27 +0100)
committerdegomme <augustin.degomme@unibas.ch>
Sun, 12 Feb 2017 01:08:28 +0000 (02:08 +0100)
src/smpi/smpi_pmpi.cpp

index 62ca0f1..f95467f 100644 (file)
@@ -2234,7 +2234,7 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount,
 
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
 
-  int* recvcounts=static_cast<int*>(xbt_malloc(count));
+  int* recvcounts=static_cast<int*>(xbt_malloc(count*sizeof(int)));
     for (i=0; i<count;i++)
       recvcounts[i]=recvcount;
     mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts, datatype,  op, comm);
@@ -2462,7 +2462,7 @@ int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI
   } else if (count<0){
     retval = MPI_ERR_COUNT;
   } else {
-    int* blocklens=static_cast<int*>(xbt_malloc(blocklength*count));
+    int* blocklens=static_cast<int*>(xbt_malloc(blocklength*count*sizeof(int)));
     for (i=0; i<count;i++)
       blocklens[i]=blocklength;
     retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
@@ -2498,7 +2498,7 @@ int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indice
   } else if (count<0){
     retval = MPI_ERR_COUNT;
   } else {
-    int* blocklens=(int*)xbt_malloc(blocklength*count);
+    int* blocklens=(int*)xbt_malloc(blocklength*count*sizeof(int));
     for (i=0; i<count;i++)blocklens[i]=blocklength;
     retval = smpi_datatype_hindexed(count, blocklens, indices, old_type, new_type);
     xbt_free(blocklens);