Opened 11 years ago

Closed 7 weeks ago

#51 closed defect (migrated)

OsiVolSolverInterface::addCol SIGSEGV

Reported by: nowozin Owned by: mjs
Priority: major Milestone:
Component: OsiCpx Version:
Keywords: Cc:

Description

I use COIN-OR Osi 0.98 (checked out from SVN at 5th March 2008) to solve a large linear program. The code works as expected with OsiClp? and OsiMsk? but crashes with OsiVol? and OsiCpx?. I only report the OsiVol? case below but I suspect the bug is the same in OsiCpx?. The code programatically creates the problem in the following way (leaving out some details, but showing the order of calls):

   OsiSolverInterface* si = new OsiVolSolverInterface;
   // use column major in order to cheaply append columns
   CoinPackedMatrix* matrix = new CoinPackedMatrix(true, 0, 0);
   double* varLB = new double[N];
   double* varUB = new double[N];
   double* objective = new double[N];
   // ... set variable upper/lower bounds and obj coefficients

   CoinPackedVector csum;
   // ... set some coefficients
   matrix->appendRow(csum);

   // Generate rows programmatically.  Do this in an extra matrix once instead of appending rows
   // to the column-major main matrix
   CoinPackedMatrix m_matrix(false, 0, 0);
   m_matrix.setDimensions(0, N);
   m_matrix.reserve(N * K, 2 * N * K, false);
   for (unsigned int n = 0; n < N*K; ++n) {
        CoinPackedVector nconstraint;
        // ... set some coefficients in nconstraint
        m_matrix.appendRow(margin_constraint);
   }
   matrix->bottomAppendPackedMatrix(m_matrix);

   double* rowLB = new double[1 + N*K];
   double* rowUB = new double[1 + N*K];
   // ... set rowLB/rowUB elements

   // Set constraint matrix
   si->assignProblem(matrix, varLB, varUB, objective, rowLB, rowUB);
   si->setObjSense(1); // minimize

   CoinPackedVector col;
   // ... setting elements in col
   // CRASH upon calling this line with si a OsiVolSolverInterface.
   si->addCol(col, 0.0, si->getInfinity(), 0.0);

My system is a x86 64bit system. Linux mohave 2.6.22-14-generic #1 SMP Tue Feb 12 02:46:46 UTC 2008 x86_64 GNU/Linux

The crash dump looks like this:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 47594371764096 (LWP 8829)]
0x00002b4967434ea0 in CoinDisjointCopyN<bool> () from /opt/coin-osi-0.98/lib/libOsiVol.so.0
(gdb) bt
#0  0x00002b4967434ea0 in CoinDisjointCopyN<bool> ()
   from /opt/coin-osi-0.98/lib/libOsiVol.so.0
#1  0x00002b496742dd70 in OsiVolSolverInterface::colRimResize_ ()
   from /opt/coin-osi-0.98/lib/libOsiVol.so.0
#2  0x00002b496742dfec in OsiVolSolverInterface::addCol ()
   from /opt/coin-osi-0.98/lib/libOsiVol.so.0
#3  0x000000000041657d in Boosting::LPBoostMulticlassClassifier::AddMulticlassClassifier ()

If you need further information, please let me know. I would provide an isolated test case but it is considerable work as the solver is just a part of a larger program. If required, I can isolate a piece of code that reproduces the bug.

Attachments (1)

osivol-0.98-assignproblem-fix.patch (574 bytes) - added by nowozin 11 years ago.
Possible fix for assignProblem method in OsiVol?

Download all attachments as: .zip

Change History (6)

comment:1 Changed 11 years ago by nowozin

Small correct, the variable named "margin_constraint" should be "nconstraint".

Changed 11 years ago by nowozin

Possible fix for assignProblem method in OsiVol?

comment:2 Changed 11 years ago by nowozin

I added a patch that should fix this problem.

The bug surfaces when OsiVolSolverInterface::colRimResize_ correctly allocates a larger bool array for the continuous/integer flag array and then subsequently tries to copy the old elements over to the new array. Because assignProblem does not initialize continuous_, hence the old continous_ in the call to CoinDisjointCopyN is a NULL pointer at the time of copying.

The patch allocates a properly sized bool array in continous_ when assignProblem is called.

I verified the crash goes away and the solver seems to work, but then figured COIN Vol is not applicable to my problem as it cannot handle ranged rows, so I can not test this patch thoroughly.

comment:3 Changed 11 years ago by lou

  • Component changed from OsiVol to OsiCpx

Patch applied in OsiVolSolverInterfaceIO.cpp, Osi trunk r1201. Allocation of continuous_ placed inside the block protected by if (maxNumcols_ > 0) . I've retargeted the ticket to OsiCpx? (presumably the problem remains there).

comment:4 Changed 10 years ago by stefan

I cannot reproduce the failure for OsiCpx. I took build.cpp from Osi/examples and replaced the loadProblem call by a assignProblem call, and it worked fine. (anyway, assignProblem just calls loadProblem)

Also adding an si->addCol afterwards did not result in a failure.

Can you give some more information on the failure you observe with OsiCpx? Like the gdb-backtrace from a debug build, or the output of a valgrind run? Or a simple example?

Thanks, Stefan

comment:5 Changed 7 weeks ago by stefan

  • Resolution set to migrated
  • Status changed from new to closed

This ticket has been migrated to GitHub and will be resolved there: https://github.com/coin-or/Osi/issues/51

Note: See TracTickets for help on using tickets.