summaryrefslogtreecommitdiffstats
path: root/src/H5E.c
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2021-05-12 03:22:45 (GMT)
committerGitHub <noreply@github.com>2021-05-12 03:22:45 (GMT)
commit78f0728d1b675e675f4dfb0112fc128535e10071 (patch)
tree519dcf4fa6c142ee9e39ee1ec461a29eb82dc1b1 /src/H5E.c
parent7d140b97fbd78d8071780e38e3e4287f6711f7f6 (diff)
downloadhdf5-78f0728d1b675e675f4dfb0112fc128535e10071.zip
hdf5-78f0728d1b675e675f4dfb0112fc128535e10071.tar.gz
hdf5-78f0728d1b675e675f4dfb0112fc128535e10071.tar.bz2
Fix H5Eget_auto2/H5Eauto_is_v2 to not clear error stack (#625)
Diffstat (limited to 'src/H5E.c')
-rw-r--r--src/H5E.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/src/H5E.c b/src/H5E.c
index 6d6dfd3..dabd367 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -245,6 +245,20 @@ H5E_term_package(void)
nstk = H5I_nmembers(H5I_ERROR_STACK);
if ((ncls + nmsg + nstk) > 0) {
+ /* Clear the default error stack. Note that
+ * the following H5I_clear_type calls do not
+ * force the clears and will not be able to
+ * clear any error message IDs that are still
+ * in use by the default error stack unless we
+ * clear that stack manually.
+ *
+ * Error message IDs will typically still be
+ * in use by the default error stack when the
+ * application does H5E_BEGIN/END_TRY cleanup
+ * at the very end.
+ */
+ H5E_clear_stack(NULL);
+
/* Clear any outstanding error stacks */
if (nstk > 0)
(void)H5I_clear_type(H5I_ERROR_STACK, FALSE, FALSE);
@@ -1532,7 +1546,8 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func /*out*/, void **client_data /*ou
H5E_auto_op_t op; /* Error stack function */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(FAIL)
+ /* Don't clear the error stack! :-) */
+ FUNC_ENTER_API_NOCLEAR(FAIL)
H5TRACE3("e", "ixx", estack_id, func, client_data);
if (estack_id == H5E_DEFAULT) {
@@ -1540,8 +1555,13 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func /*out*/, void **client_data /*ou
non-threaded case */
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack")
} /* end if */
- else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
+ else {
+ /* Only clear the error stack if it's not the default stack */
+ H5E_clear_stack(NULL);
+
+ if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
+ } /* end else */
/* Get the automatic error reporting information */
if (H5E__get_auto(estack, &op, client_data) < 0)
@@ -1598,8 +1618,13 @@ H5Eset_auto2(hid_t estack_id, H5E_auto2_t func, void *client_data)
non-threaded case */
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack")
} /* end if */
- else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
+ else {
+ /* Only clear the error stack if it's not the default stack */
+ H5E_clear_stack(NULL);
+
+ if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
+ } /* end else */
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Get the automatic error reporting information */
@@ -1646,7 +1671,8 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack)
H5E_t *estack; /* Error stack to operate on */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(FAIL)
+ /* Don't clear the error stack! :-) */
+ FUNC_ENTER_API_NOCLEAR(FAIL)
H5TRACE2("e", "i*Iu", estack_id, is_stack);
if (estack_id == H5E_DEFAULT) {
@@ -1654,8 +1680,13 @@ H5Eauto_is_v2(hid_t estack_id, unsigned *is_stack)
non-threaded case */
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack")
} /* end if */
- else if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
+ else {
+ /* Only clear the error stack if it's not the default stack */
+ H5E_clear_stack(NULL);
+
+ if (NULL == (estack = (H5E_t *)H5I_object_verify(estack_id, H5I_ERROR_STACK)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
+ } /* end else */
/* Check if the error stack reporting function is the "newer" stack type */
if (is_stack)