From 5655d64bd3e064cdd6925b994e555e75d00d0f08 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Fri, 28 Jun 2019 13:37:19 +0900 Subject: [PATCH] mpi/c: fix param checks in [I]Neighbor_alltoall{v,w} do not check some input parameters when an {in,out}degree is zero Thanks Junchao Zhang for analyzing and reporting this issue. Signed-off-by: Gilles Gouaillardet --- ompi/mpi/c/ineighbor_alltoallv.c | 13 +++++++------ ompi/mpi/c/ineighbor_alltoallw.c | 13 ++++++------- ompi/mpi/c/neighbor_alltoallv.c | 11 ++++++----- ompi/mpi/c/neighbor_alltoallw.c | 13 +++++++------ 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/ompi/mpi/c/ineighbor_alltoallv.c b/ompi/mpi/c/ineighbor_alltoallv.c index 9645e15b05..8200718187 100644 --- a/ompi/mpi/c/ineighbor_alltoallv.c +++ b/ompi/mpi/c/ineighbor_alltoallv.c @@ -13,8 +13,8 @@ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2018 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -101,14 +101,15 @@ int MPI_Ineighbor_alltoallv(const void *sendbuf, const int sendcounts[], const i } else if (! OMPI_COMM_IS_TOPO(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY, FUNC_NAME); - } else if ((NULL == sendcounts) || (NULL == sdispls) || - (NULL == recvcounts) || (NULL == rdispls) || - MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree); OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); + if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls))) || + ((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls))) || + MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) { + return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); + } for (i = 0; i < outdegree; ++i) { OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]); OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); diff --git a/ompi/mpi/c/ineighbor_alltoallw.c b/ompi/mpi/c/ineighbor_alltoallw.c index 150f28d717..d27a1a3798 100644 --- a/ompi/mpi/c/ineighbor_alltoallw.c +++ b/ompi/mpi/c/ineighbor_alltoallw.c @@ -13,8 +13,8 @@ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2018 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -101,14 +101,13 @@ int MPI_Ineighbor_alltoallw(const void *sendbuf, const int sendcounts[], const M FUNC_NAME); } - if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) || - (NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) || + err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); + if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes))) || + ((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes))) || MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } - - err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree); - OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); for (i = 0; i < outdegree; ++i) { OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]); OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); diff --git a/ompi/mpi/c/neighbor_alltoallv.c b/ompi/mpi/c/neighbor_alltoallv.c index 44234a6260..4af24fab9c 100644 --- a/ompi/mpi/c/neighbor_alltoallv.c +++ b/ompi/mpi/c/neighbor_alltoallv.c @@ -13,7 +13,7 @@ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2015 Research Organization for Information Science + * Copyright (c) 2014-2019 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ @@ -101,14 +101,15 @@ int MPI_Neighbor_alltoallv(const void *sendbuf, const int sendcounts[], const in } else if (! OMPI_COMM_IS_TOPO(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); - } else if ((NULL == sendcounts) || (NULL == sdispls) || - (NULL == recvcounts) || (NULL == rdispls) || - MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree); OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); + if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls))) || + ((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls))) || + MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) { + return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); + } for (i = 0; i < outdegree; ++i) { OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]); OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); diff --git a/ompi/mpi/c/neighbor_alltoallw.c b/ompi/mpi/c/neighbor_alltoallw.c index 29bf626f8b..7beca2fcf7 100644 --- a/ompi/mpi/c/neighbor_alltoallw.c +++ b/ompi/mpi/c/neighbor_alltoallw.c @@ -13,8 +13,8 @@ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2014-2015 Research Organization for Information Science - * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2019 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved. * $COPYRIGHT$ * @@ -97,14 +97,15 @@ int MPI_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[], const MP } else if (! OMPI_COMM_IS_TOPO(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY, FUNC_NAME); - } else if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) || - (NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) || - MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree); OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); + if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes))) || + ((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes))) || + MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) { + return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); + } for (i = 0; i < outdegree; ++i) { OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]); OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);