summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5E.c49
-rw-r--r--test/testfiles/err_compat_15
2 files changed, 44 insertions, 10 deletions
diff --git a/src/H5E.c b/src/H5E.c
index c32de5a..c5ba26e 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -244,6 +244,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);
@@ -1531,16 +1545,22 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func, void **client_data)
H5E_auto_op_t op; /* Error stack function */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_API(FAIL)
- H5TRACE3("e", "i*x**x", estack_id, func, client_data);
+ /* Don't clear the error stack! :-) */
+ FUNC_ENTER_API_NOCLEAR(FAIL)
+ H5TRACE3("e", "ixx", estack_id, func, client_data);
if (estack_id == H5E_DEFAULT) {
if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in
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)
@@ -1597,8 +1617,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 */
@@ -1645,7 +1670,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) {
@@ -1653,8 +1679,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)
diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1
index fc99f77..2562800 100644
--- a/test/testfiles/err_compat_1
+++ b/test/testfiles/err_compat_1
@@ -22,7 +22,10 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
minor: Inappropriate type
********* Print error stack in customized way *********
- error #000: (file name) in H5Eget_auto(1 or 2)(): line (number)
+ error #000: (file name) in H5Dcreate2(): line (number)
+ major: Invalid arguments to routine
+ minor: Inappropriate type
+ error #001: (file name) in H5Eget_auto(1 or 2)(): line (number)
major: Error API
minor: Can't get value