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

conversion from NaN to integer (invalid operation) #34

Closed
mlubin opened this issue Jan 7, 2018 · 1 comment
Closed

conversion from NaN to integer (invalid operation) #34

mlubin opened this issue Jan 7, 2018 · 1 comment

Comments

@mlubin
Copy link
Contributor

mlubin commented Jan 7, 2018

This line:
https://github.com/oxfordcontrol/osqp/blob/2aeaebb3a3f8f718e16373caccb0c5a8e091a004/src/osqp.c#L343
will attempt to convert NaN to a c_int in the case that work->settings->check_termination equals zero, which is a valid value according to:
https://github.com/oxfordcontrol/osqp/blob/2aeaebb3a3f8f718e16373caccb0c5a8e091a004/include/types.h#L167

This conversion from NaN to integer is required to trigger an invalid operation exception according to the IEEE 754-2008 standard. On most systems this is silently ignored, but on others, under certain compiler settings, this causes the program to crash.

I was able to work around the issue by wrapping the offending line with if (work->settings->check_termination > 0) {}, but I don't understand the context of the code to know if this is correct.

bstellato added a commit that referenced this issue Jan 7, 2018
@bstellato
Copy link
Collaborator

Thanks for pointing this out! That part of the code is related to how often we update parameter rho. We usually update it at an integer multiple of check_termination.

If check_termination is disabled (we check for convergence only when the algorithm reaches the maximum number of iterations) then we should round the number of iterations to another value that makes sense.

I have changed the code in bd72c40 to use CHECK_TERMINATION constant as a reference number for rounding in case the setting check_termination is 0. It should fix your issue with the IEEE 754-2008 standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants