Skip to content

Race condition crashes pytest suite locally sometimes #1757

Description

@Sevans711

The pytest suite fails locally for me with SIGABRT sometimes, ever since #941 merged. It doesn't happen every time, but it does happen very often (sometimes it feels like it crashes 20% of the time, sometimes it feels like it crashes >90% of the time). When the crash occurs, it occurs inside test/core/test_dataarray.py, inside the first test which uses dask with the neighborhood guvectorize kernels (the test is named TestNeighborhood.test_dask_input_stays_lazy).

Some back-and-forth with Claude led me to believe this is likely a race condition related to numba/numba#9288. I also managed to get things down to a reasonably minimal reproducer. Run the following lines from a terminal window (I'm on macOS) with an active Python venv:

for i in $(seq 1 20); do
  python -c "
import faulthandler; faulthandler.enable()
import xarray as xr, uxarray as ux
vortex = ux.tutorial.open_dataset('outCSne30-vortex')
vortex.neighborhood(r=2.0).mean()
times = xr.DataArray([0,1,2,3,4,5], dims='time')
chunked = (vortex + 0*times).chunk({'time': 2, 'n_face': -1})
chunked.neighborhood(r=2.0).mean().compute()
print('a run completed successfully')
"
  code=$?
  echo "run $i: exit $code"
  [ $code -ne 0 ] && break
done

On my end, I am seeing crashes within a few runs, e.g. it will print something like:

a run completed successfully
run 1: exit 0
a run completed successfully
run 2: exit 0
a run completed successfully
run 3: exit 0
Numba workqueue threading layer is terminating: Concurrent access has been detected.
...  # more error message details
Fatal Python error: Aborted
...  # more error message details
run 4: exit 134

In case it matters, I set up my environments using uv. I checked that the example above causes crashes within a few runs on Python 3.11, 3.13, and 3.14. My macOS is Tahoe 26.6.2. It feels like it is failing more often since upgrading to Tahoe, but that might just be confirmation bias. Before upgrading OS I was able to run the pytest suite locally within a few tries. Today is the first time I tried to run the suite since upgrading, and it crashed every time across more than 5 attempts, which is why I looked into this further.

cc: @cmdupuis3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingscalabilityRelated to scalability & performance effortstestingTest Cases

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions