Skip to content

Commit 8cf7a7e

Browse files
authored
Merge pull request #6538 from bosilca/topic/issue6522
Prevent a segfault when accessing a rank outside a communicator.
2 parents 9bb8fd5 + 6ea0c4e commit 8cf7a7e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ompi/mca/pml/ob1/pml_ob1_comm.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ static inline mca_pml_ob1_comm_proc_t *mca_pml_ob1_peer_lookup (struct ompi_comm
8282
{
8383
mca_pml_ob1_comm_t *pml_comm = (mca_pml_ob1_comm_t *)comm->c_pml_comm;
8484

85+
/**
86+
* We have very few ways to validate the correct, and collective, creation of
87+
* the communicator, and ensure all processes have the same cid. The least we
88+
* can do is to check that we are not using a rank that is outside the scope
89+
* of the communicator.
90+
*/
91+
if( OPAL_UNLIKELY(rank >= (int)pml_comm->num_procs) ) {
92+
ompi_rte_abort(-1, "PML OB1 received a message from a rank outside the"
93+
" valid range of the communicator. Please submit a bug request!");
94+
}
8595
if (OPAL_UNLIKELY(NULL == pml_comm->procs[rank])) {
8696
OPAL_THREAD_LOCK(&pml_comm->proc_lock);
8797
if (NULL == pml_comm->procs[rank]) {

0 commit comments

Comments
 (0)