Hi David,
I also encountered this issue. My understanding is that *any *call to an H5
function resets the error stack because in principle that call could
produce its own error [see, e.g. H5E.c:871]. Since H5get_msg succeeds, it
wipes the error stack, so error_desc becomes invalid.

The solution I used was to store the error code and translate to messages
after traversing the stack. If there are better solutions I'd love to hear
them!

Cheers,
Martijn

On 30 October 2015 at 01:26, David <[email protected]> wrote:

> Hi,
>
> I cannot figure out how to get H5Ewalk() to work. I get a good
> looking H5E_error2_t struct on the first entrance to my callback function
> but after I call H5Eget_msg() the strings are gone. The subsequent calls to
> the callback all have bad strings too. I'm guessing they are getting
> freed from the heap and overwritten with debug mode "deleted" values but is
> that what's supposed to happen?
>
> I'm using hdf5-1.8.15-patch1 and MSVS10.
>
> Thanks,
> David
>
> #include <hdf5/hdf5.h>
> #include <stdio.h>
>
> herr_t callback(unsigned n, const H5E_error2_t *err_desc, void*
> client_data)
> {
>   printf(err_desc->func_name); // prints the function name
>     H5Eget_msg(err_desc->maj_num, NULL, NULL, 0);
>   printf(err_desc->func_name); // prints garbage
>   return 0;
> }
>
> int main(int argc, char* argv[])
> {
>   H5Fopen("missingfile", H5F_ACC_RDWR, H5P_DEFAULT);
>   H5Ewalk(H5E_DEFAULT, H5E_WALK_UPWARD, callback, NULL);
>   return 0;
> }
>
>
> _______________________________________________
> 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
>
_______________________________________________
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