$ pytest -vv --dask-scheduler threads
============ test session starts ============
platform linux -- Python 3.11.9, pytest-8.2.2, pluggy-1.5.0 -- /home/hea211/projects/emsarray/.conda/bin/python3.11
cachedir: .pytest_cache
Matplotlib: 3.9.0
Freetype: 2.6.1
rootdir: /home/hea211/projects/emsarray
configfile: pyproject.toml
testpaths: tests
plugins: mpl-0.17.0, cov-5.0.0
collected 365 items
...
tests/conventions/test_ugrid.py::test_make_and_apply_clip_mask Fatal Python error: Segmentation fault
Thread 0x00007f8c195fa700 (most recent call first):
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 113 in _getitem
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 1014 in explicit_indexing_adapter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 100 in __getitem__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 650 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 787 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 576 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 573 in __array__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/array/core.py", line 118 in getter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 127 in _execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 225 in execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in <listcomp>
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in batch_execute_tasks
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 58 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 83 in _worker
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 982 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1045 in _bootstrap_inner
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1002 in _bootstrap
Thread 0x00007f8c19dfb700 (most recent call first):
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 113 in _getitem
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 1014 in explicit_indexing_adapter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 100 in __getitem__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 650 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 787 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 576 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 573 in __array__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/array/core.py", line 118 in getter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 127 in _execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 225 in execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in <listcomp>
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in batch_execute_tasks
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 58 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 83 in _worker
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 982 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1045 in _bootstrap_inner
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1002 in _bootstrap
Thread 0x00007f8c1a5fc700 (most recent call first):
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 113 in _getitem
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 1014 in explicit_indexing_adapter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 100 in __getitem__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 650 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 787 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 576 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 573 in __array__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/array/core.py", line 118 in getter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 127 in _execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 225 in execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in <listcomp>
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in batch_execute_tasks
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 58 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 83 in _worker
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 982 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1045 in _bootstrap_inner
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1002 in _bootstrap
Thread 0x00007f8c1adfd700 (most recent call first):
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 113 in _getitem
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 1014 in explicit_indexing_adapter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 100 in __getitem__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 650 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/coding/variables.py", line 81 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 657 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 787 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 576 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 573 in __array__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/array/core.py", line 118 in getter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 127 in _execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 157 in get
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/optimization.py", line 1001 in __call__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 127 in _execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 127 in <genexpr>
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 127 in _execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 225 in execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in <listcomp>
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in batch_execute_tasks
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 58 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 83 in _worker
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 982 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1045 in _bootstrap_inner
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1002 in _bootstrap
Thread 0x00007f8c1b7fe700 (most recent call first):
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 113 in _getitem
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 1014 in explicit_indexing_adapter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/backends/netCDF4_.py", line 100 in __getitem__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 650 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 787 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 576 in get_duck_array
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/xarray/core/indexing.py", line 573 in __array__
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/array/core.py", line 118 in getter
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/core.py", line 127 in _execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 225 in execute_task
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in <listcomp>
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/dask/local.py", line 239 in batch_execute_tasks
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 58 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/concurrent/futures/thread.py", line 83 in _worker
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 982 in run
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1045 in _bootstrap_inner
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/threading.py", line 1002 in _bootstrap
Thread 0x00007f8c1bfff700 (most recent call first):
File "<frozen importlib._bootstrap>", line 330 in _handle_fromlist
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/pandas/core/arrays/datetimelike.py", line 1176 in _sub_datetimelike
File "/home/hea211/projects/emsarray/.conda/lib/python3.11/site-packages/pandas/core/arrays/datetimelike.py"Segmentation fault (core dumped)
When all dependencies are updated to their latest versions and installed via PyPI (#137) the test suite will regularly - but non-deterministically - segfault. If all the latest dependencies are installed via conda no segfault has been observed.
As a temporary work around, disabling dask multithreading seems to stop the segfaults. This is not an acceptable solution long term but will suffice to unblock other development work.
This ticket tracks the investigation so far.
To stop the segfaults, dask can be set to single threaded mode by running:
This is now enabled by default for test runs. To trigger the failures again, run the tests with
pytest --dask-scheduler=threadsTo set up a test environment clone this repository, make a conda environment, and install the dependencies from PyPI as follows:
$ git clone https://github.com/csiro-coasts/emsarray.git $ cd emsarray $ conda env create --name emsarray-tests --no-default-packages --file ./continuous-integration/environment.yaml $ conda activate emsarray-tests $ conda install python=3.12 pip $ pip install -e .[testing] $ pytest -vv --dask-scheduler threadsThe tests segfault regularly on two specific tests which subset UGrid datasets, however other subsetting tests have also failed. Python 3.10, 3.11, and 3.12 all exhibit this issue. These tests previously worked fine. The stack traces printed vary, but some examples follow:
tests/conventions/test_ugrid.py::test_make_and_apply_clip_mask
tests/conventions/test_ugrid.py::test_make_and_apply_clip_mask
tests/cli/commands/test_clip.py::test_clip