Skip to content

Race condition crashes pytest suite locally sometimes #1757

Closed

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

  1. added
    bug
    testing
    scalability
    on Sep 14, 2026
  2. self-assigned this
    on Sep 14, 2026
  3. moved this from 📚 Backlog to 📝 To-Do in UXarray Developmenton Sep 14, 2026
  4. cmdupuis3 commented on Sep 14, 2026

    @cmdupuis3
    Collaborator

    Looking at it. I think the neighborhood filters are tough to work with due to some jankiness around how numba works with closures. I guess that's the danger of doing functional programming in an OO language, but it could just be a compiler error in numba.

  5. moved this from 📝 To-Do to 👀 In review in UXarray Developmenton Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugscalabilitytesting

Type

No type

Fields

Priority

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions