Skip to content

Segmentation fault when writing non-linear model to LP #1138

@jonathanberthias

Description

@jonathanberthias

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:

  1. Without calling writeProblem
  2. Without abs
  3. Running python instead of pytest on the file
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions