[HDFFV-10466] Another problem with copy


#1

Hello!

Some time ago I reported a critical bug in H5Ocopy to help@hdfgroup.org. It was labeled [HDFFV-10466] but no investigation took place since. I now report it publicly to hdf-forum@lists.hdfgroup.org, in search for collaboration from HDF5 user community to try craft a patch.


To reproduce:

  1. Download
    https://zendto.acdlabs.com/download.php?claimID=PAECtrZAvv3vaJcg&claimPasscode=2GTeuhMRJPbdZ82w&auth=2da721baa9d05867fe94a8fc0f19e741&fid=18754

  2. h5ls -r sulfadrug.abf
    Works fine!

  3. h5copy -i sulfadrug.abf -o new.abf -s /msms/info -d /test -p -v
    Copying file <sulfadrug.abf> and object </msms/info> to file <new.abf> and object
    h5copy: Creating parent groups
    Segmentation fault

  4. cat new.abf
    %HDF
    (file exists)

  5. h5ls new.abf
    new.abf: unable to open file

Reproducible on vanilla HDF5 binaries, Debian and Windows, 1.10.0…1.10.3.


Running under debugger, I see that src->shared->u.vlen has
loc == H5T_LOC_BADLOC
and all callbacks incl. isnull are NULLs here:
https://bitbucket.hdfgroup.org/projects/HDFFV/repos/hdf5/browse/src/H5Tconv.c#3183

It’s not quite clear how src->shared could come with H5T_LOC_BADLOC and if it’s expected (according to the comment at
https://bitbucket.hdfgroup.org/projects/HDFFV/repos/hdf5/browse/src/H5Odtype.c#512
it might be).

Best wishes,
Andrey Paramonov


#2

I managed to create a minimally reproducible example with h5py.
This works fine:

import h5py
with h5py.File('test.h5', libver='latest') as f:
    for i in range(8):
        f.attrs[str(i + 1)] = u'test'
    f.copy(f, 'copy')

But this breaks:

import h5py
with h5py.File('test.h5', libver='latest') as f:
    for i in range(9):  # <- note
        f.attrs[str(i + 1)] = u'test'
    f.copy(f, 'copy')

Best wishes,
Andrey Paramonov


#4

What about the following patch?

--- H5Aint.c
+++ CMake-hdf5-1.10.3\hdf5-1.10.3\src\H5Aint.c
@@ -2522,6 +2522,10 @@
     HDassert(udata->file);
     HDassert(udata->cpy_info);
 
+    /* Mark datatype as being on disk now (analogously to H5O__attr_copy_file). */
+    if(H5T_set_loc(attr_src->shared->dt, udata->oloc_src->file, H5T_LOC_DISK) < 0)
+        HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "invalid datatype location")
+
     if(NULL == (attr_dst = H5A__attr_copy_file(attr_src, udata->file, udata->recompute_size, udata->cpy_info)))
         HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, "can't copy attribute")

Best wishes,
Andrey Paramonov


#5

Thank you for the patch! Added to the issue and will review.

Elena