Skip to content

SetMaxNumSteps return codes are not checked (stale flag asserted) #5045

@WeiqunZhang

Description

@WeiqunZhang
  • Type: Correctness / Error handling
  • Severity: Medium
  • Component: SUNDIALS integrator setup
  • Location:
    • Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H:281
    • Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H:355
    • Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H:446

Problem

Calls to ARKStepSetMaxNumSteps do not assign their return value to flag, yet AMREX_ALWAYS_ASSERT(flag == 0) follows. The assert checks a stale value from a previous API call.

Impact

  • Failure from SetMaxNumSteps can pass unnoticed.
  • Setup can proceed with incorrect step-limit configuration.

Suggested patch

Capture and check each return code directly.

--- a/Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H
+++ b/Src/Extern/SUNDIALS/AMReX_SundialsIntegrator.H
@@
-        ARKStepSetMaxNumSteps(arkode_mem, max_num_steps);
+        flag = ARKStepSetMaxNumSteps(arkode_mem, max_num_steps);
         AMREX_ALWAYS_ASSERT(flag == 0);
@@
-        ARKStepSetMaxNumSteps(arkode_fast_mem, max_num_steps);
+        flag = ARKStepSetMaxNumSteps(arkode_fast_mem, max_num_steps);
         AMREX_ALWAYS_ASSERT(flag == 0);
@@
-        ARKStepSetMaxNumSteps(arkode_mem, max_num_steps);
+        flag = ARKStepSetMaxNumSteps(arkode_mem, max_num_steps);
         AMREX_ALWAYS_ASSERT(flag == 0);

Prepared by Codex

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions