From 873a7fadee711d399cc6328f6b0f069edf6db382 Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Fri, 30 Apr 2021 08:46:55 -0500 Subject: [PATCH] io/ompio: fix get_byte_offset for 0-size fview Handle a file view size of 0 correctly in File_get_byte_offset to avoid a division by zero problem. Fixes Issue #8841 Signed-off-by: Edgar Gabriel --- ompi/mca/io/ompio/io_ompio_file_open.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ompi/mca/io/ompio/io_ompio_file_open.c b/ompi/mca/io/ompio/io_ompio_file_open.c index e020f5f4c9a..9400ae0d07a 100644 --- a/ompi/mca/io/ompio/io_ompio_file_open.c +++ b/ompi/mca/io/ompio/io_ompio_file_open.c @@ -519,6 +519,11 @@ int mca_io_ompio_file_get_byte_offset (ompi_file_t *fh, data = (mca_common_ompio_data_t *) fh->f_io_selected_data; OPAL_THREAD_LOCK(&fh->f_lock); + if ( data->ompio_fh.f_view_size == 0 ) { + *disp = 0; + OPAL_THREAD_UNLOCK(&fh->f_lock); + return OMPI_SUCCESS; + } temp_offset = (long) data->ompio_fh.f_view_extent * (offset*data->ompio_fh.f_etype_size / data->ompio_fh.f_view_size); if ( 0 > temp_offset ) {