summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-08-11 18:16:49 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-08-11 18:16:49 (GMT)
commit60abc27c160721720c34b3b2e691c480c43aeed2 (patch)
tree367dffc40931c2a2150acd1d12fc7b81a62b7c8d
parent0ea4639d9df2d1bffc63ce9be5366ba89a7f5a13 (diff)
parent98ca520f55531b0783bb1425c1fb3a125c1c40f7 (diff)
downloadhdf5-60abc27c160721720c34b3b2e691c480c43aeed2.zip
hdf5-60abc27c160721720c34b3b2e691c480c43aeed2.tar.gz
hdf5-60abc27c160721720c34b3b2e691c480c43aeed2.tar.bz2
Merge pull request #2750 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:1_10_normalization to hdf5_1_10
* commit '98ca520f55531b0783bb1425c1fb3a125c1c40f7': Brings HDFFV-11027 H5S_NO_CLASS fix to 1.10 from develop
-rw-r--r--java/test/TestH5S.java2
-rw-r--r--release_docs/RELEASE.txt16
-rw-r--r--src/H5S.c7
-rw-r--r--test/tselect.c76
4 files changed, 98 insertions, 3 deletions
diff --git a/java/test/TestH5S.java b/java/test/TestH5S.java
index 985342b..97c0b68 100644
--- a/java/test/TestH5S.java
+++ b/java/test/TestH5S.java
@@ -171,7 +171,7 @@ public class TestH5S {
try {
H5.H5Sset_extent_none(H5sid);
read_type = H5.H5Sget_simple_extent_type(H5sid);
- assertTrue("H5.H5Sget_simple_extent_type: "+read_type, HDF5Constants.H5S_NO_CLASS == read_type);
+ assertTrue("H5.H5Sget_simple_extent_type: "+read_type, HDF5Constants.H5S_NULL == read_type);
}
catch (Throwable err) {
err.printStackTrace();
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 3a85dcc..6a9dcb5 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -511,6 +511,22 @@ Bug Fixes since HDF5-1.10.5 release
(QAK - 2020/05/07)
+ - H5Sset_extent_none() sets the dataspace class to H5S_NO_CLASS which
+ causes asserts/errors when passed to other dataspace API calls.
+
+ H5S_NO_CLASS is an internal class value that should not have been
+ exposed via a public API call.
+
+ In debug builds of the library, this can cause asserts to trip. In
+ non-debug builds, it will produce normal library errors.
+
+ The new library behavior is for H5Sset_extent_none() to convert
+ the dataspace into one of type H5S_NULL, which is better handled
+ by the library and easier for developers to reason about.
+
+ (DER - 2020/07/27, HDFFV-11027)
+
+
Java Library:
----------------
-
diff --git a/src/H5S.c b/src/H5S.c
index c42c952..dff8e60 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -414,6 +414,9 @@ H5S__extent_release(H5S_extent_t *extent)
extent->max = H5FL_ARR_FREE(hsize_t, extent->max);
} /* end if */
+ extent->rank = 0;
+ extent->nelem = 0;
+
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5S__extent_release() */
@@ -1809,7 +1812,7 @@ done:
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
- This function resets the type of a dataspace back to "none" with no
+ This function resets the type of a dataspace to H5S_NULL with no
extent information stored for the dataspace.
--------------------------------------------------------------------------*/
herr_t
@@ -1829,7 +1832,7 @@ H5Sset_extent_none(hid_t space_id)
if(H5S__extent_release(&space->extent) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace")
- space->extent.type = H5S_NO_CLASS;
+ space->extent.type = H5S_NULL;
done:
FUNC_LEAVE_API(ret_value)
diff --git a/test/tselect.c b/test/tselect.c
index 8abe898..6c8cc16 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -15201,6 +15201,77 @@ test_hyper_io_1d(void)
/****************************************************************
**
+** test_h5s_set_extent_none:
+** Test to verify the behavior of dataspace code when passed
+** a dataspace modified by H5Sset_extent_none().
+**
+****************************************************************/
+static void
+test_h5s_set_extent_none(void)
+{
+ hid_t sid = H5I_INVALID_HID;
+ hid_t dst_sid = H5I_INVALID_HID;
+ hid_t null_sid = H5I_INVALID_HID;
+ int rank = 1;
+ hsize_t current_dims = 123;
+ H5S_class_t cls;
+ int out_rank;
+ hsize_t out_dims;
+ hsize_t out_maxdims;
+ hssize_t out_points;
+ htri_t equal;
+ herr_t ret;
+
+ /* Specific values here don't matter as we're just going to reset */
+ sid = H5Screate_simple(rank, &current_dims, NULL);
+ CHECK(sid, H5I_INVALID_HID, "H5Screate_simple");
+
+ /* Dataspace class will be H5S_NULL after this.
+ * In versions prior to 1.10.7 / 1.12.1 this would produce a
+ * dataspace with the internal H5S_NO_CLASS class.
+ */
+ ret = H5Sset_extent_none(sid);
+ CHECK(ret, FAIL, "H5Sset_extent_none");
+ cls = H5Sget_simple_extent_type(sid);
+ VERIFY(cls, H5S_NULL, "H5Sget_simple_extent_type");
+
+ /* Extent getters should generate normal results and not segfault.
+ */
+ out_rank = H5Sget_simple_extent_dims(sid, &out_dims, &out_maxdims);
+ VERIFY(out_rank, 0, "H5Sget_simple_extent_dims");
+ out_rank = H5Sget_simple_extent_ndims(sid);
+ VERIFY(out_rank, 0, "H5Sget_simple_extent_ndims");
+ out_points = H5Sget_simple_extent_npoints(sid);
+ VERIFY(out_points, 0, "H5Sget_simple_extent_npoints");
+
+ /* Check that copying the new (non-)extent works.
+ */
+ dst_sid = H5Screate_simple(rank, &current_dims, NULL);
+ CHECK(dst_sid, H5I_INVALID_HID, "H5Screate_simple");
+ ret = H5Sextent_copy(dst_sid, sid);
+ CHECK(ret, FAIL, "H5Sextent_copy");
+
+ /* Check that H5Sset_extent_none() produces the same extent as
+ * H5Screate(H5S_NULL).
+ */
+ null_sid = H5Screate(H5S_NULL);
+ CHECK(null_sid, H5I_INVALID_HID, "H5Screate");
+ equal = H5Sextent_equal(sid, null_sid);
+ VERIFY(equal, TRUE, "H5Sextent_equal");
+
+ /* Close */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Sclose(dst_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Sclose(null_sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+} /* test_h5s_set_extent_none() */
+
+
+/****************************************************************
+**
** test_select(): Main H5S selection testing routine.
**
****************************************************************/
@@ -15382,6 +15453,11 @@ test_select(void)
/* Test reading of 1-d disjoint file space to 1-d single block memory space */
test_hyper_io_1d();
+ /* Test H5Sset_extent_none() functionality after we updated it to set
+ * the class to H5S_NULL instead of H5S_NO_CLASS.
+ */
+ test_h5s_set_extent_none();
+
} /* test_select() */