Hi all,
I've used valgrind to check my hdf5 use and it returns this:
==16072== Source and destination overlap in memcpy(0x4FC9CC0, 0x4FC9CC0, 33)
==16072== at 0x4906884: memcpy (mac_replace_strmem.c:394)
==16072== by 0x4C6A27A: H5O_attr_write_cb (in /home/poinot/Tools-2/lib/libhdf5.so.6.0.4)
==16072== by 0x4C7FEEC: H5O_msg_iterate_real (in /home/poinot/Tools-2/lib/libhdf5.so.6.0.4)
==16072== by 0x4C6A620: H5O_attr_write (in /home/poinot/Tools-2/lib/libhdf5.so.6.0.4)
==16072== by 0x4B84F64: H5Awrite (in /home/poinot/Tools-2/lib/libhdf5.so.6.0.4)
==16072== by 0x4A13C1E: HDF_Add_Attribute_As_String (l3.c:761)
==16072== by 0x4A1434E: HDF_Create_Root (l3.c:876)
==16072== by 0x4A16C90: L3_openFile (l3.c:1359)
==16072== by 0x401882: main (test02.c:19)
even when I set the --enable-using-memchecker.
Then I should have a bug in my code...
I cannot find it and when I run my test suite I has correct results (which is far to be a proof...)
Here's the piece of code, I would appreciate any help, hint or whatever (except putting the
valgrind message in the suppression list !).
I've suspected a misused of SCALAR data space and strings, I've seen examples with SIMPLE dataspaces
instead of SCALAR for strings but the use of a fixed length string should be possible ?
notes:
* nodeid is a group
* L3C_MAX_ATTRIB_SIZE > L3C_MAX_DTYPE
* using hdf 1.8.5 thread-safe
* using valgrind 3.5
* x86 platform with gcc
int HDF_Add_Attribute_As_String(L3_Cursor_t *ctxt, hid_t nodeid, const char *name, const char *value)
{
hid_t sid,tid,aid;
herr_t status;
hsize_t dim;
char buff[L3C_MAX_ATTRIB_SIZE+1];
if (!strcmp(name,L3S_DTYPE))
{
dim=(hsize_t)(L3C_MAX_DTYPE+1);
}
else
{
dim=(hsize_t)(L3C_MAX_ATTRIB_SIZE+1);
}
sid = H5Screate(H5S_SCALAR);
if (sid < 0)
{
return 0;
}
tid = H5Tcopy(H5T_C_S1);
if (tid < 0)
{
H5Sclose(sid);
return 0;
}
if (H5Tset_size(tid,dim)<0)
{
H5Tclose(tid);
H5Sclose(sid);
return 0;
}
aid = H5Acreate(nodeid,name,tid,sid,H5P_DEFAULT,H5P_DEFAULT);
if (aid < 0)
{
H5Tclose(tid);
H5Sclose(sid);
return 0;
}
memset(buff, 0, dim);
strcpy(buff, value);
status = H5Awrite(aid, tid, buff);
H5Aclose(aid);
H5Tclose(tid);
H5Sclose(sid);
if (status < 0)
{
return 0;
}
return 1;
}
-MP-
···
-----------------------------------------------------------------------
Marc POINOT [ONERA/DSNA] Tel:+33.1.46.73.42.84 Fax:+33.1.46.73.41.66
Avertissement/disclaimer http://www.onera.fr/onera-en/emails-terms