embotech/ecos

ECOS segfaults on infeasible problem

Closed this issue · 6 comments

The mini example below is almost the same as another issue I opened (one for ECOS_BB). The difference is that the example below has no integrality constraints.

import ecos
import numpy as np
from scipy.sparse import csc_matrix

# Construct an infeasible problem:
#   min (0)
#        subject to 0 * x <= -1
#   where "x" is length 2, and the 0 multiplying x is 2-by-2.

G = csc_matrix(np.zeros((2,2)))
h = -np.ones((2,))
c = np.zeros((2,))
dims = {'l': 2}

res = ecos.solve(c, G, h, dims)  #  exit code 139 (interrupted by signal 11: SIGSEGV)

It's harder for me to see where this issue is happening. I suspect it's because the C representation of the sparse matrix G has some data being indexed, when no data exists. (Since G is the zero matrix.)

I'm encountering a similar issue. The solver segfaults inside the ECOS_cleanup() function, specifically when running unset_equilibration(). The problem is NOT infeasible though, at least not in 2.0.6.
The issue first appears in 2.0.7rc. I was able to trace it back to this change: 50b2ced?diff=unified#diff-76df4b1f970166f3adf2998cedeb2574R84
idxint is now an int instead of long. I don't yet know why this leads to the segfault but maybe this helps. Let me know if you need further information.

This might also be unrelated, since the problem seems to become infeasible in 2.0.7rc and it could be an issue in how I use ECOS. But the different datatype definitely is the source.

echu commented

I'm running Ubuntu 18.04 64-bit.

In my case, the issue was that I had compiled ECOS with idxint being of type long while forgetting to set the appropriate preprocessor definitions to also use long in my code, which ended up using int and causing the segfault.

@EmbersArc thanks for reporting back, this will hopefully help other people in the future as well. If you are on Linux, I also suggest using google's sanitizers (for example https://github.com/google/sanitizers/wiki/AddressSanitizer) to debug such issues - just in case you had not heard of them before.

I'm closing this for the time being, if anyone encounters more issues, just comment again and we'll reopen (or open another issue if it's a separate thing)