-
Notifications
You must be signed in to change notification settings - Fork 138
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
Segmentation fault in CVAdataStore #49
Comments
I investigated the matter a bit more. It seems that the software package I use (https://github.com/AMICI-dev/AMICI) is calling functions not in the public API. So maybe when only the public API is used the index |
This might be the same issue as #31? |
amici wants to avoid sundials' checkpointing, that's we set `steps` (the number of integration steps at which a checkpoint is created) for `CVodeAdjInit` to the maximum number of integration steps (`mxsteps`) for the forward problem. However, the checkpoint is created at step `steps`, not at step `steps + 1`. Therefore, if the forward integration takes exactly `mxsteps`, a checkpoint is still created. This is not a problem per se, but it may trigger segfaults under circumstances not fully understood (-> LLNL/sundials#49). Although unlikely, it still occasionally crashes long running optimizations. This change should make sure that checkpointing never occurs.
amici wants to avoid sundials' checkpointing, that's we set `steps` (the number of integration steps at which a checkpoint is created) for `CVodeAdjInit` to the maximum number of integration steps (`mxsteps`) for the forward problem. However, the checkpoint is created at step `steps`, not at step `steps + 1`. Therefore, if the forward integration takes exactly `mxsteps`, a checkpoint is still created. This is not a problem per se, but it may trigger segfaults under circumstances not fully understood (-> LLNL/sundials#49). Although unlikely, it still occasionally crashes long running optimizations. This change should make sure that checkpointing never occurs.
amici wants to avoid sundials' checkpointing, that's we set `steps` (the number of integration steps at which a checkpoint is created) for `CVodeAdjInit` to the maximum number of integration steps (`mxsteps`) for the forward problem. However, the checkpoint is created at step `steps`, not at step `steps + 1`. Therefore, if the forward integration takes exactly `mxsteps`, a checkpoint is still created. This is not a problem per se, but it may trigger segfaults under circumstances not fully understood (-> LLNL/sundials#49). Although unlikely, it still occasionally crashes long running optimizations. This change should make sure that checkpointing never occurs.
Hi, this issue still persists with SUNDIALS 7.1.1. I can reproduce it, but unfortunately, I cannot provide a self-contained example. The problem occurs if forward integration from a checkpoint under While this shouldn't happen, it does happen occasionally. I don't know what exactly is causing this. While I don't necessarily expect SUNDIALS to be able to handle this case, it would be great to at least gracefully fail with an error message if |
This issue can easily be triggered by providing a non-deterministic Jacobian. For example, by applying the following patch to diff --git a/examples/cvodes/serial/cvsRoberts_ASAi_dns.c b/examples/cvodes/serial/cvsRoberts_ASAi_dns.c
index c60c74ce2..78abf884a 100644
--- a/examples/cvodes/serial/cvsRoberts_ASAi_dns.c
+++ b/examples/cvodes/serial/cvsRoberts_ASAi_dns.c
@@ -162,6 +162,7 @@ int main(int argc, char* argv[])
ckpnt = NULL;
y = yB = qB = NULL;
+ srand(0);
/* Print problem description */
printf("\nAdjoint Sensitivity Example for Chemical Kinetics\n");
printf("-------------------------------------------------\n\n");
@@ -581,7 +582,7 @@ static int Jac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J,
p2 = data->p[1];
p3 = data->p[2];
- IJth(J, 1, 1) = -p1;
+ IJth(J, 1, 1) = -p1 + p1 / 1000.0 * ((double)rand() / RAND_MAX);
IJth(J, 1, 2) = p2 * y3;
IJth(J, 1, 3) = p2 * y2;
IJth(J, 2, 1) = p1;
|
Thanks for the reproducer @dweindl. I think adding a check to gracefully fail with an error message is reasonable. |
For some parameter values I get a segmentation fault while doing adjoint sensitivity analysis.
The problematic point is line 2033 in the following snippet:
sundials/src/cvodes/cvodea.c
Lines 2027 to 2037 in 0c83e0b
It seems that the index
i
is not checked for being inside the bounds of thedt_mem
array.If I add the check
if (i > ca_mem->ca_nsteps) return(CV_FWD_FAIL);
at the beginning of the loop body the segmentation fault is solved.However, I am not sure if this is the correct thing to do or if index
i
should always be inside the bounds and the actual problem lies elsewhere.The text was updated successfully, but these errors were encountered: