From d41e0847473684237f49c9860b04af38df8a7cd1 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Thu, 18 Feb 2010 12:42:17 -0500 Subject: [svn-r18277] Bug fix for #1732 - The library had segmentation fault when tools call H5Close() after trying to open corrupted files. The problem turned out to be some memory leak when the library failed to open the file. The solution is simply moving some code around to their proper places - moving H5AC_unpin_entry(f->shared->sblock) in H5F_dest of H5F.c and moving H5G_name_free(root_loc.path) in H5G_mkroot of H5Groot.c. Tested on jam with production mode. Tested the same fix for 1.8 on jam with development and production modes - simple change. --- src/H5F.c | 8 +++++--- src/H5Groot.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/H5F.c b/src/H5F.c index d259db4..a9b4ff3 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -1028,14 +1028,16 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) if(H5MF_close(f, dxpl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release file free space info") + } /* end if */ - /* Unpin the superblock, since we're about to destroy the cache */ + /* Unpin the superblock, since we're about to destroy the cache */ + if(f->shared->sblock) { if(H5AC_unpin_entry(f, f->shared->sblock) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_FSPACE, H5E_CANTUNPIN, FAIL, "unable to unpin superblock") f->shared->sblock = NULL; - } /* end if */ - + } + /* Remove shared file struct from list of open files */ if(H5F_sfile_remove(f->shared) < 0) /* Push error, but keep going*/ diff --git a/src/H5Groot.c b/src/H5Groot.c index 5d07142..9dad942 100644 --- a/src/H5Groot.c +++ b/src/H5Groot.c @@ -266,13 +266,13 @@ done: * allocated */ if(ret_value < 0) { if(f->shared->root_grp) { + H5G_name_free(root_loc.path); if(f->shared->root_grp->shared) f->shared->root_grp->shared = H5FL_FREE(H5G_shared_t, f->shared->root_grp->shared); f->shared->root_grp = H5FL_FREE(H5G_t, f->shared->root_grp); } /* end if */ if(f->shared->sblock) f->shared->sblock->root_ent = (H5G_entry_t *)H5MM_xfree(f->shared->sblock->root_ent); - H5G_name_free(root_loc.path); } /* end if */ /* Mark superblock dirty in cache, if necessary */ -- cgit v0.12