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

Fix #461 - truncated error messages #462

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ for more details.

Added support for Kokkos Kernels v4.

Fixed a bug that caused error messages to be cut off in some cases. Ref. #461.
balos1 marked this conversation as resolved.
Show resolved Hide resolved

## Changes to SUNDIALS in release v7.0.0

### Major Feature
Expand Down
3 changes: 3 additions & 0 deletions doc/shared/RecentChanges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ Fixed a bug where :c:func:`MRIStepEvolve` would not handle a recoverable error
produced from evolving the inner stepper.

Added support for Kokkos Kernels v4.

Fixed a bug that caused error messages to be cut off in some cases. Ref.
`#461 <https://github.com/LLNL/sundials/issues/461>`_.
balos1 marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 7 additions & 3 deletions src/arkode/arkode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3325,15 +3325,20 @@ int arkAccessHAdaptMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem,
void arkProcessError(ARKodeMem ark_mem, int error_code, int line,
const char* func, const char* file, const char* msgfmt, ...)
{
/* Initialize the argument pointer variable
/* We initialize the argument pointer variable before each time before calling vsnprintf to avoid undefined behavior
balos1 marked this conversation as resolved.
Show resolved Hide resolved
(msgfmt is the last required argument to arkProcessError) */
va_list ap;
va_start(ap, msgfmt);

/* Compose the message */
va_start(ap, msgfmt);
size_t msglen = vsnprintf(NULL, 0, msgfmt, ap) + 1;
va_end(ap);

char* msg = (char*)malloc(msglen);

va_start(ap, msgfmt);
vsnprintf(msg, msglen, msgfmt, ap);
va_end(ap);

do {
if (ark_mem == NULL)
Expand Down Expand Up @@ -3362,7 +3367,6 @@ void arkProcessError(ARKodeMem ark_mem, int error_code, int line,
while (0);

/* Finalize argument processing */
balos1 marked this conversation as resolved.
Show resolved Hide resolved
va_end(ap);
free(msg);

return;
Expand Down
11 changes: 7 additions & 4 deletions src/cvode/cvode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4824,15 +4824,20 @@ static int cvEwtSetSV(CVodeMem cv_mem, N_Vector ycur, N_Vector weight)
void cvProcessError(CVodeMem cv_mem, int error_code, int line, const char* func,
const char* file, const char* msgfmt, ...)
{
/* Initialize the argument pointer variable
/* We initialize the argument pointer variable before each time before calling vsnprintf to avoid undefined behavior
balos1 marked this conversation as resolved.
Show resolved Hide resolved
(msgfmt is the last required argument to cvProcessError) */
va_list ap;
va_start(ap, msgfmt);

/* Compose the message */
va_start(ap, msgfmt);
size_t msglen = vsnprintf(NULL, 0, msgfmt, ap) + 1;
va_end(ap);

char* msg = (char*)malloc(msglen);

va_start(ap, msgfmt);
vsnprintf(msg, msglen, msgfmt, ap);
va_end(ap);

do {
if (cv_mem == NULL)
Expand Down Expand Up @@ -4860,8 +4865,6 @@ void cvProcessError(CVodeMem cv_mem, int error_code, int line, const char* func,
}
while (0);

/* Finalize argument processing */
va_end(ap);
free(msg);

return;
Expand Down
11 changes: 7 additions & 4 deletions src/cvodes/cvodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -9908,15 +9908,20 @@ static int cvQuadSensRhs1InternalDQ(CVodeMem cv_mem, int is, sunrealtype t,
void cvProcessError(CVodeMem cv_mem, int error_code, int line, const char* func,
const char* file, const char* msgfmt, ...)
{
/* Initialize the argument pointer variable
/* We initialize the argument pointer variable before each time before calling vsnprintf to avoid undefined behavior
balos1 marked this conversation as resolved.
Show resolved Hide resolved
(msgfmt is the last required argument to cvProcessError) */
va_list ap;
va_start(ap, msgfmt);

/* Compose the message */
va_start(ap, msgfmt);
size_t msglen = vsnprintf(NULL, 0, msgfmt, ap) + 1;
va_end(ap);

char* msg = (char*)malloc(msglen);

va_start(ap, msgfmt);
vsnprintf(msg, msglen, msgfmt, ap);
va_end(ap);

do {
if (cv_mem == NULL)
Expand Down Expand Up @@ -9944,8 +9949,6 @@ void cvProcessError(CVodeMem cv_mem, int error_code, int line, const char* func,
}
while (0);

/* Finalize argument processing */
va_end(ap);
free(msg);

return;
Expand Down
11 changes: 7 additions & 4 deletions src/ida/ida.c
Original file line number Diff line number Diff line change
Expand Up @@ -3992,15 +3992,20 @@ static int IDARootfind(IDAMem IDA_mem)
void IDAProcessError(IDAMem IDA_mem, int error_code, int line, const char* func,
const char* file, const char* msgfmt, ...)
{
/* Initialize the argument pointer variable
/* We initialize the argument pointer variable before each time before calling vsnprintf to avoid undefined behavior
balos1 marked this conversation as resolved.
Show resolved Hide resolved
(msgfmt is the last required argument to IDAProcessError) */
va_list ap;
va_start(ap, msgfmt);

/* Compose the message */
va_start(ap, msgfmt);
size_t msglen = vsnprintf(NULL, 0, msgfmt, ap) + 1;
va_end(ap);

char* msg = (char*)malloc(msglen);

va_start(ap, msgfmt);
vsnprintf(msg, msglen, msgfmt, ap);
va_end(ap);

do {
if (IDA_mem == NULL)
Expand Down Expand Up @@ -4028,8 +4033,6 @@ void IDAProcessError(IDAMem IDA_mem, int error_code, int line, const char* func,
}
while (0);

/* Finalize argument processing */
va_end(ap);
free(msg);

return;
Expand Down
11 changes: 7 additions & 4 deletions src/idas/idas.c
Original file line number Diff line number Diff line change
Expand Up @@ -8756,15 +8756,20 @@ static int IDAQuadSensRhs1InternalDQ(IDAMem IDA_mem, int is, sunrealtype t,
void IDAProcessError(IDAMem IDA_mem, int error_code, int line, const char* func,
const char* file, const char* msgfmt, ...)
{
/* Initialize the argument pointer variable
/* We initialize the argument pointer variable before each time before calling vsnprintf to avoid undefined behavior
balos1 marked this conversation as resolved.
Show resolved Hide resolved
(msgfmt is the last required argument to IDAProcessError) */
va_list ap;
va_start(ap, msgfmt);

/* Compose the message */
va_start(ap, msgfmt);
size_t msglen = vsnprintf(NULL, 0, msgfmt, ap) + 1;
va_end(ap);

char* msg = (char*)malloc(msglen);

va_start(ap, msgfmt);
vsnprintf(msg, msglen, msgfmt, ap);
va_end(ap);

do {
if (IDA_mem == NULL)
Expand Down Expand Up @@ -8792,8 +8797,6 @@ void IDAProcessError(IDAMem IDA_mem, int error_code, int line, const char* func,
}
while (0);

/* Finalize argument processing */
va_end(ap);
free(msg);

return;
Expand Down
11 changes: 7 additions & 4 deletions src/kinsol/kinsol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2563,15 +2563,20 @@ void KINPrintInfo(KINMem kin_mem, int info_code, const char* module,
void KINProcessError(KINMem kin_mem, int error_code, int line, const char* func,
const char* file, const char* msgfmt, ...)
{
/* Initialize the argument pointer variable
/* We initialize the argument pointer variable before each time before calling vsnprintf to avoid undefined behavior
balos1 marked this conversation as resolved.
Show resolved Hide resolved
(msgfmt is the last required argument to KINProcessError) */
va_list ap;
va_start(ap, msgfmt);

/* Compose the message */
va_start(ap, msgfmt);
size_t msglen = vsnprintf(NULL, 0, msgfmt, ap) + 1;
va_end(ap);

char* msg = (char*)malloc(msglen);

va_start(ap, msgfmt);
vsnprintf(msg, msglen, msgfmt, ap);
va_end(ap);

do {
if (kin_mem == NULL)
Expand Down Expand Up @@ -2599,8 +2604,6 @@ void KINProcessError(KINMem kin_mem, int error_code, int line, const char* func,
}
while (0);

/* Finalize argument processing */
va_end(ap);
free(msg);

return;
Expand Down
Loading