resdata icon indicating copy to clipboard operation
resdata copied to clipboard

Segfault when calling __repr__ on an EclFile instance with invalid filepath

Open lars-petter-hauge opened this issue 4 years ago • 0 comments

Issue:

Pytest run __repr__ on an instance as part of its runtime - which typically IDE's also will do for you. __repr__ in EclFile uses getFilename which segfaults if the file path does not exist. This occurs even though an IOerror is raised as part of handling the initilization of EclFile.

https://github.com/equinor/ecl/blob/55625950b10f048e5e462bf4c7ab779d6b5b5c76/python/ecl/eclfile/ecl_file.py#L183

How to recreate:

Create a test_ecl.py with the following content

from ecl.eclfile import EclFile

def test_seg_fault_ecl():
    ecl_sum = EclFile("non_existing_file")

and run: pytest test_ecl.py

This issue is closely related to https://github.com/equinor/ecl/pull/758, where the bug was discovered when __repr__ was called on a EclSum instance.

lars-petter-hauge avatar Dec 21 '20 09:12 lars-petter-hauge