[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)
This commit is contained in:
Quincey Koziol 2004-10-18 22:31:11 -05:00
parent 4f846baa4a
commit a4c0ed0374
3 changed files with 73 additions and 1 deletions

View File

@ -186,6 +186,8 @@ Bug Fixes since HDF5-1.6.0 release
Library 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. - Back up supporting bitfield and time types in H5Tget_native_type.
Leave it to future support. The function simply returns error Leave it to future support. The function simply returns error
message of "not support" for bitfield and time types. message of "not support" for bitfield and time types.

View File

@ -340,7 +340,10 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += attr->ds_size; p += attr->ds_size;
/* Store attribute data */ /* 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: done:
FUNC_LEAVE_NOAPI(ret_value); FUNC_LEAVE_NOAPI(ret_value);

View File

@ -393,6 +393,72 @@ test_attr_basic_read(void)
CHECK(ret, FAIL, "H5Fclose"); CHECK(ret, FAIL, "H5Fclose");
} /* test_attr_basic_read() */ } /* test_attr_basic_read() */
/****************************************************************
**
** 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. ** test_attr_compound_write(): Test H5A (attribute) code.
@ -1503,6 +1569,7 @@ test_attr(void)
/* These next two tests use the same file information */ /* These next two tests use the same file information */
test_attr_basic_write(); /* Test basic H5A writing code */ test_attr_basic_write(); /* Test basic H5A writing code */
test_attr_basic_read(); /* Test basic H5A reading 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 */ /* These next two tests use the same file information */
test_attr_compound_write(); /* Test complex datatype H5A writing code */ test_attr_compound_write(); /* Test complex datatype H5A writing code */