scs icon indicating copy to clipboard operation
scs copied to clipboard

Wrong argument type to QDLDL_factor

Open mwoehlke-kitware opened this issue 9 months ago • 3 comments

I am trying to build https://github.com/RobotLocomotion/drake. But I am running into an error:

546.6 external/drake++internal_repositories+scs_internal/linsys/cpu/direct/private.c: In function 'ldl_factor':
546.6 external/drake++internal_repositories+scs_internal/linsys/cpu/direct/private.c:68:48: error: passing argument 12 of 'QDLDL_factor' from incompatible pointer type [-Wincompatible-pointer-types]
546.6    68 |                    p->Dinv, p->Lnz, p->etree, p->bwork, p->iwork, p->fwork);
546.6       |                                               ~^~~~~~~
546.6       |                                                |
546.6       |                                                scs_int * {aka int *}
546.6 In file included from external/drake++internal_repositories+scs_internal/linsys/cpu/direct/private.h:10,
546.6                  from external/drake++internal_repositories+scs_internal/linsys/cpu/direct/private.c:1:
546.6 external/drake++internal_repositories+qdldl_internal/include/qdldl.h:123:46: note: expected 'QDLDL_bool *' {aka 'unsigned char *'} but argument is of type 'scs_int *' {aka 'int *'}
546.6   123 |                                  QDLDL_bool* bwork,
546.6       |                                  ~~~~~~~~~~~~^~~~~

Both the most recent release (0.1.7) and master (as of 2025-03-17) of https://github.com/osqp/qdldl specify the parameter type of bwork as QDLDL_bool *. But SCS is passing an incompatible scs_int *:

https://github.com/cvxgrp/scs/blob/bd8eea598c6b7c093e1f833255406f720364f437/linsys/cpu/direct/private.h#L25 https://github.com/cvxgrp/scs/blob/bd8eea598c6b7c093e1f833255406f720364f437/linsys/cpu/direct/private.c#L54

mwoehlke-kitware avatar Mar 17 '25 17:03 mwoehlke-kitware

Note, QDLD_bool is always unsigned char.

mwoehlke-kitware avatar Mar 17 '25 17:03 mwoehlke-kitware

@mwoehlke-kitware note that scs uses its own version of qldl (see ./linsys/external/qdldl) which is fixed at version 0.1.6 (it's this commit of of the upstream qdldl): https://github.com/osqp/qdldl/commit/a00d500906621fbf014b39e42a3304d1143eb65f

EDIT: but it seems that unsigned char was the only option then as well: https://github.com/osqp/qdldl/blob/a00d500906621fbf014b39e42a3304d1143eb65f/CMakeLists.txt#L79 hmm...

kalmarek avatar Mar 17 '25 18:03 kalmarek

Drake is using an external qdldl, but yeah, it hasn't changed anyway.

It seems to me that private.{h,c} should maybe use the qdldl types instead of the scs types?

Anyway, here's my attempt to patch it from Drake: https://github.com/RobotLocomotion/drake/pull/22771.

You might be able to reproduce on stand-alone builds with -Werror=incompatible-pointer-types.

mwoehlke-kitware avatar Mar 17 '25 19:03 mwoehlke-kitware

PR here: https://github.com/cvxgrp/scs/pull/319/files

bodono avatar Aug 08 '25 19:08 bodono