-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Destroy Node
's handle before its Link
#660
Destroy Node
's handle before its Link
#660
Conversation
Fixes ess-dmsc#659. Nodes must first delete the handle to the underlying hdf5 resource before deleting their link. Otherwise (i.e., link is deleted first), hdf5 attempts to close the file (if this was the last node referencing the file), which might fail (e.g., when using mpi-io, or close degree `Semi`) because the handle to the node would still be around.
If that helps, this is a way to reproduce the issue (with the code prior to this PR):
and then running
yields
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. It looks good for me.
Nothing to add to this PR, I was on holiday, but it's a bit annoying that we can't test it, is there any reason we don't implement something like https://github.com/ess-dmsc/h5cpp/blob/master/src/h5cpp/core/object_handle.cpp#L110-L112 so we can test without worrying about cerr? If not I'm happy to make the changes. |
The reason for the current implementation (as far as I as an project external developer can guess) is that you typically want destructors to be |
Yes! And you did say this, apologies. Will blame it on coming in to 86 unread e-mails and writing a comment at the end of a long day..! |
No worries :-) |
Thanks @FlyingSamson and @ggoneiESS for your clarifications. h5cpp/src/h5cpp/attribute/attribute.cpp Lines 36 to 40 in b2669a3
|
Yes your are absolute right. Good catch! I will create another PR for that in a second. |
Fixes #659.
Nodes must first delete the handle to the underlying hdf5 resource before deleting their link.
Otherwise (i.e., link is deleted first), hdf5 attempts to close the file (if this was the last node referencing the file), which might fail (e.g., when using mpi-io, or close degree
Semi
) because the handle to the node would still be around.I tried to add a test for this, but unfortunately the error message originates from the destructor of
ObjectHandle
catching any exception and only printing an error to stderr here without rethrowing to maintainnoexept
'ness and I could not find a sensible way to check what is printed to stderr within a catch2 test.