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

minion_rs / minion_c++: internal Minion checks throw SIGTERM; we probably want an exception instead? #244

Open
niklasdewally opened this issue Feb 22, 2024 · 2 comments
Assignees
Labels
area::solvers/minion Related to minion_rs, the minion C++ bindings, and the minion solver interface. kind::bug Something isn't working kind::feature New feature or request

Comments

@niklasdewally
Copy link
Contributor

When testing #230, Felix and I mistakenly used a watchneq constraint with bound variables. This triggered, during search, an internal minion check that SIGTERM-ed the entire executing process:

Cannot use watchneq with BOUND or SPARSEBOUND variables.
Please use neq as a replacement or Please use DISCRETE variables instead.

I think it would be useful for these to throw an exception over FFI instead of terminating the program. An immediate use-case for this would be improperly type-checked constraints inside our cargo tests : currently, the failing test SIGTERMs the entire test suite whereas an exception would be passed upwards and reported as a test failure.

@niklasdewally niklasdewally added kind::feature New feature or request area::solvers/minion Related to minion_rs, the minion C++ bindings, and the minion solver interface. kind::bug Something isn't working labels Feb 22, 2024
@ChrisJefferson
Copy link
Contributor

I suggest trying to remove (almost) every 'exit' and 'abort' in minion (we can remove almost all of them in both library and main mode).

There is already a 'try/catch' in the 'main' of minion, so I suggest making a new error type ( FatalMinionError ?) which contains a string and return code, replacing all exit and abort with throwing that, then catching them in 'main' and printing out the message (and exiting with the return code).

The only thing to watch out for is places where minion does 'catch(...)', which would catch these objects. Fortunately, I don't think there are any catches in minion which would cause a problem.

After doing that, the library code can just catch the same error objects.

I'm not sure if anyone feels confident enough with their C++-foo to try doing that :) I'm happy to look at this in about a week, if no-one else has tackled it before then.

@niklasdewally
Copy link
Contributor Author

niklasdewally commented Feb 23, 2024

I'm not sure if anyone feels confident enough with their C++-foo to try doing that :) I'm happy to look at this in about a week, if no-one else has tackled it before then.

I think I can do this; I more or less know where checks happen and where errors need to go.

@niklasdewally niklasdewally self-assigned this Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area::solvers/minion Related to minion_rs, the minion C++ bindings, and the minion solver interface. kind::bug Something isn't working kind::feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants