Skip to content

Commit cef7aa0

Browse files
hzhouraffenet
authored andcommitted
group: avoid divide by zero with empty group
Do not set empty group's stride to zero. Alternatively we could add exceptions for empty groups, but it is simpler if the arithmetic can work without exception.
1 parent 9410d2c commit cef7aa0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/mpi/group/grouputil.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ int MPIR_Group_init(void)
2929
MPIR_Group_builtin[0].size = 0;
3030
MPIR_Group_builtin[0].rank = MPI_UNDEFINED;
3131
MPIR_Group_builtin[0].session_ptr = NULL;
32-
memset(&MPIR_Group_builtin[0].pmap, 0, sizeof(struct MPIR_Pmap));
32+
33+
MPIR_Group_builtin[0].pmap.size = 0;
34+
MPIR_Group_builtin[0].pmap.use_map = false;
35+
MPIR_Group_builtin[0].pmap.u.stride.offset = 0;
36+
MPIR_Group_builtin[0].pmap.u.stride.stride = 1;
37+
MPIR_Group_builtin[0].pmap.u.stride.blocksize = 1;
3338

3439
return mpi_errno;
3540
}

0 commit comments

Comments
 (0)