-
Notifications
You must be signed in to change notification settings - Fork 52
Add SolverException for Model and Prover due to MathSAT5/Z3 Model Problem (Including a Sneaky Throw for API not Supporting Changes) #501
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
base: master
Are you sure you want to change the base?
Conversation
…llegalArgumentException for msat_model_create_iterator()
…n as Throwable (due to Z3)
@kfriedberger i don't know if we want to warn users about the sneaky throws, but it seems reasonable. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for the iterator interface in model class, and maybe due to backard compatibility, I do not see any strong reason to hide the exception in the signature.
Why can't we specify the exception in the methods push
and addConstraint
?
…tedException to it
Since last time we tried this we ended with many changes and a long discussion, i wanted to avoid this. But since we already plan a mayor release, i added all exceptions explicitly with the exception of the iterator. |
@PhilippWendler @kfriedberger i updated the PR and the code with explicit exceptions as far as possible. Would you two be so kind and take another look? |
This is a rather big API change. This might cause some more changes in CPAchecker than done in https://gitlab.com/sosy-lab/software/cpachecker/-/merge_requests/234 (which is still open and unmerged). I am not convinced that this step is required and solves an issue: MathSAT will still crash on specific queries and CPAchecker will abort, with and without the new exception. |
There is no need to worry about CPAchecker, we can always adopt to JavaSMT API changes. It is your other users and your general API stability promise that you need to consider.
Whether something throws an unchecked exception or the checked And in CPAchecker, for example, we act accordingly: For the unchecked exception we terminate immediately and show a stack trace that should help for debugging. For the checked exception, depending on what exactly was done, we go on and try fallbacks (different solver options, maybe even different solver), or we simply skip the operation it if is not strictly required (we can still dump a counterexample even without the model), or we terminate the respective analysis but keep others in a portfolio running, or (if none of the above works) we gracefully terminate CPAchecker and print an error message for the user. So "CPAchecker will abort, with and without the new exception." is not correct. And I would expect (hope) that other users of JavaSMT treat exceptions similarly. |
I would typically not add the exception to the implementing (solver-specific) classes everywhere, but only where it is actually meaningful because the solver can produce them. For solvers where we know that a particular exception can not happen for a given operation, it might be useful to leave it out of the method signature, for example when calling the method out of solver-specific code or if for some other reason solver-specific code is called directly in the future in some use case, or simply as documentation of what can happen and what not. Apart from this I didn't notice anything particular, though of course I didn't do a complete review. |
Thank you both!
I know, hence i am unsure whether or not this is good. As Philipp says, we can manage in CPAchecker. And we do catch this exception in several Analyses (e.g. BMC and Predicate), it just looks weird that we catch a
The problem here is that we nearly always call In general it seems like
We can of course communicate this! We could also just catch the exceptions in solvers that we know/think do never throw this so that the exception is gone in the internal implementations. |
No, I would keep it easy. Just remove the exceptions declarations (transitively) from those places where the Java compiler does not require them (just classes, don't change the public API). |
…be used without exceptions and implement for Bitwuzla
…, but since they can not be thrown this is not a problem
…t since they can not be thrown this is not a problem
…t since they can not be thrown this is not a problem
As i said, the problem is the usage of I've now removed them from the solvers that do not throw them by overriding |
I would even say the additional catch clauses are not worth it. After all, it might change in the future. My comment was really just mean to say "only add the throws declarations where the compiler forces you, not everywhere for consistency (with respect to the implementing classes, not API)". |
MathSAT5s model iterator method may fail and throws an
IllegalArgumentException
. This exception is misleading, as it is a solver error when building the model. This PR catches theIllegalArgumentException
and throws a sneakySolverException
instead. Catching and throwing a different exception removed the need to recompile the solver, but could be done later on. Since Z3 has similar issues, i addedSolverException
andInterruptedException
to many API calls in the model and prover APIs.Still, since the
iterator
API does not allow a checked exception, we have to throw it sneakily unfortunately.I also added warnings in our JavaDoc for the location that may throw sneaky exceptions.
Closes: #481