-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revise file close assertion failure fix #3418
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -654,6 +654,11 @@ H5C__load_cache_image(H5F_t *f) | |
} /* end if */ | ||
|
||
done: | ||
if (ret_value < 0) { | ||
if (H5_addr_defined(cache_ptr->image_addr)) | ||
cache_ptr->image_buffer = H5MM_xfree(cache_ptr->image_buffer); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Memory leak exposed by these file create failure changes. Free cache image pointer if this function fails. |
||
|
||
FUNC_LEAVE_NOAPI(ret_value) | ||
} /* H5C__load_cache_image() */ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2581,16 +2581,14 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) | |
hbool_t fsm_opened[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ | ||
hbool_t fsm_visited[H5F_MEM_PAGE_NTYPES]; /* State of FSM */ | ||
|
||
/* Sanity check */ | ||
assert(f->shared->sblock); | ||
|
||
/* should only be called if file is opened R/W */ | ||
assert(H5F_INTENT(f) & H5F_ACC_RDWR); | ||
|
||
/* shouldn't be called unless we have a superblock supporting the | ||
* superblock extension. | ||
*/ | ||
assert(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2); | ||
if (f->shared->sblock) | ||
assert(f->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this and the below changes, try to close down as much as possible in the raw data FSM, even if the superblock isn't available. A bit dangerous if something else here uses the superblock, but I followed things far down and didn't really see anything else. |
||
|
||
/* Initialize fsm_opened and fsm_visited */ | ||
memset(fsm_opened, 0, sizeof(fsm_opened)); | ||
|
@@ -2738,40 +2736,44 @@ H5MF_settle_raw_data_fsm(H5F_t *f, hbool_t *fsm_settled) | |
* file space manager info message is guaranteed to exist. | ||
* Leave it in for now, but consider removing it. | ||
*/ | ||
if (H5_addr_defined(f->shared->sblock->ext_addr)) | ||
if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) | ||
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, | ||
"error in removing message from superblock extension"); | ||
if (f->shared->sblock) { | ||
if (H5_addr_defined(f->shared->sblock->ext_addr)) | ||
if (H5F__super_ext_remove_msg(f, H5O_FSINFO_ID) < 0) | ||
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTRELEASE, FAIL, | ||
"error in removing message from superblock extension"); | ||
} | ||
|
||
/* As the final element in 1), shrink the EOA for the file */ | ||
if (H5MF__close_shrink_eoa(f) < 0) | ||
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTSHRINK, FAIL, "can't shrink eoa"); | ||
|
||
/* 2) Ensure that space is allocated for the free space manager superblock | ||
* extension message. Must do this now, before reallocating file space | ||
* for free space managers, as it is possible that this allocation may | ||
* grab the last section in a FSM -- making it unnecessary to | ||
* re-allocate file space for it. | ||
* | ||
* Do this by writing a free space manager superblock extension message. | ||
* | ||
* Since no free space manager has file space allocated for it, this | ||
* message must be invalid since we can't save addresses of FSMs when | ||
* those addresses are unknown. This is OK -- we will write the correct | ||
* values to the message at free space manager shutdown. | ||
*/ | ||
for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) | ||
fsinfo.fs_addr[fsm_type - 1] = HADDR_UNDEF; | ||
fsinfo.strategy = f->shared->fs_strategy; | ||
fsinfo.persist = f->shared->fs_persist; | ||
fsinfo.threshold = f->shared->fs_threshold; | ||
fsinfo.page_size = f->shared->fs_page_size; | ||
fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; | ||
fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; | ||
|
||
if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) | ||
HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, | ||
"error in writing fsinfo message to superblock extension"); | ||
if (f->shared->sblock) { | ||
/* 2) Ensure that space is allocated for the free space manager superblock | ||
* extension message. Must do this now, before reallocating file space | ||
* for free space managers, as it is possible that this allocation may | ||
* grab the last section in a FSM -- making it unnecessary to | ||
* re-allocate file space for it. | ||
* | ||
* Do this by writing a free space manager superblock extension message. | ||
* | ||
* Since no free space manager has file space allocated for it, this | ||
* message must be invalid since we can't save addresses of FSMs when | ||
* those addresses are unknown. This is OK -- we will write the correct | ||
* values to the message at free space manager shutdown. | ||
*/ | ||
for (fsm_type = H5F_MEM_PAGE_SUPER; fsm_type < H5F_MEM_PAGE_NTYPES; fsm_type++) | ||
fsinfo.fs_addr[fsm_type - 1] = HADDR_UNDEF; | ||
fsinfo.strategy = f->shared->fs_strategy; | ||
fsinfo.persist = f->shared->fs_persist; | ||
fsinfo.threshold = f->shared->fs_threshold; | ||
fsinfo.page_size = f->shared->fs_page_size; | ||
fsinfo.pgend_meta_thres = f->shared->pgend_meta_thres; | ||
fsinfo.eoa_pre_fsm_fsalloc = HADDR_UNDEF; | ||
|
||
if (H5F__super_ext_write_msg(f, H5O_FSINFO_ID, &fsinfo, TRUE, H5O_MSG_FLAG_MARK_IF_UNKNOWN) < 0) | ||
HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, | ||
"error in writing fsinfo message to superblock extension"); | ||
} | ||
|
||
/* 3) Scan all free space managers not involved in allocating | ||
* space for free space managers. For each such free space | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just goes back to the previous behavior and tries to close as much of the cache as possible, even if the superblock isn't available.