From 94ca861b4ee46ef81edbd31df325a33d5681b7dd Mon Sep 17 00:00:00 2001 From: vchoi Date: Thu, 5 Aug 2021 17:34:11 -0500 Subject: Fix the segmentation fault that occurs when running test/vfd_swmr_group_writer with one million old style groups. (A) src/vfd_swmr_enlarge_shadow_index(): --When enlarging the metadata file index entries, HDmalloc() is used to allocate space for the index entries, but they are later freed at file close via H5MM_xfree() in H5F__dest(). This is corrected to use H5MM_calloc() instead to be consistent. Note that entries are initially allocated also via H5MM_calloc() in H5F__vfd_swmr_create_index(). --If the pointer to the old metadata file index entries exists (shared->old_mdf_idx), need to free the old entries via H5MM_xfree(). (B) test/testvfdswmr.sh.in: --The test is added to verify that the bug is resolved. --- src/H5Fvfd_swmr.c | 8 +++++++- test/testvfdswmr.sh.in | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index 13170af..ebb57d6 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -1756,7 +1756,7 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "shadow-file allocation failed for index") } - new_mdf_idx = HDmalloc(new_mdf_idx_len * sizeof(new_mdf_idx[0])); + new_mdf_idx = H5MM_calloc(new_mdf_idx_len * sizeof(new_mdf_idx[0])); if (new_mdf_idx == NULL) { (void)H5MV_free(f, idx_addr, idx_size); @@ -1774,6 +1774,12 @@ vfd_swmr_enlarge_shadow_index(H5F_t *f) ret_value = shared->mdf_idx = new_mdf_idx; shared->mdf_idx_len = new_mdf_idx_len; + if(shared->old_mdf_idx) + H5MM_xfree(f->shared->old_mdf_idx); + + shared->old_mdf_idx = old_mdf_idx; + f->shared->old_mdf_idx_len = old_mdf_idx_len; + /* Postpone reclamation of the old index until max_lag ticks from now. * It's only necessary to wait until after the new index is in place, * so it's possible that some disused shadow storage will build up diff --git a/test/testvfdswmr.sh.in b/test/testvfdswmr.sh.in index b0ab785..7ef14be 100644 --- a/test/testvfdswmr.sh.in +++ b/test/testvfdswmr.sh.in @@ -145,9 +145,9 @@ all_tests="generator expand shrink expand_shrink sparse vlstr_null vlstr_oob zoo all_tests="${all_tests} groups groups_attrs groups_ops few_big many_small attrdset" tests=${all_tests} -# For exhaustive run, add: os_groups_attrs, os_groups_ops, dsetops, dsetchks +# For exhaustive run, add: os_groups_attrs, os_groups_ops, os_groups_seg, dsetops, dsetchks if [[ "$HDF5TestExpress" -eq 0 ]] ; then # exhaustive run - all_tests="${all_tests} os_groups_attrs os_groups_ops dsetops dsetchks" + all_tests="${all_tests} os_groups_attrs os_groups_ops os_groups_seg dsetops dsetchks" fi if [ $# -gt 0 ]; then @@ -1009,6 +1009,36 @@ done ############################################################################### # +# Setting for "os_groups_seg" test +# +# Only for exhaustive run +# +# Verify the segmentation fault is fixed when running with: +# --1,000,000 groups +# --as writer only +# +############################################################################### +# +# +GROUP_seg_n=1000000 # Number of groups when segmentation fault occurs +if [ ${do_os_groups_seg:-no} = no ]; then + continue +fi +echo launch vfd_swmr_group operations with old-style group: $GROUP_seg_n groups ......may take some time...... +catch_out_err_and_rc vfd_swmr_group_writer \ + ../vfd_swmr_group_writer -q -N -G -n $GROUP_seg_n -a $GROUP_seg_n + +# Collect exit code of the writer +if [ $(cat vfd_swmr_group_writer.rc) -ne 0 ]; then + echo writer had error + nerrors=$((nerrors + 1)) +fi + +# Clean up output files +rm -f vfd_swmr_group_writer.{out,rc} + +############################################################################### +# # Setting for bigset (few_big and many_small) tests # ############################################################################### -- cgit v0.12