diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2019-01-02 19:26:58 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2019-01-02 19:26:58 (GMT) |
commit | c70498f7a919644000966616c3ff152dcedf3392 (patch) | |
tree | a4b0146909d9468a0a44921bd2e3a494d9cdb77e /src/H5Adense.c | |
parent | 71f4e1832c737e2fb76385bc478fad7f39d89ab8 (diff) | |
parent | d3dff6efe6f769b219f9dcccebd057afe75ed3c7 (diff) | |
download | hdf5-c70498f7a919644000966616c3ff152dcedf3392.zip hdf5-c70498f7a919644000966616c3ff152dcedf3392.tar.gz hdf5-c70498f7a919644000966616c3ff152dcedf3392.tar.bz2 |
Merge pull request #1414 in HDFFV/hdf5 from ~VCHOI/my_hdf5_fork:develop to develop
* commit 'd3dff6efe6f769b219f9dcccebd057afe75ed3c7':
Correction based on code review.
Changes based on feedback from pull request.
Fix for HDFFV-10659: The library abort with "infinite loop closing library" after deleting attributes in densed storage. The fix: When deleting attribute nodes from the name index v2 B-tree, if an attribute is found in the intermediate B-tree nodes, which may be merged/redistributed in the process, we need to free the dynamically allocated spaces for the intermediate decoded attribute.
Diffstat (limited to 'src/H5Adense.c')
-rw-r--r-- | src/H5Adense.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/H5Adense.c b/src/H5Adense.c index 5bed82d..021fa76 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -300,18 +300,49 @@ static herr_t H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) { H5A_t const **user_attr = (H5A_t const **)_user_attr; /* User data from v2 B-tree attribute lookup */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC /* Check arguments */ HDassert(attr); HDassert(user_attr); + HDassert(took_ownership); + /* + * If there is an attribute already stored in "user_attr", + * we need to free the dynamially allocated spaces for the + * attribute, otherwise we got infinite loop closing library due to + * outstanding allocation. (HDFFV-10659) + * + * This callback is used by H5A__dense_remove() to close/free the + * attribute stored in "user_attr" (via H5O__msg_free_real()) after + * the attribute node is deleted from the name index v2 B-tree. + * The issue is: + * When deleting the attribute node from the B-tree, + * if the attribute is found in the intermediate B-tree nodes, + * which may be merged/redistributed, we need to free the dynamically + * allocated spaces for the intermediate decoded attribute. + */ + if(*user_attr != NULL) { + H5A_t *old_attr = *user_attr; + if(old_attr->shared) { + /* Free any dynamically allocated items */ + if(H5A__free(old_attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") + + /* Destroy shared attribute struct */ + old_attr->shared = H5FL_FREE(H5A_shared_t, old_attr->shared); + } /* end if */ + + old_attr = H5FL_FREE(H5A_t, old_attr); + } /* end if */ /* Take over attribute ownership */ *user_attr = attr; *took_ownership = TRUE; - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_fnd_cb() */ |