Skip to content

Prevent hdf5 calling atexit() #160

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

Merged
merged 3 commits into from
Jun 27, 2021
Merged

Conversation

mulimoen
Copy link
Collaborator

hdf5 calling atexit could create double free situations, where an orphaned thread would try to access a handle after it's been freed by the main thread.

The functioncality disabled by this involves flushing data, closing objects, and cleaning up memory used. This is provided by Drop by rust, and pure rust programs will not be affected by this change.

In multi-language applications, care must be taken that all handles are closed by the programmer before program exit.

Fixes #159

mulimoen added 2 commits June 18, 2021 22:10
This could create double free situations, where an orphaned
thread would try to access a handle after it's been freed
by the main thread.
@mulimoen mulimoen force-pushed the bugfix/dont_atexit branch from fd5aed7 to 45da8d0 Compare June 18, 2021 20:10
@@ -18,7 +18,10 @@ use crate::internal_prelude::*;

lazy_static! {
static ref LIBRARY_INIT: () = {
h5lock!(::hdf5_sys::h5::H5open());
h5lock!({
::hdf5_sys::h5::H5dont_atexit();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a comment re: why this is here?

@aldanor
Copy link
Owner

aldanor commented Jun 27, 2021

Looks good, thanks! Maybe a quick note in the changelog?

@mulimoen
Copy link
Collaborator Author

Thanks @aldanor, I've added an entry to the changelog and a comment on the initialisation.

@mulimoen
Copy link
Collaborator Author

Failure in CI/wine is unrelated to the current PR

@mulimoen mulimoen merged commit ca5eb20 into aldanor:master Jun 27, 2021
@mulimoen mulimoen deleted the bugfix/dont_atexit branch June 27, 2021 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segfault during drop
2 participants