-
Notifications
You must be signed in to change notification settings - Fork 270
Description
I am the author of the emsarray library. Back in July 2024 the CI for emsarray started segfaulting non-deterministically but very reliably. I recorded my investigation in csiro-coasts/emsarray#139. I was never able to make a minimal example that demonstrated this issue, however this issue was very repeatable when running the entire test suite.
I narrowed the issue down to the combination of this netCDF4~=1.7.0 library from PyPI, plus the dask library using the thread scheduler. This issue did not occur when installing netCDF 1.7.x from conda-forge, and it did not occur when using other schedulers with dask. I added a work around in CI of changing the dask scheduler and hoped this was a quirk of that netCDF4 1.7.0 PyPI release and it would disappear on the next release. I then promptly forgot about the issue.
I have occasionally recalled the issue over the past year and tested it again, and it continues to fail, including just now using the latest netCDF4 1.7.3 from PyPI, running on Python 3.14, using the latest dependencies for everything. The issue continues to resolve itself using netCDF4 from conda-forge, or by changing the dask scheduler.
I apologise for the size of this minimal example - an entire test suite for a library is larger than I'd hoped - but at least the steps to reproduce it are straight forward! I am running on Ubuntu Linux x64. I do not know whether this happens on Windows or Mac.
$ uname -a
Linux gonzo-hf 6.14.0-36-generic #36~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct 15 15:45:17 UTC 2 x86_64 x86_64 x86_64 GNU/LinuxTo make a broken environment using netcdf4 from pypi:
$ git clone https://github.com/csiro-coasts/emsarray.git
$ cd emsarray
$ conda env create --name emsarray-tests-pypi --no-default-packages --file ./continuous-integration/environment.yaml
$ conda activate emsarray-tests-pypi
$ conda install -c conda-forge python=3.14 pip
$ pip install -e .[testing]
$ pytest -vv --dask-scheduler threads -m 'not memory_usage'Example segfault output will be included in comments below (issues have a maximum character limit), although which exact test fails is non-deterministic so your results may vary anyway.
To make a working environment using netcdf4 from conda-forge:
$ git clone https://github.com/csiro-coasts/emsarray.git
$ cd emsarray
$ conda env create --name emsarray-tests-conda-forge --no-default-packages --file ./continuous-integration/environment.yaml
$ conda activate emsarray-tests-conda-forge
$ conda install -c conda-forge python=3.14 pip netcdf4==1.7.3
$ pip install -e .[testing]
$ pytest -vv --dask-scheduler threads -m 'not memory_usage'For completeness sake, the output of conda list and pip freeze from the above broken pypi environment are attached below, however this has been happening reliably with all netCDF 1.7.x releases on PyPI and all combinations of other dependencies over time
pip freeze
bokeh==3.8.1
Bottleneck==1.6.0
Cartopy==0.25.0
certifi==2025.11.12
cftime==1.6.5
cfunits==3.3.7
charset-normalizer==3.4.4
click==8.3.1
cloudpickle==3.1.2
contourpy==1.3.3
coverage==7.13.0
cycler==0.12.1
dask==2025.11.0
distributed==2025.11.0
-e git+https://github.com/csiro-coasts/emsarray.git@52b899d5ad43701adf0e3cfaba3936a15df22a5d#egg=emsarray
flake8==7.3.0
fonttools==4.61.0
freezegun==1.5.5
fsspec==2025.12.0
geojson==3.2.0
idna==3.11
iniconfig==2.3.0
isort==7.0.0
Jinja2==3.1.6
kiwisolver==1.4.9
librt==0.7.3
locket==1.0.0
lz4==4.4.5
MarkupSafe==3.0.3
matplotlib==3.10.8
mccabe==0.7.0
msgpack==1.1.2
mypy==1.19.0
mypy_extensions==1.1.0
narwhals==2.13.0
netCDF4==1.7.3
numpy==2.3.5
packaging==25.0
pandas==2.3.3
pandas-stubs==2.3.3.251201
partd==1.4.2
pathspec==0.12.1
pillow==12.0.0
platformdirs==4.5.1
pluggy==1.6.0
pooch==1.8.2
psutil==7.1.3
pyarrow==22.0.0
pycodestyle==2.14.0
pyflakes==3.4.0
Pygments==2.19.2
pykdtree==1.4.3
pyparsing==3.2.5
pyproj==3.7.2
pyshp==3.0.3
pytest==9.0.2
pytest-cov==7.0.0
pytest-mpl==0.18.0
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.3
requests==2.32.5
shapely==2.1.2
six==1.17.0
sortedcontainers==2.4.0
tblib==3.2.2
toolz==1.1.0
tornado==6.5.2
types-pytz==2025.2.0.20251108
typing_extensions==4.15.0
tzdata==2025.2
urllib3==2.6.1
xarray==2025.12.0
xyzservices==2025.11.0
zict==3.0.0
conda list
# packages in environment at /home/hea211/.local/share/miniconda3/envs/emsarray-tests-pypi:
#
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
bokeh 3.8.1 pypi_0 pypi
bottleneck 1.6.0 pypi_0 pypi
bzip2 1.0.8 h5eee18b_6
ca-certificates 2025.12.2 h06a4308_0
cartopy 0.25.0 pypi_0 pypi
certifi 2025.11.12 pypi_0 pypi
cftime 1.6.5 pypi_0 pypi
cfunits 3.3.7 pypi_0 pypi
charset-normalizer 3.4.4 pypi_0 pypi
click 8.3.1 pypi_0 pypi
cloudpickle 3.1.2 pypi_0 pypi
contourpy 1.3.3 pypi_0 pypi
coverage 7.13.0 pypi_0 pypi
cycler 0.12.1 pypi_0 pypi
dask 2025.11.0 pypi_0 pypi
distributed 2025.11.0 pypi_0 pypi
emsarray 0.10.0 pypi_0 pypi
flake8 7.3.0 pypi_0 pypi
fonttools 4.61.0 pypi_0 pypi
freezegun 1.5.5 pypi_0 pypi
fsspec 2025.12.0 pypi_0 pypi
geojson 3.2.0 pypi_0 pypi
geos 3.12.3 h06de43c_0 conda-forge
idna 3.11 pypi_0 pypi
iniconfig 2.3.0 pypi_0 pypi
isort 7.0.0 pypi_0 pypi
jinja2 3.1.6 pypi_0 pypi
kiwisolver 1.4.9 pypi_0 pypi
ld_impl_linux-64 2.44 h153f514_2
libexpat 2.7.3 hecca717_0 conda-forge
libffi 3.4.4 h6a678d5_1
libgcc 15.2.0 he0feb66_16 conda-forge
libgcc-ng 15.2.0 h69a702a_16 conda-forge
libgomp 15.2.0 he0feb66_16 conda-forge
libmpdec 4.0.0 h5eee18b_0
librt 0.7.3 pypi_0 pypi
libstdcxx 15.2.0 h934c35e_16 conda-forge
libstdcxx-ng 15.2.0 hdf11a46_16 conda-forge
libudunits2 2.2.28 h40f5838_3 conda-forge
libuuid 1.41.5 h5eee18b_0
libxcb 1.17.0 h9b100fa_0
libzlib 1.3.1 hb25bd0a_0
locket 1.0.0 pypi_0 pypi
lz4 4.4.5 pypi_0 pypi
lz4-c 1.9.4 h6a678d5_1
markupsafe 3.0.3 pypi_0 pypi
matplotlib 3.10.8 pypi_0 pypi
mccabe 0.7.0 pypi_0 pypi
msgpack 1.1.2 pypi_0 pypi
mypy 1.19.0 pypi_0 pypi
mypy-extensions 1.1.0 pypi_0 pypi
narwhals 2.13.0 pypi_0 pypi
ncurses 6.5 h7934f7d_0
netcdf4 1.7.3 pypi_0 pypi
numpy 2.3.5 pypi_0 pypi
openssl 3.0.18 hd6dcaed_0
packaging 25.0 pypi_0 pypi
pandas 2.3.3 pypi_0 pypi
pandas-stubs 2.3.3.251201 pypi_0 pypi
partd 1.4.2 pypi_0 pypi
pathspec 0.12.1 pypi_0 pypi
pillow 12.0.0 pypi_0 pypi
pip 25.3 pyh0d26453_0
platformdirs 4.5.1 pypi_0 pypi
pluggy 1.6.0 pypi_0 pypi
pooch 1.8.2 pypi_0 pypi
psutil 7.1.3 pypi_0 pypi
pthread-stubs 0.3 h0ce48e5_1
pyarrow 22.0.0 pypi_0 pypi
pycodestyle 2.14.0 pypi_0 pypi
pyflakes 3.4.0 pypi_0 pypi
pygments 2.19.2 pypi_0 pypi
pykdtree 1.4.3 pypi_0 pypi
pyparsing 3.2.5 pypi_0 pypi
pyproj 3.7.2 pypi_0 pypi
pyshp 3.0.3 pypi_0 pypi
pytest 9.0.2 pypi_0 pypi
pytest-cov 7.0.0 pypi_0 pypi
pytest-mpl 0.18.0 pypi_0 pypi
python 3.14.1 h90eec9f_101_cp314
python-dateutil 2.9.0.post0 pypi_0 pypi
python_abi 3.14 2_cp314
pytz 2025.2 pypi_0 pypi
pyyaml 6.0.3 pypi_0 pypi
readline 8.3 hc2a1206_0
requests 2.32.5 pypi_0 pypi
shapely 2.1.2 pypi_0 pypi
six 1.17.0 pypi_0 pypi
sortedcontainers 2.4.0 pypi_0 pypi
sqlite 3.51.0 h2a70700_0
tblib 3.2.2 pypi_0 pypi
tk 8.6.15 h54e0aa7_0
toolz 1.1.0 pypi_0 pypi
tornado 6.5.2 pypi_0 pypi
types-pytz 2025.2.0.20251108 pypi_0 pypi
typing-extensions 4.15.0 pypi_0 pypi
tzdata 2025.2 pypi_0 pypi
udunits2 2.2.28 h40f5838_3 conda-forge
urllib3 2.6.1 pypi_0 pypi
xarray 2025.12.0 pypi_0 pypi
xorg-libx11 1.8.12 h9b100fa_1
xorg-libxau 1.0.12 h9b100fa_0
xorg-libxdmcp 1.1.5 h9b100fa_0
xorg-xorgproto 2024.1 h5eee18b_1
xyzservices 2025.11.0 pypi_0 pypi
xz 5.6.4 h5eee18b_1
zict 3.0.0 pypi_0 pypi
zlib 1.3.1 hb25bd0a_0
zstd 1.5.7 h11fc155_0