From 10900f4cec335ea502a3cd5af5c15b2a19e9c8bd Mon Sep 17 00:00:00 2001 From: Boris Karasev Date: Wed, 25 Aug 2021 14:17:55 +0300 Subject: [PATCH] shmem: fix `oshmem_shmem_finalize()` when `main()` returns not zero value. Example: int main(void) { int rc = 0; shmem_init(); if (0 == shmem_my_pe()) rc = 1; shmem_finalize(); return rc; } If the user wants to return not-zero status, this leads to `ompi_mpi_finalize()` won't be called and the program terminates abnormally. Signed-off-by: Boris Karasev (cherry picked from commit ceb9259a0d7aa71c8b1e087374f822ad5be4c5b9) --- oshmem/runtime/oshmem_shmem_finalize.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oshmem/runtime/oshmem_shmem_finalize.c b/oshmem/runtime/oshmem_shmem_finalize.c index bf3ea749ad1..1950e20fdd1 100644 --- a/oshmem/runtime/oshmem_shmem_finalize.c +++ b/oshmem/runtime/oshmem_shmem_finalize.c @@ -53,7 +53,7 @@ #include "oshmem/shmem/shmem_lock.h" #include "oshmem/runtime/oshmem_shmem_preconnect.h" -extern int oshmem_shmem_globalexit_status; +extern int oshmem_shmem_inglobalexit; static int _shmem_finalize(void); @@ -79,7 +79,7 @@ int oshmem_shmem_finalize(void) if ((OSHMEM_SUCCESS == ret) && (state >= OMPI_MPI_STATE_INIT_COMPLETED && state < OMPI_MPI_STATE_FINALIZE_PAST_COMM_SELF_DESTRUCT) && - oshmem_shmem_globalexit_status == 0) { + (oshmem_shmem_inglobalexit == 0)) { PMPI_Comm_free(&oshmem_comm_world); ret = ompi_mpi_finalize(); }