From b0b020d422b493228c00449391552bdfc50a33c2 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 31 Dec 2003 15:28:46 -0500 Subject: [svn-r8007] Purpose: Bug fix Description: Range check the szip 'pixels per block' against the chunk size of the dataset when attempting to create a new dataset, since the szip library requires the PPB to be at least the size of the fastest changing dimension in the chunk. Platforms tested: FreeBSD 4.9 (sleipnir) too minor for h5committest --- release_docs/RELEASE.txt | 3 +++ src/H5Z.c | 6 +++--- src/H5Zszip.c | 4 ++++ test/dsets.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 81b7a74..32ab48c 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -93,6 +93,9 @@ Bug Fixes since HDF5-1.6.0 release Library ------- + - Detect situation where szip 'pixels per block' is larger than the + fastest changing dimension of a dataset's chunk size and disallow + this (due to limits in szip library). QAK - 2003/12/31 - Fixed bug with flattened hyperslab selections that would generate incorrect hyperslab information with certain high-dimensionality combinations of start/stride/count/block information. diff --git a/src/H5Z.c b/src/H5Z.c index a1edaa4..f421d74 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -526,7 +526,7 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Check return value */ if(status<=0) { /* We're leaving, so close dataspace */ - if(H5Sclose(space_id)<0) + if(H5I_dec_ref(space_id)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") /* Indicate filter can't apply to this combination of parameters */ @@ -547,7 +547,7 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Make callback to filter's "set local" function */ if((fclass->set_local)(dcpl_id, type_id, space_id)<0) { /* We're leaving, so close dataspace */ - if(H5Sclose(space_id)<0) + if(H5I_dec_ref(space_id)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") /* Indicate error during filter callback */ @@ -563,7 +563,7 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty } /* end for */ /* Close dataspace */ - if(H5Sclose(space_id)<0) + if(H5I_dec_ref(space_id)<0) HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") } /* end if */ } /* end if */ diff --git a/src/H5Zszip.c b/src/H5Zszip.c index 94df634..9907f9c 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -129,6 +129,10 @@ H5Z_can_apply_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) assert(ndims>0); scanline=dims[ndims-1]; + /* Range check the pixels per block against the 'scanline' size */ + if(scanline SZ_MAX_PIXELS_PER_SCANLINE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid scanline size") diff --git a/test/dsets.c b/test/dsets.c index b443ff5..7c1f123 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -2562,7 +2562,9 @@ file) unsigned szip_options_mask=H5_SZIP_NN_OPTION_MASK; unsigned szip_pixels_per_block; const hsize_t dims[2] = {500, 4096}; /* Dataspace dimensions */ + const hsize_t dims2[2] = {4, 2}; /* Dataspace dimensions */ const hsize_t chunk_dims[2] = {250, 2048}; /* Chunk dimensions */ + const hsize_t chunk_dims2[2] = {2, 1}; /* Chunk dimensions */ herr_t ret; /* Status value */ #else /* H5_HAVE_FILTER_SZIP */ const char *not_supported= " Szip filter is not enabled."; @@ -2646,6 +2648,59 @@ file) goto error; } /* end if */ + /* Create another data space */ + if ((sid = H5Screate_simple(2, dims2, NULL))<0) { + H5_FAILED(); + printf(" Line %d: Can't open dataspace\n",__LINE__); + goto error; + } /* end if */ + + /* Create dcpl with special filter */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) { + H5_FAILED(); + printf(" Line %d: Can't create dcpl\n",__LINE__); + goto error; + } /* end if */ + if(H5Pset_chunk(dcpl, 2, chunk_dims2)<0) { + H5_FAILED(); + printf(" Line %d: Can't set chunk sizes\n",__LINE__); + goto error; + } /* end if */ + + /* Set (invalid at dataset creation time) szip parameters */ + szip_pixels_per_block=32; + if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block)<0) { + H5_FAILED(); + printf(" Line %d: Can't set szip filter\n",__LINE__); + goto error; + } + + /* Create new dataset */ + /* (Should fail because the 'can apply' filter should indicate inappropriate combination) */ + H5E_BEGIN_TRY { + dsid = H5Dcreate(file, DSET_CAN_APPLY_SZIP_NAME, H5T_NATIVE_INT, sid, dcpl); + } H5E_END_TRY; + if (dsid >=0) { + H5_FAILED(); + printf(" Line %d: Shouldn't have created dataset!\n",__LINE__); + H5Dclose(dsid); + goto error; + } /* end if */ + + /* Close dataspace */ + if(H5Sclose(sid)<0) { + H5_FAILED(); + printf(" Line %d: Can't close dataspace\n",__LINE__); + goto error; + } /* end if */ + + /* Close dataset creation property list */ + if(H5Pclose(dcpl)<0) { + H5_FAILED(); + printf(" Line %d: Can't close dcpl\n",__LINE__); + goto error; + } /* end if */ + PASSED(); #else /* H5_HAVE_FILTER_SZIP */ -- cgit v0.12