Originally posted by: cssartori
Hello, I've been working with the CPLEX C++ API for some time now (almost a whole year) and recently I have reached a point where a bug is not allowing me to continue to do my research. I've been trying for the past few days to debug my program and I just can't find the error. All the applications I have used to try to identify where it is happening point me to CPLEX library, even though I think it is not the case.
I'm building a pretty standard MIP model with a matrix of binary variables, and three arrays of real/integer variables.
The bug is segmentation fault that happens sometimes only, and in a different place each time (or at least it is detected at a different place each time it happens). Basically, from around 50 runs, three give me this seg fault, and only when using big instances (with a binary matrix of size 1000 x 1000 ). It is more common when I'm running instances of the program in parallel. I have already checked memory usage, and there is enough to run them in parallel, and the swap is on anyway (it is not used, but it could before killing the process). Each program calls CPLEX in single thread mode.
What I have done so far is to use GDB, which was not successful because it is hard to reproduce the error. By calling the program with catchsegv (from Linux) the program tells me the problem is either in the calling to solve, or in the moment of extracting the problem. Once or twice it told me it was when I was building one constraint or another. So, this is not very helpfull anyway.
The final test was using valgrind, which gave me some more information, though I don't know if actually usefull. It tells me that in the moment of extracting certain objects, such as Objective Function, or others, there is an invalid read of some bytes that were not allocated before. below follows a small print:
==12561== Parent PID: 12560
==12561==
==12561== Warning: set address range perms: large range [0x79de2040, 0x8ccf2b10) (undefined)
==12561== Warning: set address range perms: large range [0x8ccf9040, 0x9fc09b10) (undefined)
==12561== Invalid read of size 4
==12561== at 0x6E6510: _c10eb1f4d9a2d5f2419fc4b6fdd63002 (in /home/code/main)
==12561== by 0x7004EF: _db5b20d0578ce6bb874a10606d0d2157 (in /home/code/main)
==12561== by 0x700225: _06d59c776fe54a486c95a0b14a460289 (in /home/code/main)
==12561== by 0x86DA23: _b15b628f6e2221db01548906080666df (in /home/code/main)
==12561== by 0x7E0571: _88460010ab4bed13741d30767523c0a1 (in /home/code/main)
==12561== by 0x7E05D4: CPXLchgprobtype (in /home/code/main)
==12561== by 0x4168CA: IloCplexI::flushCtype() (in /home/code/main)
==12561== by 0x41B5B8: IloCplexI::doflush() (in /home/code/main)
==12561== by 0x41B619: IloCplexI::flush(long) const (in /home/code/main)
==12561== by 0x43717A: IloCplexI::setObj(int, IloCarray<double> const&, IloCarray<int*> const&, double) (in /home/code/main)
==12561== by 0x479AFE: IloDefaultLPExtractor::doextractObj(IloObjectiveI const*) (in /home/code/main)
==12561== by 0x479F14: IloDefaultLPExtractor::extractObj(IloObjectiveI const*, int**) (in /home/code/main)
==12561== Address 0xff093e80 is not stack'd, malloc'd or (recently) free'd
==12561==
==12561==
==12561== Process terminating with default action of signal 11 (SIGSEGV)
==12561== Access not within mapped region at address 0xFF093E80
==12561== at 0x6E6510: _c10eb1f4d9a2d5f2419fc4b6fdd63002 (in /home/code/main)
==12561== by 0x7004EF: _db5b20d0578ce6bb874a10606d0d2157 (in /home/code/main)
==12561== by 0x700225: _06d59c776fe54a486c95a0b14a460289 (in /home/code/main)
==12561== by 0x86DA23: _b15b628f6e2221db01548906080666df (in /home/code/main)
==12561== by 0x7E0571: _88460010ab4bed13741d30767523c0a1 (in /home/code/main)
==12561== by 0x7E05D4: CPXLchgprobtype (in /home/code/main)
==12561== by 0x4168CA: IloCplexI::flushCtype() (in /home/code/main)
==12561== by 0x41B5B8: IloCplexI::doflush() (in /home/code/main)
==12561== by 0x41B619: IloCplexI::flush(long) const (in /home/code/main)
==12561== by 0x43717A: IloCplexI::setObj(int, IloCarray<double> const&, IloCarray<int*> const&, double) (in /home/code/main)
==12561== by 0x479AFE: IloDefaultLPExtractor::doextractObj(IloObjectiveI const*) (in /home/code/main)
==12561== by 0x479F14: IloDefaultLPExtractor::extractObj(IloObjectiveI const*, int**) (in /home/code/main)
==12561== If you believe this happened as a result of a stack
==12561== overflow in your program's main thread (unlikely but
==12561== possible), you can try to increase the size of the
==12561== main thread stack using the --main-stacksize= flag.
==12561== The main thread stack size used in this run was 8388608.
==12561==
I'm compiling the program with g++ 5.4.0 under Ubuntu 16.04 LTS. My CPLEX API version is 12.6.2
I have no idea how to proceed, everything I know about debugging I have already tried, and all the tools I have used are pointing to CPLEX, thus I come here hoping anyone can give me some light, even if it is by saying that it is certainly NOT CPLEX.
Thanks in advance
#CPLEXOptimizers#DecisionOptimization