diff options
author | vchoi <vchoi@jelly.ad.hdfgroup.org> | 2021-08-05 22:34:11 (GMT) |
---|---|---|
committer | vchoi <vchoi@jelly.ad.hdfgroup.org> | 2021-08-05 22:34:11 (GMT) |
commit | 94ca861b4ee46ef81edbd31df325a33d5681b7dd (patch) | |
tree | 79838058dd7c065fd6f8f28d01ad36509338dcb3 /src/H5Fvfd_swmr.c | |
parent | 14cbceaa96dfef990e34179de4a49ff226c71ae7 (diff) | |
download | hdf5-94ca861b4ee46ef81edbd31df325a33d5681b7dd.zip hdf5-94ca861b4ee46ef81edbd31df325a33d5681b7dd.tar.gz hdf5-94ca861b4ee46ef81edbd31df325a33d5681b7dd.tar.bz2 |
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.
Diffstat (limited to 'src/H5Fvfd_swmr.c')
-rw-r--r-- | src/H5Fvfd_swmr.c | 8 |
1 files changed, 7 insertions, 1 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 |