Segmentation fault in get_spatial_hash with delaunay grid from points
Version
v2025.3.1.dev11+g4257f71
How did you install UXarray?
Pip
What happened?
I received a segmentation fault error when creating the spatial hash
uxarray version : 2025.3.1.dev11+g4257f71
Segmentation fault (core dumped)
What did you expect to happen?
No segmentation fault
Can you provide a MCVE to repoduce the bug?
#!/usr/bin/env python
import numpy as np
import uxarray as ux
print(f"uxarray version : {ux.__version__}")
lon, lat = np.meshgrid(np.linspace(0, 1, 10, dtype=np.float32),
np.linspace(0, 1, 10, dtype=np.float32))
points = (lon.flatten(), lat.flatten())
# Create the grid
uxgrid = ux.Grid.from_points(points, method="regional_delaunay")
uxgrid.get_spatial_hash()
Backtrace from gdb..
(gdb) bt
#0 0x000000000000002b in ?? ()
#1 0x0000155553637a76 in execute_ufunc_loop () from /home/joe/miniconda3/envs/parcels/lib/python3.13/site-packages/numpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so
#2 0x0000155553641323 in ufunc_generic_fastcall () from /home/joe/miniconda3/envs/parcels/lib/python3.13/site-packages/numpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so
#3 0x000055555572efe4 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=2, args=0x7fffffffc570, callable=0x155553300840, tstate=0x555555ab6650 <_PyRuntime+283024>)
at /usr/local/src/conda/python-3.13.2/Include/internal/pycore_call.h:168
#4 object_vacall (tstate=<optimized out>, base=0x0, callable=0x155553300840, vargs=0x7fffffffc5e0) at /usr/local/src/conda/python-3.13.2/Objects/call.c:819
#5 0x00005555557cafc8 in PyObject_CallFunctionObjArgs (callable=<optimized out>) at /usr/local/src/conda/python-3.13.2/Objects/call.c:926
#6 0x000015555350e7dd in array_richcompare () from /home/joe/miniconda3/envs/parcels/lib/python3.13/site-packages/numpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so
#7 0x000055555573e128 in do_richcompare (op=2, w=0x1555310bc7b0, v=0x1554a55f5dd0, tstate=0x555555ab6650 <_PyRuntime+283024>) at /usr/local/src/conda/python-3.13.2/Objects/object.c:1010
#8 PyObject_RichCompare (v=0x1554a55f5dd0, w=0x1555310bc7b0, op=2) at /usr/local/src/conda/python-3.13.2/Objects/object.c:1059
#9 0x00005555555f3e42 in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at /usr/local/src/conda/python-3.13.2/Python/generated_cases.c.h:2210
#10 0x000055555573ed74 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=9223372036854775809, args=0x7fffffffc978, callable=0x1554a5bf1940, tstate=0x555555ab6650 <_PyRuntime+283024>)
at /usr/local/src/conda/python-3.13.2/Include/internal/pycore_call.h:168
#11 PyObject_CallOneArg (func=0x1554a5bf1940, arg=<optimized out>) at /usr/local/src/conda/python-3.13.2/Objects/call.c:395
#12 0x000055555572dd8c in _PyObject_GenericGetAttrWithDict (obj=0x1554a5b99940, name=0x15552b459440, dict=0x0, suppress=0) at /usr/local/src/conda/python-3.13.2/Include/object.h:336
#13 0x000055555570bb31 in PyObject_GenericGetAttr (name=0x15552b459440, obj=0x1554a5b99940) at /usr/local/src/conda/python-3.13.2/Objects/object.c:1747
#14 PyObject_GetAttr (v=0x1554a5b99940, name=0x15552b459440) at /usr/local/src/conda/python-3.13.2/Objects/object.c:1261
--Type <RET> for more, q to quit, c to continue without paging--
#15 0x00005555555f0bdb in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at /usr/local/src/conda/python-3.13.2/Python/generated_cases.c.h:3766
#16 0x000055555573ed74 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=9223372036854775809, args=0x7fffffffcc38, callable=0x1554a5bf1a80, tstate=0x555555ab6650 <_PyRuntime+283024>)
at /usr/local/src/conda/python-3.13.2/Include/internal/pycore_call.h:168
#17 PyObject_CallOneArg (func=0x1554a5bf1a80, arg=<optimized out>) at /usr/local/src/conda/python-3.13.2/Objects/call.c:395
#18 0x000055555572dd8c in _PyObject_GenericGetAttrWithDict (obj=0x1554a5b99940, name=0x15552b29e9f0, dict=0x0, suppress=0) at /usr/local/src/conda/python-3.13.2/Include/object.h:336
#19 0x000055555570bb31 in PyObject_GenericGetAttr (name=0x15552b29e9f0, obj=0x1554a5b99940) at /usr/local/src/conda/python-3.13.2/Objects/object.c:1747
#20 PyObject_GetAttr (v=0x1554a5b99940, name=0x15552b29e9f0) at /usr/local/src/conda/python-3.13.2/Objects/object.c:1261
#21 0x00005555555f0bdb in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at /usr/local/src/conda/python-3.13.2/Python/generated_cases.c.h:3766
#22 0x000055555574100b in _PyEval_EvalFrame (throwflag=0, frame=0x155555507130, tstate=0x555555ab6650 <_PyRuntime+283024>) at /usr/local/src/conda/python-3.13.2/Include/internal/pycore_ceval.h:119
#23 _PyEval_Vector (kwnames=0x0, argcount=3, args=0x7fffffffcf30, locals=0x0, func=0x1554ad81cd60, tstate=0x555555ab6650 <_PyRuntime+283024>) at /usr/local/src/conda/python-3.13.2/Python/ceval.c:1812
#24 _PyFunction_Vectorcall (kwnames=0x0, nargsf=<optimized out>, stack=0x7fffffffcf30, func=0x1554ad81cd60) at /usr/local/src/conda/python-3.13.2/Objects/call.c:413
#25 _PyObject_VectorcallDictTstate (kwargs=<optimized out>, nargsf=<optimized out>, args=<optimized out>, callable=0x1554ad81cd60, tstate=0x555555ab6650 <_PyRuntime+283024>)
at /usr/local/src/conda/python-3.13.2/Objects/call.c:135
#26 _PyObject_Call_Prepend (kwargs=<optimized out>, args=<optimized out>, obj=<optimized out>, callable=0x1554ad81cd60, tstate=0x555555ab6650 <_PyRuntime+283024>)
at /usr/local/src/conda/python-3.13.2/Objects/call.c:504
#27 slot_tp_init (self=<optimized out>, args=<optimized out>, kwds=<optimized out>) at /usr/local/src/conda/python-3.13.2/Objects/typeobject.c:9785
#28 0x00005555557084ef in type_call (kwds=0x0, args=0x1554a5ca1c00, self=0x5555595a78b0) at /usr/local/src/conda/python-3.13.2/Objects/typeobject.c:1999
#29 _PyObject_MakeTpCall (tstate=0x555555ab6650 <_PyRuntime+283024>, callable=0x5555595a78b0, args=<optimized out>, nargs=<optimized out>, keywords=0x0)
at /usr/local/src/conda/python-3.13.2/Objects/call.c:242
#30 0x00005555555f2a99 in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at /usr/local/src/conda/python-3.13.2/Python/generated_cases.c.h:813
#31 0x00005555557c9881 in PyEval_EvalCode (co=0x555555be1db0, globals=<optimized out>, locals=0x155553f34380) at /usr/local/src/conda/python-3.13.2/Python/ceval.c:602
#32 0x00005555557ee6f0 in run_eval_code_obj (tstate=0x555555ab6650 <_PyRuntime+283024>, co=0x555555be1db0, globals=0x155553f34380, locals=0x155553f34380)
at /usr/local/src/conda/python-3.13.2/Python/pythonrun.c:1337
#33 0x00005555557e962c in run_mod (mod=<optimized out>, filename=<optimized out>, globals=0x155553f34380, locals=0x155553f34380, flags=<optimized out>, arena=<optimized out>, interactive_src=0x0,
generate_new_source=0) at /usr/local/src/conda/python-3.13.2/Python/pythonrun.c:1422
#34 0x0000555555808dd6 in pyrun_file (fp=0x555555b47550, filename=0x155553f6b0f0, start=<optimized out>, globals=0x155553f34380, locals=0x155553f34380, closeit=1, flags=0x7fffffffd418)
at /usr/local/src/conda/python-3.13.2/Python/pythonrun.c:1255
#35 0x0000555555807ab8 in _PyRun_SimpleFileObject (fp=0x555555b47550, filename=0x155553f6b0f0, closeit=1, flags=0x7fffffffd418) at /usr/local/src/conda/python-3.13.2/Python/pythonrun.c:490
#36 0x000055555580773c in _PyRun_AnyFileObject (fp=0x555555b47550, filename=0x155553f6b0f0, closeit=1, flags=0x7fffffffd418) at /usr/local/src/conda/python-3.13.2/Python/pythonrun.c:77
#37 0x000055555580077e in pymain_run_file_obj (skip_source_first_line=0, filename=0x155553f6b0f0, program_name=0x155553f6a550) at /usr/local/src/conda/python-3.13.2/Modules/main.c:410
#38 pymain_run_file (config=0x555555a88d48 <_PyRuntime+96392>) at /usr/local/src/conda/python-3.13.2/Modules/main.c:429
#39 pymain_run_python (exitcode=0x7fffffffd40c) at /usr/local/src/conda/python-3.13.2/Modules/main.c:697
#40 Py_RunMain () at /usr/local/src/conda/python-3.13.2/Modules/main.c:776
#41 0x00005555557b9547 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at /usr/local/src/conda/python-3.13.2/Modules/main.c:830
#42 0x0000155555029d90 in __libc_start_call_main (main=main@entry=0x5555557b9490 <main>, argc=argc@entry=2, argv=argv@entry=0x7fffffffd668) at ../sysdeps/nptl/libc_start_call_main.h:58
#43 0x0000155555029e40 in __libc_start_main_impl (main=0x5555557b9490 <main>, argc=2, argv=0x7fffffffd668, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffd658) at ../csu/libc-start.c:392
--Type <RET> for more, q to quit, c to continue without paging--
#44 0x00005555557b893e in _start ()
Thank you for reporting this issue and for providing a detailed minimal example and a gdb backtrace—that’s extremely helpful!
From the backtrace, it looks like the segmentation fault is occurring deep within NumPy’s C extensions (_multiarray_umath) during a ufunc operation, possibly triggered by a comparison or array operation when building the spatial hash.
How about trying Python 3.11/3.12 ? Also, try np float64
Hey @rajeeja , Thanks for the triaging advice here
- Python 3.13 segfaults with both
np.float32andnp.float64 - Python 3.11 works fine with both precisions
@fluidnumerics-joe I am unable to reproduce your bug locally, we do test with 3.13 on all OS's https://github.com/UXARRAY/uxarray/actions/runs/14716006159/job/41299420871?pr=1228 and others
Hmm.. not sure what to make of that. I'm still able to reproduce today.
Must be something with version incompatibility, our testcase doesn't pick it up, and my local with python 3.13 also seems to pass the test you pointed out. What is your system configuration?
Rajeev
On Wed, Apr 30, 2025 at 4:09 PM Joe Schoonover @.***> wrote:
fluidnumerics-joe left a comment (UXARRAY/uxarray#1212) https://github.com/UXARRAY/uxarray/issues/1212#issuecomment-2843155721
Hmm.. not sure what to make of that. I'm still able to reproduce today.
— Reply to this email directly, view it on GitHub https://github.com/UXARRAY/uxarray/issues/1212#issuecomment-2843155721, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALF6AUR54DSAY2A6SEPDQL24EUXFAVCNFSM6AAAAAB3JA3HI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNBTGE2TKNZSGE . You are receiving this because you were mentioned.Message ID: @.***>
Must be something with version incompatibility, our testcase doesn't pick it up, and my local with python 3.13 also seems to pass the test you pointed out. What is your system configuration? …
(uxarray_dev) (base) ➜ cp_uxarray git:(main) ✗ ipython
Python 3.13.2 | packaged by Anaconda, Inc. | (main, Feb 6 2025, 12:55:35) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.1.0 -- An enhanced Interactive Python. Type '?' for help.
Tip: IPython 9.0+ has hooks to integrate AI/LLM completions.
In [1]: import numpy as np
...: import uxarray as ux
...:
...: print(f"uxarray version : {ux.__version__}")
...:
...: lon, lat = np.meshgrid(np.linspace(0, 1, 10, dtype=np.float32),
...: np.linspace(0, 1, 10, dtype=np.float32))
...: points = (lon.flatten(), lat.flatten())
...:
...: # Create the grid
...: uxgrid = ux.Grid.from_points(points, method="regional_delaunay")
...: uxgrid.get_spatial_hash()
...:
uxarray version : 2025.4.1.dev1+ga13ddca5
/Users/mbook/cp_uxarray/uxarray/grid/grid.py:1432: RuntimeWarning: Necessary functions for computing the bounds of each face are not yet compiled with Numba. This initial execution will be significantly longer.
warn(
Out[1]: <uxarray.grid.neighbors.SpatialHash at 0x3241c6510>
In [2]: !python --version
Python 3.13.2