Describe the bug
I have a test that started segfaulting with v6 (SCIP 10), but the issue only occurs when running with pytest. The test writes the problem in LP format.
To Reproduce
I had to spend a bit of time to come up with the smallest example, so here we go.
Create a file repro_test.py with these contents:
from pyscipopt import Model
def test_abs():
model = Model()
x = model.addVar()
model.addCons(abs(x) >= 1)
model.setObjective(x, "minimize")
model.writeProblem("abs_example.lp") # segfaults
if __name__ == "__main__":
test_abs()
Then run pytest on it (here using uvx to have a fresh environment):
uvx --with pyscipopt==6.0.0 --with pytest pytest repro_test.py
This causes a segmentation fault:
repro_test.py Fatal Python error: Segmentation fault
Current thread 0x000079f2a721f740 [python] (most recent call first):
File "~/dev/cvxpy-translation/repro_test.py", line 10 in test_abs
With a debug build of SCIP (scipopt/scip@9e13056), I see:
python: ~/dev/scip/src/scip/expr.c:4267: SCIPexprAreQuadraticExprsVariables: Assertion `expr->quaddata != NULL' failed.
Fatal Python error: Aborted
Expected behavior
The code should work without segfaulting. It does work when any of these change:
- Without calling
writeProblem
- Without
abs
- Running
python instead of pytest on the file
- Using PySCIPOpt 5.7.1
This is probably caused by pytest modifying the environment in some way. The version of pytest I use does not change the outcome though, only the version of SCIP seems to matter.
System
- OS: Ubuntu
- Version: 6.0.0
- SCIP version: 10.0.0
- How did you install
pyscipopt? PyPI and from source
Describe the bug
I have a test that started segfaulting with v6 (SCIP 10), but the issue only occurs when running with
pytest. The test writes the problem in LP format.To Reproduce
I had to spend a bit of time to come up with the smallest example, so here we go.
Create a file
repro_test.pywith these contents:Then run
pyteston it (here usinguvxto have a fresh environment):This causes a segmentation fault:
With a debug build of SCIP (scipopt/scip@9e13056), I see:
Expected behavior
The code should work without segfaulting. It does work when any of these change:
writeProblemabspythoninstead ofpyteston the fileThis is probably caused by
pytestmodifying the environment in some way. The version ofpytestI use does not change the outcome though, only the version of SCIP seems to matter.System
pyscipopt?PyPIand from source