scipopt / scip

SCIP - Solving Constraint Integer Programs
Other
406 stars 67 forks source link

Segmentation fault when declaring constraints (only sometimes) #59

Closed SanPen closed 5 months ago

SanPen commented 1 year ago

Hi,

This is one of those weird bugs that make you love C++.

I have a MIP formulation interface in my C++ program which works similar to ORTOOLS.

I wrote a SCIP interface linking it dynamically with dlsym. In my system I have SCIP 8.0.3. which I got from the release site here.

I'm getting a segmentation fault when declaring the array of constraints, but only for a certain problem size.

The sequence of SCIP commands are these:

SCIP* scip;
SCIP_RETCODE ret_val;
SCIP_STAGE stage;

// declare var pointers
SCIP_VAR* vars[557088];

// declare constraint pointers
SCIP_CONS* constraints[491904];   /// the SEGFAULT happens here

I run my program with valgrind, and then it does not happen, I run the sequence of commands independently and it doesn't happen

I don't know if anyone has had such weird segfault. Any help with this is appreciated.

PS: the same problem with other solvers solves fine.

svigerske commented 1 year ago

If neither valgrind help nor a debugger is useful, then try sanitizers.

If you build SCIP with OPT=dbg on Linux with gcc or clang, then some should get enabled by default. You get more by SANITZIE=full. (This is with the normal makefiles. Someone else would have to explain what happens in the cmake system.) Or you add compiler/linker flags manually.