coin-or / coin-or/CyLP

Segfault when running a test with custom pivot

Open
#105 8 comments 2 reactions 0 assignees View on GitHub
Dominant language
JetBrains MPS
Stars
192
Forks
70
PR merge metrics
No merged PRs in 30d

Description

On current master (which has the fix for the memory leak: https://github.com/coin-or/CyLP/commit/72d66b58af5ac0cee25d94b63115c6f65e3cff8b ) I'm getting a segfault when running standard cylp tests (from the file `cylp/py/test_PySolve.py`).

I've converted that test to a simple repro:

```python
from cylp.cy import CyClpSimplex
from cylp.py.pivots import DantzigPivot

s = CyClpSimplex()
s.readMps('p0033.mps') # or adlittle.mps
pivot = DantzigPivot(s)
s.setPivotMethod(pivot)
s.primal()
print(s.objectiveValue)
```

File `p0033.mps` comes from `cylp/input` directory.

I'm getting the following output:

```
$ python repro.py
Coin0001I At line 15 NAME P0033
Coin0001I At line 16 ROWS
Coin0001I At line 34 COLUMNS
Coin0001I At line 109 RHS
Coin0001I At line 118 BOUNDS
Coin0001I At line 152 ENDATA
Coin0002I Problem P0033 has 16 rows, 33 columns and 98 elements
Clp0027I Model was imported from p0033.mps in 0.000493 seconds
Clp0006I 0 Obj 0 Primal inf 18.492499 (10) Dual inf 5.5987499e+11 (32)
Segmentation fault (core dumped)
```

I could reproduce this after building and installing `cylp` using `pip install .` on both ArchLinux (with system-wide `coin-or-cbc` package of version `2.10.5-4`) and WSL and also when installing using `conda`.

Looking at core dump I can see that it failed in `ClpSimplexPrimal::statusOfProblemInPrimal` function (due to null pointer dereferencing):

```
#0 0x00007fabd5176671 in ClpSimplexPrimal::statusOfProblemInPrimal(int&, int, ClpSimplexProgress*, bool, int, ClpSimplex*) () from /usr/lib/libClp.so.1
#1 0x00007fabd517aba9 in ClpSimplexPrimal::primal(int, int) () from /usr/lib/libClp.so.1
#2 0x00007fabd54b5b76 in IClpSimplex::primal (this=, ifValuesPass=0, startFinishOptions=0) at cylp/cpp/IClpSimplex.cpp:1327
#3 0x00007fabd54ef95a in __pyx_pf_4cylp_2cy_12CyClpSimplex_12CyClpSimplex_118primal (__pyx_v_presolve=, __pyx_v_startFinishOptions=,
__pyx_v_ifValuesPass=, __pyx_v_self=0x7fabcaf89820) at cylp/cy/CyClpSimplex.cpp:25122
#4 __pyx_pw_4cylp_2cy_12CyClpSimplex_12CyClpSimplex_119primal (__pyx_v_self=0x7fabcaf89820, __pyx_args=, __pyx_kwds=)
at cylp/cy/CyClpSimplex.cpp:24993
```

This problem does *not* happen if I do any of the following:

1. Checkout and build `cylp` version before memory leak fixes, i.e. this commit: https://github.com/coin-or/CyLP/commit/875d5d5ad07cd1b4b53d3715e4aa29164a025e9f
2. Do not set pivot method in the repro.
3. Use `initialSolve` instead of `primal` in the repro.

I tried to understand what exactly is causing the null pointer, but the function `ClpSimplexPrimal::statusOfProblemInPrimal` is around 900 lines long, it's not easy to understand and debug.

In general, it looks like this memory leak fix (as described in https://github.com/coin-or/CyLP/issues/102 ) is causing subtle memory issues, so we are either getting the segfault or the memory leaks.

Could you please take a look at this?

Thank you!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.