id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 1975845455,I_kwDOAMm_X851xQJP,8410,Segmentation fault 139 (SIGSEGV),39524075,closed,0,,,4,2023-11-03T10:14:03Z,2023-11-06T20:34:46Z,2023-11-06T20:34:45Z,NONE,,,,"### What happened? While opening a set of netCDF files in a for loop, using xr.open_dataset().load(), I get a segmentation error (nr. 139). Please see code example below: ``` for region in region_list: [some code to read data associated to each region...] region_pred = xr.open_dataset(io.BytesIO(data)).load() [other code working on region_pred...] ``` The error is shown in Linux/Mac after running my Python code, whereas Windows seems to be masking it. I was able to catch that on Windows by launching my code as: ``` python3 my_code.py && echo ok || echo KO ``` In this way, KO gets printed and the segmentation fault is now noticeable. I managed to fix the issue by using a second variable (called reg_pred) in addition to region_pred: ``` for region in region_list: [some code to read data associated to each region...] region_pred = xr.open_dataset(io.BytesIO(data)) reg_pred = region_pred.load() [other code working on reg_pred...] ``` ### What did you expect to happen? I don't know if the issue I described is something that the developers made on purpose. Personally, I think it is an issue and that's why I am reporting it. If it is not an issue, I would like to get a clarification in order to understand what am I missing. Thank you in advance. ### Minimal Complete Verifiable Example ```Python for region in region_list: with storage_client.open(region, ""rb"") as f: data = f.read() region_pred = xr.open_dataset(io.BytesIO(data)).load() # some code working on region_pred to compute weather indices... ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [ ] Complete example — the example is self-contained, including all data and the text of any traceback. - [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result. - [X] New issue — a search of GitHub Issues suggests this is not a duplicate. - [ ] Recent environment — the issue occurs with the latest version of xarray and its dependencies. ### Relevant log output _No response_ ### Anything else we need to know? _No response_ ### Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 141 Stepping 1, GenuineIntel byteorder: little LC_ALL: None LANG: it_IT.UTF-8 LOCALE: ('Italian_Italy', '1252') libhdf5: 1.14.0 libnetcdf: 4.9.2 xarray: 2023.8.0 pandas: 2.1.0 numpy: 1.26.0 scipy: 1.11.2 netCDF4: 1.6.4 pydap: None h5netcdf: 1.2.0 h5py: 3.9.0 Nio: None zarr: None cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None iris: None bottleneck: None dask: 2023.10.0 distributed: 2023.10.0 matplotlib: 3.8.0 cartopy: None seaborn: None numbagg: None fsspec: 2023.9.1 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 68.2.2 pip: 23.2.1 conda: None pytest: None mypy: None IPython: 8.15.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8410/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,not_planned,13221727,issue