-
-
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
Fix leak of internal IDs registered during compound datatype conversion #4459
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 |
---|---|---|
|
@@ -1655,12 +1655,11 @@ H5T__unlock_cb(void *_dt, hid_t H5_ATTR_UNUSED id, void *_udata) | |
FUNC_ENTER_PACKAGE_NOERR | ||
|
||
assert(dt); | ||
assert(dt->shared); | ||
|
||
if (H5T_STATE_IMMUTABLE == dt->shared->state) { | ||
if (dt->shared && (H5T_STATE_IMMUTABLE == dt->shared->state)) { | ||
dt->shared->state = H5T_STATE_RDONLY; | ||
(*n)++; | ||
} /* end if */ | ||
} | ||
|
||
FUNC_LEAVE_NOAPI(SUCCEED) | ||
} /* end H5T__unlock_cb() */ | ||
|
@@ -1874,7 +1873,6 @@ H5T__close_cb(H5T_t *dt, void **request) | |
|
||
/* Sanity check */ | ||
assert(dt); | ||
assert(dt->shared); | ||
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. Handled further down when |
||
|
||
/* If this datatype is VOL-managed (i.e.: has a VOL object), | ||
* close it through the VOL connector. | ||
|
@@ -4154,10 +4152,10 @@ H5T_close_real(H5T_t *dt) | |
FUNC_ENTER_NOAPI(FAIL) | ||
|
||
/* Sanity check */ | ||
assert(dt && dt->shared); | ||
assert(dt); | ||
|
||
/* Clean up resources, depending on shared state */ | ||
if (dt->shared->state != H5T_STATE_OPEN) { | ||
if (dt->shared && (dt->shared->state != H5T_STATE_OPEN)) { | ||
if (H5T__free(dt) < 0) | ||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); | ||
|
||
|
@@ -4194,10 +4192,9 @@ H5T_close(H5T_t *dt) | |
|
||
/* Sanity check */ | ||
assert(dt); | ||
assert(dt->shared); | ||
|
||
/* Named datatype cleanups */ | ||
if (dt->shared->state == H5T_STATE_OPEN) { | ||
if (dt->shared && (dt->shared->state == H5T_STATE_OPEN)) { | ||
/* Decrement refcount count on open named datatype */ | ||
dt->shared->fo_count--; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,21 +264,32 @@ H5T__conv_struct_init(const H5T_t *src, const H5T_t *dst, H5T_cdata_t *cdata, co | |
if (need_ids) { | ||
hid_t tid; | ||
|
||
if ((tid = H5I_register(H5I_DATATYPE, priv->src_memb[i], false)) < 0) { | ||
H5T__conv_struct_free(priv); | ||
cdata->priv = NULL; | ||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, | ||
"can't register ID for source compound member datatype"); | ||
/* Only register new IDs for the source and destination member datatypes | ||
* if IDs weren't already registered for them. If the cached conversion | ||
* information has to be recalculated (in the case where the library's | ||
* table of conversion functions is modified), the same IDs can be reused | ||
* since the only information that needs to be recalculated is the conversion | ||
* paths used. | ||
*/ | ||
if (priv->src_memb_id[i] == H5I_INVALID_HID) { | ||
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. Is it a guarantee that the memb_id's are initialized to H5I_INVALID_HID? 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. Yes, they are initialized a bit above around line 174 and 180 |
||
if ((tid = H5I_register(H5I_DATATYPE, priv->src_memb[i], false)) < 0) { | ||
H5T__conv_struct_free(priv); | ||
cdata->priv = NULL; | ||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, | ||
"can't register ID for source compound member datatype"); | ||
} | ||
priv->src_memb_id[i] = tid; | ||
} | ||
priv->src_memb_id[i] = tid; | ||
|
||
if ((tid = H5I_register(H5I_DATATYPE, priv->dst_memb[src2dst[i]], false)) < 0) { | ||
H5T__conv_struct_free(priv); | ||
cdata->priv = NULL; | ||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, | ||
"can't register ID for destination compound member datatype"); | ||
if (priv->dst_memb_id[src2dst[i]] == H5I_INVALID_HID) { | ||
if ((tid = H5I_register(H5I_DATATYPE, priv->dst_memb[src2dst[i]], false)) < 0) { | ||
H5T__conv_struct_free(priv); | ||
cdata->priv = NULL; | ||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, | ||
"can't register ID for destination compound member datatype"); | ||
} | ||
priv->dst_memb_id[src2dst[i]] = tid; | ||
} | ||
priv->dst_memb_id[src2dst[i]] = tid; | ||
} | ||
} /* end if */ | ||
} /* end for */ | ||
|
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.
The changes in this file are for making the library handle unlocking/closing of partially initialized datatypes more gracefully