HDFGroup / HDF.PInvoke

Raw HDF5 Power for .NET
http://www.hdfgroup.org/HDF5
Other
80 stars 29 forks source link

H5E.walk_t should have err_desc marked with [In] attribute? #154

Closed marklam closed 5 years ago

marklam commented 5 years ago

When using a stack walking function in a debug build, the CLR terminates the app due to heap corruption.

I think it's a side-effect of marshalling the error_t structure. If the definition of walk_t is changed to add the [In] attribute to err_desc:

        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
        public delegate herr_t walk_t
             (
             uint n,
             [In]ref H5E.error_t err_desc,
             IntPtr client_data
             );

then the stack-walking completes successfully.

gheber commented 5 years ago

Good catch. It appears that C# gets the "special" treatment and the error doesn't show in the (admittedly, dumb) unit test. I'll push out new Nu(g)Gets in a few. Let me know if that fixes the issue.

marklam commented 5 years ago

I couldn't create a C# unit test that showed it either :-) I've checked the 1.10.5.1 packages, and can confirm that they do fix the problem - thanks!