Skip to content

Commit f91f31d

Browse files
committed
osc/rdma: Fix MPI_Win_start()/complete() with MPI_GROUP_EMPTY.
- Make sure the epoch type is set before returning from MPI_Win_start(). - Make sure the group is only free'd if it is valid in MPI_Win_complete(). - Fix possible double free() of the group. Signed-off-by: Austen Lauria <[email protected]>
1 parent 9f15410 commit f91f31d

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

ompi/mca/osc/rdma/osc_rdma_active_target.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ int ompi_osc_rdma_start_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t
385385

386386
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "start group size %d", sync->num_peers);
387387

388+
sync->type = OMPI_OSC_RDMA_SYNC_TYPE_PSCW;
389+
388390
if (0 == ompi_group_size (group)) {
389391
/* nothing more to do. this is an empty start epoch */
390392
OPAL_THREAD_UNLOCK(&module->lock);
@@ -393,8 +395,6 @@ int ompi_osc_rdma_start_atomic (ompi_group_t *group, int mpi_assert, ompi_win_t
393395

394396
opal_atomic_wmb ();
395397

396-
sync->type = OMPI_OSC_RDMA_SYNC_TYPE_PSCW;
397-
398398
/* prevent us from entering a passive-target, fence, or another pscw access epoch until
399399
* the matching complete is called */
400400
sync->epoch_active = true;
@@ -466,17 +466,14 @@ int ompi_osc_rdma_complete_atomic (ompi_win_t *win)
466466
sync->type = OMPI_OSC_RDMA_SYNC_TYPE_NONE;
467467
sync->epoch_active = false;
468468

469-
/* phase 2 cleanup group */
470-
OBJ_RELEASE(group);
471-
472469
peers = sync->peer_list.peers;
473470
if (NULL == peers) {
474-
/* empty peer list */
475471
OPAL_THREAD_UNLOCK(&(module->lock));
476-
OBJ_RELEASE(group);
477472
return OMPI_SUCCESS;
478473
}
479474

475+
OBJ_RELEASE(group);
476+
480477
sync->peer_list.peers = NULL;
481478

482479
OPAL_THREAD_UNLOCK(&(module->lock));
@@ -508,7 +505,6 @@ int ompi_osc_rdma_wait_atomic (ompi_win_t *win)
508505
{
509506
ompi_osc_rdma_module_t *module = GET_MODULE(win);
510507
ompi_osc_rdma_state_t *state = module->state;
511-
ompi_group_t *group;
512508
int group_size;
513509

514510
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "wait: %s", win->w_name);
@@ -532,12 +528,12 @@ int ompi_osc_rdma_wait_atomic (ompi_win_t *win)
532528
}
533529

534530
OPAL_THREAD_LOCK(&module->lock);
535-
group = module->pw_group;
531+
if(MPI_GROUP_EMPTY != module->pw_group) {
532+
OBJ_RELEASE(module->pw_group);
533+
}
536534
module->pw_group = NULL;
537535
OPAL_THREAD_UNLOCK(&module->lock);
538536

539-
OBJ_RELEASE(group);
540-
541537
OSC_RDMA_VERBOSE(MCA_BASE_VERBOSE_TRACE, "wait complete");
542538

543539
return OMPI_SUCCESS;

0 commit comments

Comments
 (0)