Replies: 12 comments 3 replies
-
Hello HDF Group, If the proposed functions (or something similar) by @chacha21 will be implemented would it be possible to also add function like |
Beta Was this translation helpful? Give feedback.
-
This should rather be done through a |
Beta Was this translation helpful? Give feedback.
-
You shouldn't see failures with threadsafe enabled, unless one of the threads is changing assumptions made by the other threads (such as resizing the dataset). Do you have an example program that shows the issue? Also, I'm not sure what you mean by "sequence of operation". The functions you list don't exist in the repository. |
Beta Was this translation helpful? Give feedback.
-
I did not put sample code, but you are pointing exactly at the problem. |
Beta Was this translation helpful? Give feedback.
-
What errors do you see? |
Beta Was this translation helpful? Give feedback.
-
And are you only extending the datasets or also shrinking them (along any dimension)? |
Beta Was this translation helpful? Give feedback.
-
I will post sample code (in a few days, time to make a minimal project) |
Beta Was this translation helpful? Give feedback.
-
random crashes |
Beta Was this translation helpful? Give feedback.
-
I have created a minimal project to exhibit the bug... that was finally my fault. However, my code is not fundamentally incorrect : it just requires proper locking for some custom state. The "bug" tag is now incorrect, though, only "feature request" |
Beta Was this translation helpful? Give feedback.
-
@chacha21 |
Beta Was this translation helpful? Give feedback.
-
There is no generic answer. It means that you are using your own mutexes to protect some parts of your code that could be executed in parallel by multiple threads. |
Beta Was this translation helpful? Give feedback.
-
I'm not certain what you are asking for here - if the HDF5 library is configured & built w/threadsafety, it is not possible to have concurrent operations working within the library, so it's impossible to have crashes from this. The library implements the mutex to guard against these problems, so there's no user code necessary - just call the (built with threadsafety enabled) library routines you want. |
Beta Was this translation helpful? Give feedback.
-
HDF 1.12
In the context of a single HDF5 file (with a single
file_id
) containing multiple datasets, I encounter crashes when multiple threads perform reading operations (involving hyperslabs) in the different datasets, even if HDF5 was compiled with thread safety.I understand that basic thread safety currently relies on a giant lock for each and every API call, but does not protect a sequence of operation (H5F_getspace(), H5S_selectHyperslab, H5D_read...) : that should explain the bug.
Since I work with a single file_id, I cannot expect the SWMR scheme of H5F_open() flags to help.
In my context, it is really not possible to open the file multiple times (because of #1978)
As a workaround, I successfully used a OS-provided mutex associated to the the file_id value, and enclosed my threaded sequences of operations in mutex-protected sections. But it is a pity to rely on an external locking scheme.
After thinking about it, I think that what I need is a very basic
H5F_[un]lock(hid_t file_id)
, orH5F_[un]lock_read(hid_t file_id)/H5F_[un]lock_write(hid_t file_id)
if SWMR is possible.And since it really seems very basic, I wonder why (as of my knowledge), nothing similar is available in the current API.
Beta Was this translation helpful? Give feedback.
All reactions