Skip to content
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

Applications using dynamic plugins must link to shared HDF5 library #1009

Open
planetmarshall opened this issue Sep 15, 2021 · 4 comments
Open
Assignees
Labels
Component - Testing Code in test or testpar directories, GitHub workflows Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Improvement Improvements that don't add a new feature or functionality

Comments

@planetmarshall
Copy link

planetmarshall commented Sep 15, 2021

Summary

Applications using dynamic plugins must link to shared HDF5 library. API calls from the plugin fail if the application loading the plugin links to the static library

Steps to reproduce

See the attached minimal sample:

plugin_test.tar.gz

mkdir build
cd build
cmake ..  -DH5_PLUGIN_BUILD_SHARED=OFF
cmake --build .
export HDF5_PLUGIN_PATH=$(pwd)/plugins
./h5_plugin_test

Expected results

Test executable should exit cleanly with the following output:

filter is available for encoding and decoding.
....Create dataset ................
Chunk dimensions are 4X8....Writing compressed data ................

Actual results

filter is available for encoding and decoding.
....Create dataset ................
HDF5-DIAG: Error detected in HDF5 (1.12.1) thread 0:
  #000: ../src/H5S.c line 970 in H5Sget_simple_extent_dims(): not a dataspace
    major: Invalid arguments to routine
    minor: Inappropriate type
Error getting dimensions
...
#015: ../src/H5Z.c line 773 in H5Z__prelude_callback(): error during user callback
    major: Data filters
    minor: Error from filter 'set local' callback
failed to create dataset.

Workaround

Configure as above but link the shared HDF5 libraries with

cmake ..  -DH5_PLUGIN_BUILD_SHARED=ON

Notes

If this is expected behaviour I could not locate it in the documentation.

@planetmarshall planetmarshall changed the title Applications using dynamic plugins must link to dynamic HDF5 library Applications using dynamic plugins must link to shared HDF5 library Sep 15, 2021
planetmarshall added a commit to planetmarshall/h5jpegls that referenced this issue Sep 16, 2021
@planetmarshall
Copy link
Author

Note that this is also the case for the HDF5 tools, eg h5repack-shared can be used with a dynamic plugin whereas h5repack rasies the same error as above.

@byrnHDF
Copy link
Contributor

byrnHDF commented Sep 19, 2021

HDF5 using dynamic plugins use the dlopen call, which must use shared libraries. Otherwise application will use an incorrect instance of the hdf5 library.

@planetmarshall
Copy link
Author

HDF5 using dynamic plugins use the dlopen call, which must use shared libraries. Otherwise application will use an incorrect instance of the hdf5 library.

Yes that makes sense, thanks - though I do think the documentation needs to be clearer on this point (I'm happy to contribute that documentation once I've finished work on this plugin).

This limitation also only applies to plugins that call back into the HDF5 API - not all of them do, notably the bzip2 sample plugin.

If the plugin callback signatures were extended to make calling back into the API unecessary (eg by providing chunk size and type information), this limitation could be mitigated.

planetmarshall added a commit to planetmarshall/h5jpegls that referenced this issue Sep 20, 2021
@derobins derobins added Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Component - Testing Code in test or testpar directories, GitHub workflows Type - Improvement Improvements that don't add a new feature or functionality labels May 4, 2023
@byrnHDF
Copy link
Contributor

byrnHDF commented Jun 14, 2024

The documentation needs to fixed in hdf5. And the plugins repo as well.

This limitation also only applies to plugins that call back into the HDF5 API - not all of them do, notably the bzip2 sample >>plugin.

NO, this limitation applies always when using plugins and needs to be documented.
When building plugins, the hdf5 library used to build can be static (shared still has advantages across platforms) under very limited conditions. If there are no calls back into the library, there might be a reason, but not recommended. The actual plugin must be a shared module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Testing Code in test or testpar directories, GitHub workflows Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

No branches or pull requests

4 participants