summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2015-03-10 22:03:53 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2015-03-10 22:03:53 (GMT)
commit878149c4a2d17de7d157c246c1db88db41ec1f70 (patch)
treeb8eec0ec6efd9abc81231ab7912e2f3e958d6723
parentd928aca8e63d7c5dd73721c634514a5ce951b54e (diff)
downloadhdf5-878149c4a2d17de7d157c246c1db88db41ec1f70.zip
hdf5-878149c4a2d17de7d157c246c1db88db41ec1f70.tar.gz
hdf5-878149c4a2d17de7d157c246c1db88db41ec1f70.tar.bz2
[svn-r26419] merged r26373 and r26380 from the trunk into the branch.
tested: h5committest
-rw-r--r--src/H5R.c13
-rw-r--r--test/trefer.c75
-rw-r--r--tools/h5dump/errfiles/tarray1_big.err54
-rw-r--r--tools/h5dump/errfiles/tattrregR.err36
-rw-r--r--tools/h5dump/errfiles/tdataregR.err36
5 files changed, 107 insertions, 107 deletions
diff --git a/src/H5R.c b/src/H5R.c
index c36c2fa..1e99b86 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -409,6 +409,10 @@ done:
Currently only set up to work with references to datasets
EXAMPLES
REVISION LOG
+
+ M. Scot Breitenfeld
+ 3 March 2015
+ Added a check for undefined reference pointer.
--------------------------------------------------------------------------*/
static hid_t
H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, hbool_t app_ref)
@@ -433,8 +437,10 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re
switch(ref_type) {
case H5R_OBJECT:
oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */
- break;
-
+ if(!H5F_addr_defined(oloc.addr) || oloc.addr == 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer")
+ break;
+
case H5R_DATASET_REGION:
{
H5HG_t hobjid; /* Heap object ID */
@@ -446,6 +452,9 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re
H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
UINT32DECODE(p, hobjid.idx);
+ if(!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer")
+
/* Get the dataset region from the heap (allocate inside routine) */
if(NULL == (buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)))
HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
diff --git a/test/trefer.c b/test/trefer.c
index bd105a3..5475e9e 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -500,6 +500,12 @@ test_reference_region(void)
H5O_type_t obj_type; /* Type of object */
int i, j; /* counting variables */
herr_t ret; /* Generic return value */
+ haddr_t addr = HADDR_UNDEF; /* test for undefined reference */
+ hid_t dset_NA; /* Dataset id for undefined reference */
+ hid_t space_NA; /* Dataspace id for undefined reference */
+ hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */
+ hdset_reg_ref_t wdata_NA[1], /* Write buffer */
+ rdata_NA[1]; /* Read buffer */
/* Output message about test being performed */
MESSAGE(5, ("Testing Dataset Region Reference Functions\n"));
@@ -586,6 +592,31 @@ test_reference_region(void)
ret = H5Dwrite(dset1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf);
CHECK(ret, FAIL, "H5Dwrite");
+ /*
+ * Store a dataset region reference which will not get written to disk
+ */
+
+ /* Create reference to an element in dset1 */
+ ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord1);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+ ret = H5Rcreate(&wdata_NA[0], fid1, "/Dataset1", H5R_DATASET_REGION, sid2);
+ CHECK(ret, FAIL, "H5Rcreate");
+
+ /* Create the dataspace of the region references */
+ space_NA = H5Screate_simple(1, dims_NA, NULL);
+ CHECK(space_NA, FAIL, "H5Screate_simple");
+
+ /* Create the dataset and write the region references to it */
+ dset_NA = H5Dcreate(fid1, "DS_NA", H5T_STD_REF_DSETREG, space_NA, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(dset_NA, FAIL, "H5Dcreate");
+
+ /* Close and release resources for undefined region reference tests */
+ ret = H5Dclose(dset_NA);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Sclose(space_NA);
+ CHECK(ret, FAIL, "H5Sclose");
+
/* Close disk dataspace */
ret = H5Sclose(sid1);
CHECK(ret, FAIL, "H5Sclose");
@@ -606,6 +637,41 @@ test_reference_region(void)
fid1 = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fopen");
+ /*
+ * Start the test of an undefined reference
+ */
+
+ /* Open the dataset of the undefined references */
+ dset_NA = H5Dopen2(fid1, "DS_NA", H5P_DEFAULT);
+ CHECK(dset_NA, FAIL, "H5Dopen2");
+
+ /* Read the data */
+ ret = H5Dread(dset_NA, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_NA);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /*
+ * Dereference an undefined reference (should fail)
+ */
+ H5E_BEGIN_TRY {
+ dset2 = H5Rdereference(dset_NA, H5R_DATASET_REGION, &rdata_NA[0]);
+ } H5E_END_TRY;
+ VERIFY(dset2, FAIL, "H5Rdereference");
+
+ /* Close and release resources. */
+ ret = H5Dclose(dset_NA);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* This close should fail since H5Rdereference never created
+ * the id of the referenced object. */
+ H5E_BEGIN_TRY {
+ ret = H5Dclose(dset2);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Dclose");
+
+ /*
+ * End the test of an undefined reference
+ */
+
/* Open the dataset */
dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT);
CHECK(dset1, FAIL, "H5Dopen2");
@@ -614,6 +680,10 @@ test_reference_region(void)
ret = H5Dread(dset1, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf);
CHECK(ret, FAIL, "H5Dread");
+ /* Try to read an unaddressed dataset */
+ dset2 = H5Rdereference(dset1, H5R_DATASET_REGION, &addr);
+ VERIFY(dset2, FAIL, "H5Rdereference haddr_undef");
+
/* Try to open objects */
dset2 = H5Rdereference(dset1, H5R_DATASET_REGION, &rbuf[0]);
CHECK(dset2, FAIL, "H5Rdereference");
@@ -1031,6 +1101,7 @@ test_reference_obj_deleted(void)
hid_t sid1; /* Dataspace ID */
hobj_ref_t oref; /* Object Reference to test */
H5O_type_t obj_type; /* Object type */
+ haddr_t addr = HADDR_UNDEF; /* test for undefined reference */
herr_t ret; /* Generic return value */
/* Create file */
@@ -1088,6 +1159,10 @@ test_reference_obj_deleted(void)
dataset = H5Dopen2(fid1, "/Dataset2", H5P_DEFAULT);
CHECK(ret, FAIL, "H5Dopen2");
+ /* Open undefined reference */
+ dset2 = H5Rdereference(dataset, H5R_OBJECT, &addr);
+ VERIFY(dset2, FAIL, "H5Rdereference");
+
/* Read selection from disk */
HDmemset(&oref, 0, sizeof(hobj_ref_t));
ret = H5Dread(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, &oref);
diff --git a/tools/h5dump/errfiles/tarray1_big.err b/tools/h5dump/errfiles/tarray1_big.err
index edfe0df..d5cd435 100644
--- a/tools/h5dump/errfiles/tarray1_big.err
+++ b/tools/h5dump/errfiles/tarray1_big.err
@@ -2,59 +2,23 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Rdereference(): unable to dereference object
major: References
minor: Unable to initialize object
- #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information
- major: References
- minor: Read failed
- #002: (file name) line (number) in H5HG_read(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #003: (file name) line (number) in H5HG_protect(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed.
- major: Object cache
- minor: Unable to protect metadata
- #005: (file name) line (number) in H5C_protect(): incorrect cache entry type
- major: Object cache
- minor: Inappropriate type
+ #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer
+ major: Invalid arguments to routine
+ minor: Bad value
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Rdereference(): unable to dereference object
major: References
minor: Unable to initialize object
- #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information
- major: References
- minor: Read failed
- #002: (file name) line (number) in H5HG_read(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #003: (file name) line (number) in H5HG_protect(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed.
- major: Object cache
- minor: Unable to protect metadata
- #005: (file name) line (number) in H5C_protect(): incorrect cache entry type
- major: Object cache
- minor: Inappropriate type
+ #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer
+ major: Invalid arguments to routine
+ minor: Bad value
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Rdereference(): unable to dereference object
major: References
minor: Unable to initialize object
- #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information
- major: References
- minor: Read failed
- #002: (file name) line (number) in H5HG_read(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #003: (file name) line (number) in H5HG_protect(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed.
- major: Object cache
- minor: Unable to protect metadata
- #005: (file name) line (number) in H5C_protect(): incorrect cache entry type
- major: Object cache
- minor: Inappropriate type
+ #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer
+ major: Invalid arguments to routine
+ minor: Bad value
H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs):
#000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed
major: Failure in tools library
diff --git a/tools/h5dump/errfiles/tattrregR.err b/tools/h5dump/errfiles/tattrregR.err
index 4dca3ae..c5aa5ba 100644
--- a/tools/h5dump/errfiles/tattrregR.err
+++ b/tools/h5dump/errfiles/tattrregR.err
@@ -2,40 +2,16 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Rdereference(): unable to dereference object
major: References
minor: Unable to initialize object
- #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information
- major: References
- minor: Read failed
- #002: (file name) line (number) in H5HG_read(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #003: (file name) line (number) in H5HG_protect(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed.
- major: Object cache
- minor: Unable to protect metadata
- #005: (file name) line (number) in H5C_protect(): incorrect cache entry type
- major: Object cache
- minor: Inappropriate type
+ #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer
+ major: Invalid arguments to routine
+ minor: Bad value
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Rdereference(): unable to dereference object
major: References
minor: Unable to initialize object
- #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information
- major: References
- minor: Read failed
- #002: (file name) line (number) in H5HG_read(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #003: (file name) line (number) in H5HG_protect(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed.
- major: Object cache
- minor: Unable to protect metadata
- #005: (file name) line (number) in H5C_protect(): incorrect cache entry type
- major: Object cache
- minor: Inappropriate type
+ #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer
+ major: Invalid arguments to routine
+ minor: Bad value
H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs):
#000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed
major: Failure in tools library
diff --git a/tools/h5dump/errfiles/tdataregR.err b/tools/h5dump/errfiles/tdataregR.err
index 4dca3ae..c5aa5ba 100644
--- a/tools/h5dump/errfiles/tdataregR.err
+++ b/tools/h5dump/errfiles/tdataregR.err
@@ -2,40 +2,16 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Rdereference(): unable to dereference object
major: References
minor: Unable to initialize object
- #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information
- major: References
- minor: Read failed
- #002: (file name) line (number) in H5HG_read(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #003: (file name) line (number) in H5HG_protect(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed.
- major: Object cache
- minor: Unable to protect metadata
- #005: (file name) line (number) in H5C_protect(): incorrect cache entry type
- major: Object cache
- minor: Inappropriate type
+ #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer
+ major: Invalid arguments to routine
+ minor: Bad value
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#000: (file name) line (number) in H5Rdereference(): unable to dereference object
major: References
minor: Unable to initialize object
- #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information
- major: References
- minor: Read failed
- #002: (file name) line (number) in H5HG_read(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #003: (file name) line (number) in H5HG_protect(): unable to protect global heap
- major: Heap
- minor: Unable to protect metadata
- #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed.
- major: Object cache
- minor: Unable to protect metadata
- #005: (file name) line (number) in H5C_protect(): incorrect cache entry type
- major: Object cache
- minor: Inappropriate type
+ #001: (file name) line (number) in H5R_dereference(): Undefined reference pointer
+ major: Invalid arguments to routine
+ minor: Bad value
H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs):
#000: (file name) line (number) in h5tools_dump_simple_data(): H5Rdereference failed
major: Failure in tools library