Skip to content

Commit 3c7f93f

Browse files
committed
Don't overwhelm the blockLength.
During the optimization process the datatype engine will merge contiguous elements. When this happen adding two integers might result in a "largher than int" value and the resulting datatype will be incorrectly sized. Use size_t instead of int (this is correct because the MPI standard mandates the block lengths to be non-negative numbers). Thanks @albandil for finding the issue and providing a patch. Fixes #11607. Signed-off-by: George Bosilca <[email protected]>
1 parent f881440 commit 3c7f93f

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

ompi/datatype/ompi_datatype_create_struct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ int32_t ompi_datatype_create_struct( int count, const int* pBlockLength, const p
3333
{
3434
ptrdiff_t disp = 0, endto, lastExtent, lastDisp;
3535
ompi_datatype_t *pdt, *lastType;
36-
int lastBlock;
3736
int i, start_from;
37+
size_t lastBlock;
3838

3939
/* Find first non-zero length element */
4040
for( i = 0; (i < count) && (0 == pBlockLength[i]); i++ );

test/datatype/opal_ddt_lib.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,7 @@ static int32_t opal_datatype_create_struct(int count, const int *pBlockLength,
365365
opal_datatype_t **newType)
366366
{
367367
int i;
368-
ptrdiff_t disp = 0, endto, lastExtent, lastDisp;
369-
int lastBlock;
368+
ptrdiff_t disp = 0, endto, lastExtent, lastDisp, lastBlock;
370369
opal_datatype_t *pdt, *lastType;
371370

372371
if (0 == count) {

0 commit comments

Comments
 (0)