diff options
author | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2020-01-15 23:27:48 (GMT) |
---|---|---|
committer | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2020-01-15 23:27:48 (GMT) |
commit | 024f7ba09250110c19b070c9699cfbc0f9dc2b96 (patch) | |
tree | cc3e04bdcb987e194bb481540fca17a2e2ea914a /test | |
parent | eaa8ab277491173b66d3b08ad74920547073e677 (diff) | |
parent | a7648879d729c1b75bd32f3a151831e9cbfbe31c (diff) | |
download | hdf5-024f7ba09250110c19b070c9699cfbc0f9dc2b96.zip hdf5-024f7ba09250110c19b070c9699cfbc0f9dc2b96.tar.gz hdf5-024f7ba09250110c19b070c9699cfbc0f9dc2b96.tar.bz2 |
Merge pull request #2237 in HDFFV/hdf5 from ~JSOUMAGNE/hdf5:HDFFV-10992-fix to develop
* commit 'a7648879d729c1b75bd32f3a151831e9cbfbe31c':
Add test for reference shutdown issue
H5R: set app ref when incrementing ref_count on location held by reference (fix HDFFV-10992)
Diffstat (limited to 'test')
-rw-r--r-- | test/trefer_shutdown.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/test/trefer_shutdown.c b/test/trefer_shutdown.c new file mode 100644 index 0000000..89a44b3 --- /dev/null +++ b/test/trefer_shutdown.c @@ -0,0 +1,83 @@ +#include "h5test.h" + +int +main(int argc, char **argv) +{ + H5R_ref_t write_ref, read_ref; + hid_t fid; + hid_t did; + hid_t sid; + int i; + + if ((fid = H5Fcreate("HDFFV-10992.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + HDfprintf(stderr, "H5Fcreate failed\n"); + return 1; + } + + if ((sid = H5Screate(H5S_SCALAR)) < 0) { + HDfprintf(stderr, "H5Screate failed\n"); + return 1; + } + + /* Create a dataset of object references */ + if ((did = H5Dcreate2(fid, "dset", H5T_STD_REF, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + HDfprintf(stderr, "H5Dcreate failed\n"); + return 1; + } + + for (i = 0; i < 100; i++) { + /* Create reference to the root group */ + if (H5Rcreate_object(fid, "/dset", H5P_DEFAULT, &write_ref) < 0) { + HDfprintf(stderr, "H5Rcreate_object failed\n"); + return 1; + } + } + + /* Write reference to dataset */ + if (H5Dwrite(did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, &write_ref) < 0) { + HDfprintf(stderr, "H5Dwrite failed\n"); + return 1; + } + + for (i = 0; i < 500; i++) { + /* Read reference back into different reference buffer */ + if (H5Dread(did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, &read_ref) < 0) { + HDfprintf(stderr, "H5Dread failed\n"); + return 1; + } + } + + /* + * "Forget" to call H5Rdestroy on reference objects. If H5Rdestroy + * is called at least once on either reference object, or both + * objects, the infinite loop goes away. If H5Rdestroy is never + * called, the infinite loop will appear. + */ +#if 0 + if (H5Rdestroy(&write_ref) < 0) { + HDfprintf(stderr, "H5Rdestroy on reference write buffer failed\n"); + return 1; + } + if (H5Rdestroy(&read_ref) < 0) { + HDfprintf(stderr, "H5Rdestroy on reference read buffer failed\n"); + return 1; + } +#endif + + if (H5Sclose(sid) < 0) { + HDfprintf(stderr, "H5Sclose failed\n"); + return 1; + } + + if (H5Dclose(did) < 0) { + HDfprintf(stderr, "H5Dclose failed\n"); + return 1; + } + + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "H5Fclose failed\n"); + return 1; + } + + return 0; +} |