ornladios / ADIOS2

Next generation of ADIOS developed in the Exascale Computing Program
https://adios2.readthedocs.io/en/latest/index.html
Apache License 2.0
268 stars 125 forks source link

Catch previously closed file handle #2447

Open rmchurch opened 4 years ago

rmchurch commented 4 years ago

In Python, when attempting to close a previously closed file handle, it simply seg faults, instead of catching and returning an error. This results in losing the Python session and work built up till then.

Steps to reproduce

In [1]: import adios2 as ad

In [2]: fm = ad.open('xgc.mesh.bp','r')

In [3]: RZ = fm.read('/coordinates/values')

In [4]: fm.close()

In [5]: fm.close()
[1]    115484 segmentation fault (core dumped)  ipython

Expected behavior Catch whether a file handle is still valid, and if not and the user attempts to close(), return a ValueError: Not a file id instead

Desktop (please complete the following information):

williamfgc commented 4 years ago

@pnorbert @rmchurch this is my fault. The Python API is not entirely safe. A check for m_Stream is required in every operation of File. Hope this helps.