From a13db57efe3767d69d26772e81dc2f775bcade1c Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 2 Dec 2020 11:19:31 +0100 Subject: [PATCH] Avoid segfault in CVODES CVAdataStore (#1351) Does not fix the root cause of occassional segfaults, but turns them into exceptions / integration failues. --- ThirdParty/sundials/src/cvodes/cvodea.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ThirdParty/sundials/src/cvodes/cvodea.c b/ThirdParty/sundials/src/cvodes/cvodea.c index 9ee8c2ab65..04a04c20ee 100644 --- a/ThirdParty/sundials/src/cvodes/cvodea.c +++ b/ThirdParty/sundials/src/cvodes/cvodea.c @@ -2026,6 +2026,9 @@ static int CVAdataStore(CVodeMem cv_mem, CkpntMem ck_mem) /* Run CVode to set following structures in dt_mem[i] */ i = 1; do { + // Modified for AMICI + // (dt_mem has dimension ca_mem->ca_nsteps) + if (i > ca_mem->ca_nsteps) return(CV_FWD_FAIL); flag = CVode(cv_mem, ck_mem->ck_t1, ca_mem->ca_ytmp, &t, CV_ONE_STEP); if (flag < 0) return(CV_FWD_FAIL);