Hi,

You could try using the H5allocate_memory and H5free_memory functions in the 
filter, instead of regular malloc and free.


Dan.


From: Hdf-forum [mailto:[email protected]] On Behalf Of 
Bálint Balázs
Sent: 08 January 2016 13:51
To: [email protected]
Subject: [Hdf-forum] Memory corruption problems with a dynamic filter in jhdf5

Hi,
I'm working on a compression filter for HDF5, but I had some problems with 
jhdf5 opening the filtered datasets.

I managed to trace down the problem to this: the filter plugin is found, starts 
execution, but when it wants to free the original buffer, the program exits 
with a memory heap corruption error. This is a minimal version of the filter 
that reproduces the error:

size_t H5Z_dummy_filter(unsigned int flags, size_t cd_nelmts, const unsigned 
int cd_values[], size_t nbytes, size_t *buf_size, void **buf)
{
    int* outbuf = (int*)malloc(*buf_size);
    memcpy(outbuf, *buf, *buf_size);
    free(*buf);    // error occurs here
    *buf = outbuf;
    return nbytes;
}

This (dummy) filter works from C++, from the command line with h5dump, and also 
with HDFView. I only had a problem when using it with Fiji, which uses the 
jhdf5 library (14.12.2).
I compiled the dll with Visual Studio 2013 on Windows 7 64 bit, and use the 64 
bit version of Java 8 with Fiji.

Thanks in advance for the help!
Cheers,
Balint
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to