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 1285001323,I_kwDOAMm_X85Ml5Br,6728,open_dataset segfaults when opening hdf5 with array of strings,352673,closed,0,,,8,2022-06-26T18:48:04Z,2022-06-27T16:10:21Z,2022-06-27T16:10:20Z,NONE,,,,"### What happened? An attempt to open *non* netCDF4 hdf5 file with `xarray.open_dataset` results in a segmentation fault. ### What did you expect to happen? Code execute and not die a horrible death. ### Minimal Complete Verifiable Example ```Python import h5py import numpy as np from xarray import open_dataset filename = ""foobar.h5"" with h5py.File(filename, ""w"") as fp: fp[""test""] = np.array([""foo"", ""bar"", ""baz""], dtype=""|S3"") with open_dataset(filename, engine=""netcdf4"") as ds: print(""yay"") ``` ### MVCE confirmation - [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray. - [X] Complete example — the example is self-contained, including all data and the text of any traceback. - [X] 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. ### Relevant log output ```Python $ python3 -Wd -X faulthandler bug.py Fatal Python error: Segmentation fault Current thread 0x00007f2283947740 (most recent call first): File ""/home/xarth/codes/xarthisius/xarray/xarray/backends/netCDF4_.py"", line 106 in _getitem File ""/home/xarth/codes/xarthisius/xarray/xarray/core/indexing.py"", line 816 in explicit_indexing_adapter File ""/home/xarth/codes/xarthisius/xarray/xarray/backends/netCDF4_.py"", line 93 in __getitem__ File ""/home/xarth/codes/xarthisius/xarray/xarray/core/indexing.py"", line 527 in __array__ File ""/home/xarth/codes/xarthisius/xarray/xarray/core/variable.py"", line 250 in _as_array_or_item File ""/home/xarth/codes/xarthisius/xarray/xarray/core/variable.py"", line 510 in values File ""/home/xarth/codes/xarthisius/xarray/xarray/core/variable.py"", line 337 in data File ""/home/xarth/codes/xarthisius/xarray/xarray/core/common.py"", line 1866 in contains_cftime_datetimes File ""/home/xarth/codes/xarthisius/xarray/xarray/core/common.py"", line 1875 in _contains_datetime_like_objects File ""/home/xarth/codes/xarthisius/xarray/xarray/conventions.py"", line 345 in decode_cf_variable File ""/home/xarth/codes/xarthisius/xarray/xarray/conventions.py"", line 521 in decode_cf_variables File ""/home/xarth/codes/xarthisius/xarray/xarray/backends/store.py"", line 27 in open_dataset File ""/home/xarth/codes/xarthisius/xarray/xarray/backends/netCDF4_.py"", line 567 in open_dataset File ""/home/xarth/codes/xarthisius/xarray/xarray/backends/api.py"", line 495 in open_dataset File ""/home/xarth/codes/xarthisius/yt/bug.py"", line 10 in Segmentation fault (core dumped) ``` ### Anything else we need to know? This regression was introduced in #6489 ### Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.9.5 (default, Nov 23 2021, 15:27:38) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 5.4.0-121-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: en_US.utf8 LANG: en_US.utf8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.2 libnetcdf: 4.9.0 xarray: 2022.3.1.dev60+g5f01c115 pandas: 1.4.3 numpy: 1.23.0 scipy: 1.9.0rc1 netCDF4: 1.6.0 pydap: None h5netcdf: None h5py: 3.7.0 Nio: None zarr: None cftime: 1.6.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 2022.6.1 distributed: None matplotlib: 3.5.2 cartopy: None seaborn: None numbagg: None fsspec: 2022.5.0 cupy: None pint: None sparse: None setuptools: 44.0.0 pip: 20.0.2 conda: None pytest: 7.1.2 IPython: 8.4.0 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6728/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue