From 8ee5bd55c9e32339fede36704c416a3306d42a2a Mon Sep 17 00:00:00 2001 From: Kohei Hiraga Date: Thu, 25 Jan 2024 17:16:36 +0900 Subject: [PATCH] romio: Fix wrong communicator use in ADIOI_GEN_OpenColl When ADIOI_GEN_OpenColl is called in ADIO_CREAT mode, file creation is done by calling ADIOI_xxx_Open with MPI_COMM_SELF by rank == fd->hints->ranklist[0]. If successful, the file is closed with ADIOI_xxx_Close, and later the file will be opened by all without creation flag. The problem is that the communicator of ADIOI_GEN_OpenColl is passed to ADIOI_xxx_Close instead of MPI_COMM_SELF. If a collective call is made using this communicator in ADIOI_xxx_Close, it may hang. --- src/mpi/romio/adio/common/ad_opencoll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mpi/romio/adio/common/ad_opencoll.c b/src/mpi/romio/adio/common/ad_opencoll.c index edef3c0e64c..ae0ee4c5d6e 100644 --- a/src/mpi/romio/adio/common/ad_opencoll.c +++ b/src/mpi/romio/adio/common/ad_opencoll.c @@ -80,11 +80,11 @@ void ADIOI_GEN_OpenColl(ADIO_File fd, int rank, int access_mode, int *error_code tmp_comm = fd->comm; fd->comm = MPI_COMM_SELF; (*(fd->fns->ADIOI_xxx_Open)) (fd, error_code); - fd->comm = tmp_comm; - MPI_Bcast(error_code, 1, MPI_INT, fd->hints->ranklist[0], fd->comm); + MPI_Bcast(error_code, 1, MPI_INT, fd->hints->ranklist[0], tmp_comm); /* if no error, close the file and reopen normally below */ if (*error_code == MPI_SUCCESS) (*(fd->fns->ADIOI_xxx_Close)) (fd, error_code); + fd->comm = tmp_comm; fd->access_mode = access_mode; /* back to original */ } else