H5Eget_msg sounds like it should not clear the stack or have any side
effect whatsoever.  Is there a technical reason why it calls the
FUNC_ENTER_API macro?

-Jason

On Fri, Oct 30, 2015 at 6:32 PM, David <[email protected]> wrote:

>
> H5Eget_msg() uses the FUNC_ENTER_API(FAIL) macro on entrance which clears
> the error stack.
>
> Interestingly the deprecated functions H5Eget_major() and H5Eget_minor()
> uses FUNC_ENTER_API_NOCLEAR(NULL) instead which preserves the error stack.
>
> In the manual Section 9.4.7, "Traverse an Error Stack with a Callback
> Function" the example code uses H5Eget_msg() as though the stack is not
> cleared which of course fails under the current implementation. Might it be
> that at one point the intention was to have H5Eget_msg() not clear the
> error stack so that using it in the callback for H5Ewalk() is possible? I
> don't see any reasonable way to implement a walk callback without using the
> deprecated functions instead.
>
> David
>
> On Fri, Oct 30, 2015 at 7:04 AM, Allen Byrne <[email protected]> wrote:
>
>> David and Martijn,
>>
>> We use these calls in our Java wrapper library (and execute tests) that
>> implement what you need. See the exceptionImp.c file in our hdf-java repo.
>> Also available at;
>>     http://www.hdfgroup.org/products/java/release/download.html
>>
>> Martijn is correct about the error stack being reset, which is why you
>> need to
>> save the stack and restore it on calls that will reset the stack.
>>
>> Allen
>>
>>
>> On Friday, October 30, 2015 02:35:04 PM Martijn Jasperse wrote:
>> > 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
>>
>
>
> _______________________________________________
> 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