Skip to content

Bug: Segmentation fault when trying to read Value of unsolved variable in ipopt #91

@staadecker

Description

@staadecker

Hi Yue,

I hope you're doing well. This is not an urgent bug, but I thought I'd report it anyways in case it's helpful to be aware of.

The following code, instead of returning an exception, causes the entire program to crash.

from pyoptinterface.ipopt import Model
import pyoptinterface as poi

m = Model()
x = m.add_variable()
m.get_variable_attribute(x, poi.VariableAttribute.Value)

It seems that pyoptinterface triggers a segmentation fault when trying to read the Value attribute prior to optimization when using ipopt:

Windows fatal exception: access violation

Current thread 0x000027e4 (most recent call first):
  File "C:\Users\staadeck\Software\pyoframe\.venv\Lib\site-packages\pyoptinterface\_src\ipopt.py", line 84 in <lambda>
  File "C:\Users\staadeck\Software\pyoframe\.venv\Lib\site-packages\pyoptinterface\_src\solver_common.py", line 74 in _direct_get_entity_attribute

As a workaround, I'm explicitly checking that the model was solved before letting users access the Value attribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions