H5Tunregister not calling H5_CONV_FREE

Hello,

I'm developing some custom conversion functions. I'm using Windows 32bit at HDF5 version 1.8.9. It seems that when I register them with H5T_PERS_SOFT that they are not called with H5T_CONV_FREE when H5Tunregister is called. In fact, H5Tunregister does not appear to do anything, including actually unregister the converters. Actual unregistration does not appear to happen until H5close is called or hdf5 shared library is unloaded.

This is a problem because I'm calling the registration functions from a second library. What happens is that I register the functions when the library is loaded. The H5T_CONV_INIT functions allocate memory and store pointers in cdata->priv. After using my custom library, the following happens:

Main program completes
Main program unloads my custom library
Main program unloads hdf5 library*
Main program crashes

*At this point, the converters are called with H5T_CONV_FREE. The crash is caused when the custom conversion functions are called since they are no longer loaded.

As a workaround, I think I can call H5close when my library unloads. However, I'm not sure that that will work in all cases (what if the hdf5 library is still needed, but the custom library is not?)

Any other suggestions? Can anyone confirm this behavior?
Jason

Jason,

Few people work as deeply into the HDF5 library as you do. We don't have extensive test on this part of the library. You might have triggered some bug. In H5T_unregister of H5T.c, you can see the lines like this:

            /* Shut down path */
            H5T__print_stats(path, &nprint);
            path->cdata.command = H5T_CONV_FREE;
            if((path->func)(FAIL, FAIL, &(path->cdata),
                    (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id) < 0) {

This is the step that frees your private data. It calls your conversion function and goes to the H5T_CONV_FREE part. I suggest you use debugger to trace down to see what's going on exactly. I'm curious to know what you'll find.

Thanks.

Ray

···

On Oct 9, 2012, at 3:34 PM, Jason Sommerville wrote:

Hello,

I'm developing some custom conversion functions. I'm using Windows 32bit at HDF5 version 1.8.9. It seems that when I register them with H5T_PERS_SOFT that they are not called with H5T_CONV_FREE when H5Tunregister is called. In fact, H5Tunregister does not appear to do anything, including actually unregister the converters. Actual unregistration does not appear to happen until H5close is called or hdf5 shared library is unloaded.

This is a problem because I'm calling the registration functions from a second library. What happens is that I register the functions when the library is loaded. The H5T_CONV_INIT functions allocate memory and store pointers in cdata->priv. After using my custom library, the following happens:

Main program completes
Main program unloads my custom library
Main program unloads hdf5 library*
Main program crashes

*At this point, the converters are called with H5T_CONV_FREE. The crash is caused when the custom conversion functions are called since they are no longer loaded.

As a workaround, I think I can call H5close when my library unloads. However, I'm not sure that that will work in all cases (what if the hdf5 library is still needed, but the custom library is not?)

Any other suggestions? Can anyone confirm this behavior?
Jason

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org