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

339 stackoverflowerror using mathsat5 #345

Merged
merged 46 commits into from
Jan 3, 2024

Conversation

daniel-raffler
Copy link
Contributor

Hello everyone,
this is my fix for bug #339. The issue was in the implementation of the termination call back for MathSAT in our JNI bindings. In order to check whether the shutdown manager has been triggered we need to provide MathSAT with a way of calling back our Java code. For this the current Jenv pointer is stored when a new prover environment instance is created. Unfortunately this pointer is only valid for the current thread, and if isUnsat is later called from any other thread we get a StackOverflowError. The solution is to only install the callback right before the native call to MathSAT in isUnsat. This way we can be sure to be on the right thread when the JEnv is saved. Once MathSAT returns we can then remove the callback again.

In addition to the bug fix this pull request also includes a new test class "SolverThreadLocalityTest" that is meant to find similar errors in other solvers.

…en MathSat returns a "user-requested termination" error.
…gered when MathSat returns a "user-requested termination" error."

This reverts commit 4003c34.
…eneds when formulas are used outside of their context.
@daniel-raffler daniel-raffler linked an issue Dec 19, 2023 that may be closed by this pull request
@daniel-raffler
Copy link
Contributor Author

Hello Philipp,
thanks a lot for the review! I think I've now addressed all of your points. Is there anything else you would like me to change?

@PhilippWendler
Copy link
Member

I guess Daniel will do a full review, I just stumbled upon this because I was interested in this issue (good find btw.!) and left comments where I noticed something.

I guess you could get rid of the boolean result that you have in the two changed methods.

This commit unifies the level of abstraction
for registering a shutdown-callback and removing the callback afterwards.
@kfriedberger kfriedberger self-requested a review December 26, 2023 23:06
Copy link
Member

@kfriedberger kfriedberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bugfix is a great outcome, well done! The tests are well written, too.

The steps for debugging and narrowing the problem (cf. commit history of this PR) are very interesting.

👍

@daniel-raffler or @baierd : Who has the honor and would like to merge this?

@daniel-raffler
Copy link
Contributor Author

Thanks for your help, Karlheinz! I've talked to Daniel and he will merge the branch in the next few days.

…d to create the ProverEnvironment on the thread. The other version also fails, but for different reasons and this somehow got mixed up earlier.
@baierd baierd merged commit 5320a50 into master Jan 3, 2024
2 of 4 checks passed
baierd pushed a commit that referenced this pull request Jan 3, 2024
baierd pushed a commit that referenced this pull request Jan 3, 2024
… termination test directly in isUnsat and isUnsatWithAssumptions. This was suggested in #345 (comment)
@daniel-raffler daniel-raffler deleted the 339-stackoverflowerror-using-mathsat5 branch April 4, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

StackOverflowError using MathSAT5
4 participants