Skip to content
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

Pause recording errors instead of clearing the error stack #4475

Merged
merged 38 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1a20767
Pause recording errors instead of clearing the error stack
qkoziol May 10, 2024
a488357
Committing clang-format changes
github-actions[bot] May 10, 2024
1a0a353
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol May 13, 2024
a9928fa
Bring 'pause' of errors down to lowest level possible
qkoziol May 13, 2024
f1d505d
Committing clang-format changes
github-actions[bot] May 13, 2024
c44e319
Fix spelling typos
qkoziol May 13, 2024
ff45632
Fix memory leak
qkoziol May 13, 2024
d0d9c85
Committing clang-format changes
github-actions[bot] May 13, 2024
7508c47
Add H5fortkit dependecy for H5Rff.F90 (#4482)
brtnfld May 14, 2024
0a3e193
Properly clean up cache when failing to load an object header (#4477)
fortnern May 14, 2024
685ced4
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol May 14, 2024
5e66a0b
Disable EOF checks for SWMR readers in more cases.
qkoziol May 14, 2024
3cdc6d0
Add H5Eis_paused, H5Epause_stack, and H5Eresume_stack
qkoziol May 17, 2024
1059010
Committing clang-format changes
github-actions[bot] May 17, 2024
991ecad
Correct spelling errors
qkoziol May 17, 2024
b0559e4
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol May 20, 2024
fea96d3
Allow the "default" error stack to be paused and resumed
qkoziol May 23, 2024
7e7bd41
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol May 23, 2024
2cf5b77
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol May 23, 2024
7e12d7c
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol May 25, 2024
07d2859
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol May 28, 2024
e1f105e
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol May 31, 2024
604f268
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol Jun 3, 2024
756ffda
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol Jun 4, 2024
706270f
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol Jun 5, 2024
05efa32
Update release version in doxygen
qkoziol Jun 5, 2024
385df3d
Address review comments
qkoziol Jun 6, 2024
e62e272
Update comment
qkoziol Jun 6, 2024
134ebf4
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol Jun 6, 2024
ead2cdb
Merge "try open" and "open" routines into one, with a 'try' parameter
qkoziol Jun 7, 2024
5dadd23
Committing clang-format changes
github-actions[bot] Jun 7, 2024
ba9ced2
Fix some missed calls
qkoziol Jun 7, 2024
fcbfb70
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol Jun 7, 2024
d3f1599
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol Jun 8, 2024
ebf575b
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol Jun 13, 2024
1074ab6
Committing clang-format changes
github-actions[bot] Jun 13, 2024
b3f7036
Merge remote-tracking branch 'origin/develop' into pause_errors
qkoziol Jun 18, 2024
734325c
Add release note
qkoziol Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions bin/format_source
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ find . \( -type d -path ./config -prune -and -not -path ./config \) \
-name H5LTanalyze.c \
-or -name H5LTparse.c \
-or -name H5LTparse.h \
-or -name H5Epubgen.h \
-or -name H5Edefin.h \
-or -name H5Einit.h \
-or -name H5Emajdef.h \
-or -name H5Emindef.h \
-or -name H5Epubgen.h \
-or -name H5Eterm.h \
-or -name H5Edefin.h \
-or -name H5version.h \
-or -name H5overflow.h \
\) \) \
Expand Down
10 changes: 4 additions & 6 deletions src/H5Dvirtual.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,16 +875,14 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *vir
intent = H5F_INTENT(vdset->oloc.file);

/* Try opening the file */
src_file = H5F_prefix_open_file(vdset->oloc.file, H5F_PREFIX_VDS, vdset->shared->vds_prefix,
source_dset->file_name, intent,
vdset->shared->layout.storage.u.virt.source_fapl);
if (H5F_prefix_try_open_file(&src_file, vdset->oloc.file, H5F_PREFIX_VDS, vdset->shared->vds_prefix,
source_dset->file_name, intent,
vdset->shared->layout.storage.u.virt.source_fapl) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENFILE, FAIL, "can't try opening file");

/* If we opened the source file here, we should close it when leaving */
if (src_file)
src_file_open = true;
else
/* Reset the error stack */
H5E_clear_stack();
} /* end if */
else
/* Source file is ".", use the virtual dataset's file */
Expand Down
179 changes: 147 additions & 32 deletions src/H5E.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,11 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid
/* Don't clear the error stack! :-) */
FUNC_ENTER_API_NOCLEAR(FAIL)

if (err_stack == H5E_DEFAULT)
estack = NULL;
/* Check for 'default' error stack */
if (err_stack == H5E_DEFAULT) {
if (NULL == (estack = H5E__get_my_stack()))
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get the default error stack");
}
else {
/* Only clear the error stack if it's not the default stack */
H5E_clear_stack();
Expand All @@ -543,35 +546,33 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID");
} /* end else */

/* Note that the variable-argument parsing for the format is identical in
* the H5E_printf_stack() routine - correct errors and make changes in both
* places. -QAK
*/

/* Format the description */
va_start(ap, fmt);
va_started = true;

/* Duplicate string information */
if (NULL == (tmp_file = strdup(file)))
HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate file string");
if (NULL == (tmp_func = strdup(func)))
HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate function string");

/* Increment refcount on non-library IDs */
if (cls_id != H5E_ERR_CLS_g)
if (H5I_inc_ref(cls_id, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment class ID");
if (maj_id < H5E_first_maj_id_g || maj_id > H5E_last_maj_id_g)
if (H5I_inc_ref(maj_id, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment major error ID");
if (min_id < H5E_first_min_id_g || min_id > H5E_last_min_id_g)
if (H5I_inc_ref(min_id, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment minor error ID");

/* Push the error on the stack */
if (H5E__push_stack(estack, true, tmp_file, tmp_func, line, cls_id, maj_id, min_id, fmt, &ap) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack");
/* Check if error reporting is paused for this stack */
if (!estack->paused) {
/* Start the variable-argument parsing */
va_start(ap, fmt);
va_started = true;

/* Duplicate string information */
if (NULL == (tmp_file = strdup(file)))
HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate file string");
if (NULL == (tmp_func = strdup(func)))
HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate function string");

/* Increment refcount on non-library IDs */
if (cls_id != H5E_ERR_CLS_g)
if (H5I_inc_ref(cls_id, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment class ID");
if (maj_id < H5E_first_maj_id_g || maj_id > H5E_last_maj_id_g)
if (H5I_inc_ref(maj_id, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment major error ID");
if (min_id < H5E_first_min_id_g || min_id > H5E_last_min_id_g)
if (H5I_inc_ref(min_id, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment minor error ID");

/* Push the error on the stack */
if (H5E__push_stack(estack, true, tmp_file, tmp_func, line, cls_id, maj_id, min_id, fmt, &ap) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack");
}

done:
if (va_started)
Expand Down Expand Up @@ -865,7 +866,6 @@ H5Eappend_stack(hid_t dst_stack_id, hid_t src_stack_id, hbool_t close_source_sta
H5E_stack_t *dst_stack, *src_stack; /* Error stacks */
herr_t ret_value = SUCCEED; /* Return value */

/* Don't clear the error stack! :-) */
FUNC_ENTER_API(FAIL)

/* Check args */
Expand All @@ -889,3 +889,118 @@ H5Eappend_stack(hid_t dst_stack_id, hid_t src_stack_id, hbool_t close_source_sta
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Eappend_stack() */

/*-------------------------------------------------------------------------
* Function: H5Eis_paused
*
* Purpose: Check if pushing errors on an error stack is paused
*
* Return: Non-negative value on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Eis_paused(hid_t stack_id, hbool_t *is_paused)
{
H5E_stack_t *stack; /* Error stack */
herr_t ret_value = SUCCEED; /* Return value */

/* Don't clear the error stack! :-) */
qkoziol marked this conversation as resolved.
Show resolved Hide resolved
FUNC_ENTER_API_NOCLEAR(FAIL)

/* Get the correct error stack */
if (stack_id == H5E_DEFAULT) {
if (NULL == (stack = H5E__get_my_stack()))
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack");
} /* end if */
else {
/* Only clear the error stack if it's not the default stack */
H5E_clear_stack();

/* Get the error stack to operate on */
if (NULL == (stack = (H5E_stack_t *)H5I_object_verify(stack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack ID");
} /* end else */

/* Check arguments */
if (NULL == is_paused)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "is_paused parameter is NULL");

/* Check if the stack is paused */
*is_paused = (stack->paused > 0);

done:
FUNC_LEAVE_API(ret_value)
} /* end H5Eis_paused() */

/*-------------------------------------------------------------------------
* Function: H5Epause_stack
*
* Purpose: Pause pushing errors on an error stack
*
* Return: Non-negative value on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Epause_stack(hid_t stack_id)
{
H5E_stack_t *stack; /* Error stack */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)

/* Get the correct error stack */
if (stack_id == H5E_DEFAULT) {
if (NULL == (stack = H5E__get_my_stack()))
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack");
} /* end if */
else
/* Get the error stack to operate on */
if (NULL == (stack = (H5E_stack_t *)H5I_object_verify(stack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack ID");

/* Increment pause counter */
stack->paused++;

done:
FUNC_LEAVE_API(ret_value)
} /* end H5Epause_stack() */

/*-------------------------------------------------------------------------
* Function: H5Eresume_stack
*
* Purpose: Resume pushing errors on an error stack
*
* Return: Non-negative value on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5Eresume_stack(hid_t stack_id)
{
H5E_stack_t *stack; /* Error stack */
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)

/* Get the correct error stack */
if (stack_id == H5E_DEFAULT) {
if (NULL == (stack = H5E__get_my_stack()))
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack");
} /* end if */
else
/* Get the error stack to operate on */
if (NULL == (stack = (H5E_stack_t *)H5I_object_verify(stack_id, H5I_ERROR_STACK)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack ID");

/* Check for pause/resume imbalance */
if (0 == stack->paused)
HGOTO_ERROR(H5E_ERROR, H5E_BADRANGE, FAIL, "resuming more than paused");

/* Decrement pause counter */
stack->paused--;

done:
FUNC_LEAVE_API(ret_value)
} /* end H5Eresume_stack() */
49 changes: 29 additions & 20 deletions src/H5Edeprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,30 +182,38 @@ H5Eget_minor(H5E_minor_t min)
herr_t
H5Epush1(const char *file, const char *func, unsigned line, H5E_major_t maj, H5E_minor_t min, const char *str)
{
const char *tmp_file; /* Copy of the file name */
const char *tmp_func; /* Copy of the function name */
herr_t ret_value = SUCCEED; /* Return value */
H5E_stack_t *estack; /* Pointer to error stack to modify */
const char *tmp_file; /* Copy of the file name */
const char *tmp_func; /* Copy of the function name */
herr_t ret_value = SUCCEED; /* Return value */

/* Don't clear the error stack! :-) */
FUNC_ENTER_API_NOCLEAR(FAIL)

/* Duplicate string information */
if (NULL == (tmp_file = strdup(file)))
HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate file string");
if (NULL == (tmp_func = strdup(func)))
HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate function string");

/* Increment refcount on non-library IDs */
if (maj < H5E_first_maj_id_g || maj > H5E_last_maj_id_g)
if (H5I_inc_ref(maj, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment major error ID");
if (min < H5E_first_min_id_g || min > H5E_last_min_id_g)
if (H5I_inc_ref(min, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment minor error ID");

/* Push the error on the default error stack */
if (H5E__push_stack(NULL, true, tmp_file, tmp_func, line, H5E_ERR_CLS_g, maj, min, str, NULL) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack");
/* Get the 'default' error stack */
if (NULL == (estack = H5E__get_my_stack()))
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get the default error stack");

/* Check if error reporting is paused for this stack */
if (!estack->paused) {
/* Duplicate string information */
if (NULL == (tmp_file = strdup(file)))
HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate file string");
if (NULL == (tmp_func = strdup(func)))
HGOTO_ERROR(H5E_ERROR, H5E_CANTALLOC, FAIL, "can't duplicate function string");

/* Increment refcount on non-library IDs */
if (maj < H5E_first_maj_id_g || maj > H5E_last_maj_id_g)
if (H5I_inc_ref(maj, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment major error ID");
if (min < H5E_first_min_id_g || min > H5E_last_min_id_g)
if (H5I_inc_ref(min, false) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINC, FAIL, "can't increment minor error ID");

/* Push the error on the default error stack */
if (H5E__push_stack(estack, true, tmp_file, tmp_func, line, H5E_ERR_CLS_g, maj, min, str, NULL) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "can't push error on stack");
}

done:
FUNC_LEAVE_API(ret_value)
Expand Down Expand Up @@ -259,6 +267,7 @@ H5Eprint1(FILE *stream)
/* Don't clear the error stack! :-) */
FUNC_ENTER_API_NOCLEAR(FAIL)

/* Get the 'default' error stack */
if (NULL == (estack = H5E__get_my_stack()))
HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack");

Expand Down
Loading
Loading