From f630b432850be63fcc626e07157950d749008b72 Mon Sep 17 00:00:00 2001 From: Alex Mikheev Date: Wed, 26 Oct 2016 11:15:06 +0300 Subject: [PATCH 1/2] OSHMEM: fixes crash during initialization Do not call mpi comm_dup() if mpi failed to initialize. Also do not set signal handlers. Small code styling fixes. Signed-off-by: Alex Mikheev --- oshmem/runtime/oshmem_shmem_init.c | 46 ++++++++++++++++-------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/oshmem/runtime/oshmem_shmem_init.c b/oshmem/runtime/oshmem_shmem_init.c index 658fb34d03..0733d0d718 100644 --- a/oshmem/runtime/oshmem_shmem_init.c +++ b/oshmem/runtime/oshmem_shmem_init.c @@ -149,35 +149,37 @@ int oshmem_shmem_init(int argc, char **argv, int requested, int *provided) if (!ompi_mpi_initialized && !ompi_mpi_finalized) { ret = ompi_mpi_init(argc, argv, requested, provided); } + + if (OSHMEM_SUCCESS != ret) { + return ret; + } + PMPI_Comm_dup(MPI_COMM_WORLD, &oshmem_comm_world); + ret = _shmem_init(argc, argv, requested, provided); - if (OSHMEM_SUCCESS == ret) { - ret = _shmem_init(argc, argv, requested, provided); + if (OSHMEM_SUCCESS != ret) { + return ret; + } + oshmem_shmem_initialized = true; + + if (OSHMEM_SUCCESS != shmem_lock_init()) { + SHMEM_API_ERROR( "shmem_lock_init() failed"); + return OSHMEM_ERROR; } - if (OSHMEM_SUCCESS == ret) { - oshmem_shmem_initialized = true; + /* this is a collective op, implies barrier */ + MCA_MEMHEAP_CALL(get_all_mkeys()); - if (OSHMEM_SUCCESS != shmem_lock_init()) { - SHMEM_API_ERROR( "shmem_lock_init() failed"); - return OSHMEM_ERROR; - } - - /* this is a collective op, implies barrier */ - MCA_MEMHEAP_CALL(get_all_mkeys()); - - oshmem_shmem_preconnect_all(); + oshmem_shmem_preconnect_all(); #if OSHMEM_OPAL_THREAD_ENABLE - pthread_t thread_id; - int perr; - perr = pthread_create(&thread_id, NULL, &shmem_opal_thread, NULL); - if (perr != 0) - { - SHMEM_API_ERROR("cannot creat opal thread for SHMEM"); - return OSHMEM_ERROR; - } -#endif + pthread_t thread_id; + int perr; + perr = pthread_create(&thread_id, NULL, &shmem_opal_thread, NULL); + if (0 != perr) { + SHMEM_API_ERROR("cannot creat opal thread for SHMEM"); + return OSHMEM_ERROR; } +#endif } #ifdef SIGUSR1 signal(SIGUSR1,sighandler__SIGUSR1); From 511dd437362c94a9a0b08a07a9b600ba13f1c3b7 Mon Sep 17 00:00:00 2001 From: Alex Mikheev Date: Thu, 27 Oct 2016 09:27:45 +0300 Subject: [PATCH 2/2] oshmem: fixes typo in the error message Signed-off-by: Alex Mikheev --- oshmem/runtime/oshmem_shmem_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oshmem/runtime/oshmem_shmem_init.c b/oshmem/runtime/oshmem_shmem_init.c index 0733d0d718..d5d1281e4a 100644 --- a/oshmem/runtime/oshmem_shmem_init.c +++ b/oshmem/runtime/oshmem_shmem_init.c @@ -176,7 +176,7 @@ int oshmem_shmem_init(int argc, char **argv, int requested, int *provided) int perr; perr = pthread_create(&thread_id, NULL, &shmem_opal_thread, NULL); if (0 != perr) { - SHMEM_API_ERROR("cannot creat opal thread for SHMEM"); + SHMEM_API_ERROR("cannot create opal thread for SHMEM"); return OSHMEM_ERROR; } #endif