Skip to content

Commit 2d4b87a

Browse files
ggouaillardetbosilca
authored andcommitted
opal/datatype: fix opal_convertor_raw
correctly handle the case in which iovec is full and the last accessed element of the datatype is the beginning of a loop Refs. #6285 Thanks Axel Huebl for reporting this Signed-off-by: Gilles Gouaillardet <[email protected]> cherry-pick #6295 into 3.1 Signed-off-by: George Bosilca <[email protected]>
1 parent 315c2e6 commit 2d4b87a

File tree

3 files changed

+353
-9
lines changed

3 files changed

+353
-9
lines changed

opal/datatype/opal_convertor_raw.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* reserved.
66
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
77
* Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
8-
* Copyright (c) 2017 Research Organization for Information Science
9-
* and Technology (RIST). All rights reserved.
8+
* Copyright (c) 2017-2019 Research Organization for Information Science
9+
* and Technology (RIST). All rights reserved.
1010
* $COPYRIGHT$
1111
*
1212
* Additional copyrights may follow
@@ -170,9 +170,18 @@ opal_convertor_raw( opal_convertor_t* pConvertor,
170170
ddt_endloop_desc_t* end_loop = (ddt_endloop_desc_t*)(pElem + pElem->loop.items);
171171

172172
if( pElem->loop.common.flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
173-
uint32_t i;
174-
source_base += end_loop->first_elem_disp;
175-
for( i = count_desc; (i > 0) && (index < *iov_count); i--, index++ ) {
173+
ptrdiff_t offset = end_loop->first_elem_disp;
174+
source_base += offset;
175+
for(size_t i = count_desc; i > 0; i--, index++ ) {
176+
if (index >= *iov_count) {
177+
dt_elem_desc_t* nElem = pElem + 1;
178+
while (nElem->elem.common.type == OPAL_DATATYPE_LOOP) {
179+
nElem++;
180+
}
181+
assert(OPAL_DATATYPE_END_LOOP != nElem->elem.common.type);
182+
offset = nElem->elem.disp;
183+
break;
184+
}
176185
OPAL_DATATYPE_SAFEGUARD_POINTER( source_base, end_loop->size, pConvertor->pBaseBuf,
177186
pConvertor->pDesc, pConvertor->count );
178187
iov[index].iov_base = (IOVBASE_TYPE *) source_base;
@@ -181,7 +190,7 @@ opal_convertor_raw( opal_convertor_t* pConvertor,
181190
raw_data += end_loop->size;
182191
count_desc--;
183192
}
184-
source_base -= end_loop->first_elem_disp;
193+
source_base -= offset;
185194
if( 0 == count_desc ) { /* completed */
186195
pos_desc += pElem->loop.items + 1;
187196
goto update_loop_description;

test/datatype/Makefile.am

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# reserved.
55
# Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
66
# Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
7-
# Copyright (c) 2014-2015 Research Organization for Information Science
8-
# and Technology (RIST). All rights reserved.
7+
# Copyright (c) 2014-2019 Research Organization for Information Science
8+
# and Technology (RIST). All rights reserved.
99
# Copyright (c) 2016 IBM Corporation. All rights reserved.
1010
# $COPYRIGHT$
1111
#
@@ -15,7 +15,7 @@
1515
#
1616

1717
if PROJECT_OMPI
18-
MPI_TESTS = checksum position position_noncontig ddt_test ddt_raw unpack_ooo ddt_pack external32
18+
MPI_TESTS = checksum position position_noncontig ddt_test ddt_raw ddt_raw2 unpack_ooo ddt_pack external32
1919
MPI_CHECKS = to_self
2020
endif
2121
TESTS = opal_datatype_test unpack_hetero $(MPI_TESTS)
@@ -40,6 +40,12 @@ ddt_raw_LDADD = \
4040
$(top_builddir)/ompi/lib@[email protected] \
4141
$(top_builddir)/opal/lib@[email protected]
4242

43+
ddt_raw2_SOURCES = ddt_raw2.c ddt_lib.c ddt_lib.h
44+
ddt_raw2_LDFLAGS = $(OMPI_PKG_CONFIG_LDFLAGS)
45+
ddt_raw2_LDADD = \
46+
$(top_builddir)/ompi/lib@[email protected] \
47+
$(top_builddir)/opal/lib@[email protected]
48+
4349
ddt_pack_SOURCES = ddt_pack.c
4450
ddt_pack_LDFLAGS = $(OMPI_PKG_CONFIG_LDFLAGS)
4551
ddt_pack_LDADD = \

0 commit comments

Comments
 (0)