Open tkoolen opened 6 years ago
Same with update_settings!
. It would actually be quite nice to be able to set settings before calling setup!
. In fact, if OSQP itself supported it, I would personally opt to remove the settings
kwargs from setup!
to completly separate problem-dependent data and solver settings, so as to simplify things.
This is the same issue as in here https://github.com/oxfordcontrol/osqp/issues/39. I think the easiest solution is to add a check if the workspace is null to all the OSQP update functions in C. If the workspace is null I would return an error using the exitflag in C without generating a segfault.
I would not change the C osqp_setup
interface for now because it would make things more complicated in my opinion. We can extend the Julia interface with multiple functions, but I would keep the current functions as they are to mimic the Python and Matlab interfaces.
This actually does look like an interface-specific issue. That backtrace (and the similar backtrace in #86) appear to be trying to directly access the structure before setup has been called using the Julia memory accessors. This will of course try to access an unallocated piece of memory since the library hasn't been initialized. There isn't anything we can do in the C library to work around that, the field accessors for the Julia wrappers should do null pointer checks to ensure the data being accessed is valid. I do see that it is checking the workspace against C_NULL
already here https://github.com/osqp/OSQP.jl/blob/a173b5a3be98d74b79d7e89898f30bd9ff4f1e69/src/interface.jl#L750, so something else is needed as well.
Turns out this was the unsafe_load
causing the segfault, not the subsequent access to the struct (which was already guarded in a null check). This was fixed in https://github.com/osqp/OSQP.jl/pull/126, but we need to audit the rest of the functions to make sure we don't try to load a null struct in any other places.