Skip to content

Commit

Permalink
Merge pull request #1 in ~DYOUNG/vchoi_fork from ~DEROBINS/hdf5_der:s…
Browse files Browse the repository at this point in the history
…vd_multi_memory_fix to multi

* commit '09981b58d800d784a2aa7e3ea5f7f1cad576e8db':
  Fixes a leak of the metadata index memory
  • Loading branch information
derobins committed Sep 9, 2020
2 parents ff8b70d + 09981b5 commit 361861d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
20 changes: 14 additions & 6 deletions src/H5Fint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1425,15 +1425,23 @@ H5F__dest(H5F_t *f, hbool_t flush)
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")

/* A VFD SWMR reader may still have a metadata index at this stage.
* If so, free it.
/* A VFD SWMR reader may still have metadata indexes at this stage.
* If so, free them.
*/
if (f->shared->vfd_swmr && f->shared->mdf_idx != NULL) {
HDfree(f->shared->mdf_idx);
f->shared->mdf_idx = NULL;
f->shared->mdf_idx_len = 0;
if (f->shared->vfd_swmr) {
if (f->shared->mdf_idx != NULL) {
H5MM_xfree(f->shared->mdf_idx);
f->shared->mdf_idx = NULL;
f->shared->mdf_idx_len = 0;
}
if (f->shared->old_mdf_idx != NULL) {
H5MM_xfree(f->shared->old_mdf_idx);
f->shared->old_mdf_idx = NULL;
f->shared->old_mdf_idx_len = 0;
}
}


/* Free mount table */
f->shared->mtab.child = (H5F_mount_t *)H5MM_xfree(f->shared->mtab.child);
f->shared->mtab.nalloc = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/H5Fvfd_swmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,7 @@ H5F__vfd_swmr_create_index(H5F_shared_t *shared)

HDassert(entries_in_index > 0);

index = HDcalloc(entries_in_index, sizeof(index[0]));
index = H5MM_calloc(entries_in_index * sizeof(index[0]));

if (index == NULL) {
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
Expand Down
14 changes: 9 additions & 5 deletions test/vfd_swmr_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file,
int fill_count = 0; /* # of times fill value (0) was read
* instead of the expected value.
*/
hid_t dsid; /* Dataset ID */
hid_t file_sid; /* Dataset's space ID */
hid_t dsid = H5I_INVALID_HID; /* Dataset ID */
hid_t file_sid = H5I_INVALID_HID; /* Dataset's space ID */
hssize_t snpoints; /* Number of elements in dataset */
hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */

Expand Down Expand Up @@ -237,9 +237,9 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file,
time_t curr_time; /* Current time */
symbol_info_t **sym_com = NULL; /* Pointers to array of common dataset IDs */
symbol_info_t **sym_rand = NULL; /* Pointers to array of random dataset IDs */
hid_t mem_sid; /* Memory dataspace ID */
hid_t fid; /* SWMR test file ID */
hid_t fapl; /* file access property list */
hid_t mem_sid = H5I_INVALID_HID; /* Memory dataspace ID */
hid_t fid = H5I_INVALID_HID; /* SWMR test file ID */
hid_t fapl = H5I_INVALID_HID; /* file access property list */
symbol_t record; /* The record to read from the dataset */
unsigned v; /* Local index variable */
hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */
Expand Down Expand Up @@ -672,6 +672,10 @@ int main(int argc, const char *argv[])
HDexit(1);
} /* end if */

/* Close the output file */
if(verbose)
HDfclose(verbose_file);

return 0;
}

0 comments on commit 361861d

Please sign in to comment.