From 1b784081847f83b99807021a73673e591f27272f Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Mon, 9 Feb 2015 11:31:28 -0500 Subject: [svn-r26149] Fix potential memory error reported by valgrind in H5D__link_chunk_collective_io. This would occur when performing collective I/O on a dataset with only 1 chunk, and a participating process had nothing to read or write. Tested: jam, koala, ostrich (h5committest) --- src/H5Dmpio.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 58bcc04..01d2288 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -833,39 +833,37 @@ H5D__link_chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *typ * equivalent of compressed contiguous datasets - QAK] */ if(total_chunks == 1) { - H5D_chunk_ud_t udata; /* User data for querying chunk info */ - hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk in file dataset's dataspace */ H5SL_node_t *chunk_node; /* Pointer to chunk node for selection */ H5S_t *fspace; /* Dataspace describing chunk & selection in it */ H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ - /* Initialize the chunk coordinates */ - /* (must be all zero, since there's only one chunk) */ - HDmemset(coords, 0, sizeof(coords)); - - /* Look up address of chunk */ - if(H5D__chunk_lookup(io_info->dset, io_info->dxpl_id, coords, - io_info->store->chunk.index, &udata) < 0) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skipped list") - ctg_store.contig.dset_addr = udata.addr; - /* Check for this process having selection in this chunk */ chunk_node = H5SL_first(fm->sel_chunks); if(chunk_node == NULL) { - /* Set the dataspace info for I/O to NULL, this process doesn't have any I/O to perform */ - fspace = mspace = NULL; + /* Set the dataspace info for I/O to NULL, this process doesn't have any I/O to perform */ + fspace = mspace = NULL; + + /* Initialize chunk address */ + ctg_store.contig.dset_addr = 0; } /* end if */ else { - H5D_chunk_info_t *chunk_info; - - /* Get the chunk info, for the selection in the chunk */ - if(NULL == (chunk_info = H5SL_item(chunk_node))) - HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skipped list") - - /* Set the dataspace info for I/O */ - fspace = chunk_info->fspace; - mspace = chunk_info->mspace; + H5D_chunk_ud_t udata; /* User data for querying chunk info */ + H5D_chunk_info_t *chunk_info; /* Info for chunk in skiplist */ + + /* Get the chunk info, for the selection in the chunk */ + if(NULL == (chunk_info = (H5D_chunk_info_t *)H5SL_item(chunk_node))) + HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk info from skip list") + + /* Set the dataspace info for I/O */ + fspace = chunk_info->fspace; + mspace = chunk_info->mspace; + + /* Look up address of chunk */ + if(H5D__chunk_lookup(io_info->dset, io_info->dxpl_id, chunk_info->coords, + chunk_info->index, &udata) < 0) + HGOTO_ERROR(H5E_STORAGE, H5E_CANTGET, FAIL, "couldn't get chunk address") + ctg_store.contig.dset_addr = udata.addr; } /* end else */ /* Set up the base storage address for this chunk */ -- cgit v0.12