summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-10-19 03:31:11 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-10-19 03:31:11 (GMT)
commita4c0ed037424ada07720a22ebb15a58f199c5b78 (patch)
treec67f19286f10b58c299a0fbd0eab0756eb5c7853
parent4f846baa4a2ab80ac70a8b288589e307926534bf (diff)
downloadhdf5-a4c0ed037424ada07720a22ebb15a58f199c5b78.zip
hdf5-a4c0ed037424ada07720a22ebb15a58f199c5b78.tar.gz
hdf5-a4c0ed037424ada07720a22ebb15a58f199c5b78.tar.bz2
[svn-r9433] Purpose:
Bug fix Description: Fix core dump when flushing a file with a newly created attribute which hasn't had a value written to it still open. Solution: Write the attribute fill value when appropriate. Platforms tested: FreeBSd 4.10 (sleipnir) Linux 2.4 (verbena) Solaris 2.7 (arabica)
-rw-r--r--release_docs/RELEASE.txt2
-rw-r--r--src/H5Oattr.c5
-rw-r--r--test/tattr.c67
3 files changed, 73 insertions, 1 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 2c29bb8..1e1518e 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -186,6 +186,8 @@ Bug Fixes since HDF5-1.6.0 release
Library
-------
+ - Fix segmentation fault when calling H5Fflush with an attribute that
+ hasn't had a value written to it open. QAK - 2004/10/18
- Back up supporting bitfield and time types in H5Tget_native_type.
Leave it to future support. The function simply returns error
message of "not support" for bitfield and time types.
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index f816b2c..1493403 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -340,7 +340,10 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += attr->ds_size;
/* Store attribute data */
- HDmemcpy(p,attr->data,attr->data_size);
+ if(attr->data)
+ HDmemcpy(p,attr->data,attr->data_size);
+ else
+ HDmemset(p,0,attr->data_size);
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/test/tattr.c b/test/tattr.c
index ded9a79..6727442 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -395,6 +395,72 @@ test_attr_basic_read(void)
/****************************************************************
**
+** test_attr_flush(): Test H5A (attribute) code for performing
+** I/O when H5Fflush is used.
+**
+****************************************************************/
+static void
+test_attr_flush(void)
+{
+ hid_t fil, /* File ID */
+ att, /* Attribute ID */
+ spc, /* Dataspace ID */
+ set; /* Dataset ID */
+ double wdata=3.14159; /* Data to write */
+ double rdata; /* Data read in */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Attribute Flushing\n"));
+
+ fil = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fil, FAIL, "H5Fcreate");
+
+ spc = H5Screate(H5S_SCALAR);
+ CHECK(spc, FAIL, "H5Screate");
+
+ set = H5Dcreate(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT);
+ CHECK(set, FAIL, "H5Dcreate");
+
+ att = H5Acreate(set, ATTR1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT);
+ CHECK(att, FAIL, "H5Acreate");
+
+ ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ if(rdata!=0.0)
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,0.0);
+
+ ret=H5Fflush(fil, H5F_SCOPE_GLOBAL);
+ CHECK(ret, FAIL, "H5Fflush");
+
+ ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ if(rdata!=0.0)
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,0.0);
+
+ ret=H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ if(rdata!=wdata)
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,wdata);
+
+ ret=H5Sclose(spc);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret=H5Aclose(att);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret=H5Dclose(set);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret=H5Fclose(fil);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* test_attr_basic_flush() */
+
+/****************************************************************
+**
** test_attr_compound_write(): Test H5A (attribute) code.
** Tests compound datatype attributes
**
@@ -1503,6 +1569,7 @@ test_attr(void)
/* These next two tests use the same file information */
test_attr_basic_write(); /* Test basic H5A writing code */
test_attr_basic_read(); /* Test basic H5A reading code */
+ test_attr_flush(); /* Test H5A I/O in the presence of H5Fflush calls */
/* These next two tests use the same file information */
test_attr_compound_write(); /* Test complex datatype H5A writing code */