osqp / osqp-matlab

Matlab interface for OSQP
https://osqp.org/
Apache License 2.0
42 stars 25 forks source link

Check A dimensions match P #22

Closed abrandemuehl closed 4 years ago

abrandemuehl commented 4 years ago

The second dimension of A is not currently checked, so it won't be detected when size(A,2) ~= size(P,1). In the mex, this can result in using uninitialized memory when they don't match. For me it showed up as nnz(A) being uninitialized causing a malloc failure.

abrandemuehl commented 4 years ago

Here's a simple reproduction. It will either not fail (which is also wrong) or it will give an Out of Memory error

P = sparse(ones(3, 3));
q = [];
A = sparse(ones(3, 2));
l = ones(3,1);
u = ones(3,1);

problem = osqp;
settings = osqp.default_settings();
problem.setup(P, q, A, l, u, settings);
gbanjac commented 4 years ago

Looks good. Thanks for the fix!

imciner2 commented 4 years ago

Shouldn't this have gone into develop and been included in the next bug-fix release? There is already at least one other change sitting in develop for the next release.