Skip to content

open_dataset crash with long filenames #2187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sbiner opened this issue May 25, 2018 · 2 comments
Closed

open_dataset crash with long filenames #2187

sbiner opened this issue May 25, 2018 · 2 comments

Comments

@sbiner
Copy link

sbiner commented May 25, 2018

Code Sample

import xarray as xr
import shutil
import numpy as np

# create netcdf file
data = np.random.rand(4, 3)
foo = xr.DataArray(data)
foo.to_netcdf('test.nc')

f_nc = 'a.nc'
shutil.copy('test.nc', f_nc)
while 1:
    print '{:05n} characteres'.format(len(f_nc))
    ds1 = xr.open_dataset(f_nc)
    ds1.close()
    nf_nc = 'a' + f_nc
    shutil.move(f_nc, nf_nc)
    f_nc = nf_nc

    if len(f_nc) == 100:
        break

Problem description

On my linux machine (CentOS) this code crashes (memory corrruption) when the filename length hits 32 characters.

On my OSX machine it is fine until 255 character and stops with an IOError

Output of xr.show_versions()

# Paste the output here xr.show_versions() here

INSTALLED VERSIONS

commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Linux
OS-release: 3.10.0-514.2.2.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: None.None

xarray: 0.10.4
pandas: 0.22.0
numpy: 1.14.2
scipy: 0.16.1
netCDF4: 1.2.2
h5netcdf: None
h5py: 2.5.0
Nio: None
zarr: None
bottleneck: None
cyordereddict: None
dask: 0.17.2
distributed: None
matplotlib: 1.5.0
cartopy: 0.13.1
seaborn: 0.8.1
setuptools: 19.2
pip: 10.0.1
conda: None
pytest: None
IPython: 4.0.1
sphinx: 1.7.2

@shoyer
Copy link
Member

shoyer commented May 26, 2018

Try updating netCDF4-python to a newer version if possible.

This looks similar to a previously reported issue when using old versions of netCDF4-Python with 88 character filenames in #1745

@sbiner
Copy link
Author

sbiner commented May 29, 2018

Hi @shoyer

updating netCDF4 to 1.4.0 works. I now obtain a proper IOError message. Help appreciated. Thanks.

I intent to close the issue, hope it's proper "etiquette".

@sbiner sbiner closed this as completed May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants