yt icon indicating copy to clipboard operation
yt copied to clipboard

Segfault when using surface container + oct-based dataset.

Open cphyc opened this issue 6 months ago • 0 comments

The following script leads to a segfault:

import yt

ds = yt.load_sample("output_00080")
ad = ds.all_data()
surf = ds.surface(ad, ("gas", "density"), (1, "mp/cm**3"))

surf["index", "x"]

Note that the segfault is only triggered when trying to access generated index fields (like dx, x, spherical_radius, etc.).

Backtrace (through GDB) points to an issue is the way octrees are being indexed.
#0  0x00007fffcee02260 in __pyx_f_2yt_8geometry_13oct_container_root_node_compare () from /home/cphyc/Documents/prog/yt/yt/geometry/oct_container.cpython-313-x86_64-linux-gnu.so
#1  0x00007ffff7da70a4 in __GI___tfind (key=0x7fffffffbc00, vrootp=<optimized out>, compar=0x7fffcee02260 <__pyx_f_2yt_8geometry_13oct_container_root_node_compare>) at tsearch.c:387
#2  0x00007fffcee030ab in __pyx_f_2yt_8geometry_13oct_container_21SparseOctreeContainer_get_root ()
   from /home/cphyc/Documents/prog/yt/yt/geometry/oct_container.cpython-313-x86_64-linux-gnu.so
#3  0x00007fffcee03230 in __pyx_f_2yt_8geometry_13oct_container_15OctreeContainer_get () from /home/cphyc/Documents/prog/yt/yt/geometry/oct_container.cpython-313-x86_64-linux-gnu.so
#4  0x00007fffceeaf20b in __pyx_f_2yt_8geometry_12oct_visitors_20BaseNeighbourVisitor_set_neighbour_info ()
   from /home/cphyc/Documents/prog/yt/yt/geometry/oct_visitors.cpython-313-x86_64-linux-gnu.so
#5  0x00007fffceeb7dc5 in __pyx_f_2yt_8geometry_12oct_visitors_25NeighbourCellIndexVisitor_visit ()
   from /home/cphyc/Documents/prog/yt/yt/geometry/oct_visitors.cpython-313-x86_64-linux-gnu.so
#6  0x00007fffcef4595f in __pyx_f_2yt_8geometry_18selection_routines_14SelectorObject_visit_oct_cells ()
   from /home/cphyc/Documents/prog/yt/yt/geometry/selection_routines.cpython-313-x86_64-linux-gnu.so
#7  0x00007fffcef4541a in __pyx_f_2yt_8geometry_18selection_routines_14SelectorObject_recursively_visit_octs ()
   from /home/cphyc/Documents/prog/yt/yt/geometry/selection_routines.cpython-313-x86_64-linux-gnu.so
#8  0x00007fffcee0fdb5 in __pyx_f_2yt_8geometry_13oct_container_21SparseOctreeContainer_visit_all_octs ()
   from /home/cphyc/Documents/prog/yt/yt/geometry/oct_container.cpython-313-x86_64-linux-gnu.so
#9  0x00007fffcee437d1 in __pyx_pf_2yt_8geometry_13oct_container_15OctreeContainer_44fill_octcellindex_neighbours ()
   from /home/cphyc/Documents/prog/yt/yt/geometry/oct_container.cpython-313-x86_64-linux-gnu.so
#10 0x00007fffcee4506e in __pyx_pw_2yt_8geometry_13oct_container_15OctreeContainer_45fill_octcellindex_neighbours ()
   from /home/cphyc/Documents/prog/yt/yt/geometry/oct_container.cpython-313-x86_64-linux-gnu.so
#11 0x00005555557060fe in _PyObject_VectorcallTstate (kwnames=<optimized out>, nargsf=<optimized out>, args=<optimized out>, callable=0x7fffcf058e80, 
    tstate=0x555555ab55b0 <_PyRuntime+283024>) at /usr/local/src/conda/python-3.13.5/Include/internal/pycore_call.h:168
#12 PyObject_Vectorcall (callable=0x7fffcf058e80, args=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at /usr/local/src/conda/python-3.13.5/Objects/call.c:327
#13 0x00005555555f2e73 in _PyEval_EvalFrameDefault (tstate=0x555555ab55b0 <_PyRuntime+283024>, frame=<optimized out>, throwflag=<optimized out>)
    at /usr/local/src/conda/python-3.13.5/Python/generated_cases.c.h:813
#14 0x00005555557376c4 in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=9223372036854775809, args=0x7fffffffc7f8, callable=0x7fffc8c5b4c0, tstate=0x555555ab55b0 <_PyRuntime+283024>)
    at /usr/local/src/conda/python-3.13.5/Include/internal/pycore_call.h:168
#15 PyObject_CallOneArg (func=0x7fffc8c5b4c0, arg=<optimized out>) at /usr/local/src/conda/python-3.13.5/Objects/call.c:395
#16 0x000055555572442d in _PyObject_GenericGetAttrWithDict (obj=0x7fffc5f87950, name=0x7fffcffb5bf0, dict=0x0, suppress=0) at /usr/local/src/conda/python-3.13.5/Include/object.h:336
#17 0x00005555557061a1 in PyObject_GenericGetAttr (name=0x7fffcffb5bf0, obj=0x7fffc5f87950) at /usr/local/src/conda/python-3.13.5/Objects/object.c:1751
#18 PyObject_GetAttr (v=v@entry=0x7fffc5f87950, name=0x7fffcffb5bf0) at /usr/local/src/conda/python-3.13.5/Objects/object.c:1261
#19 0x00005555555f0905 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555ab55b0 <_PyRuntime+283024>, frame=<optimized out>, throwflag=throwflag@entry=0)
    at /usr/local/src/conda/python-3.13.5/Python/generated_cases.c.h:3770
#20 0x00005555557c7463 in _PyEval_EvalFrame (throwflag=0, frame=<optimized out>, tstate=0x555555ab55b0 <_PyRuntime+283024>)
    at /usr/local/src/conda/python-3.13.5/Include/internal/pycore_ceval.h:119
#21 _PyEval_Vector (kwnames=0x0, argcount=2, args=<optimized out>, locals=0x0, func=0x7fffcf07a2a0, tstate=0x555555ab55b0 <_PyRuntime+283024>)
    at /usr/local/src/conda/python-3.13.5/Python/ceval.c:1816
#22 _PyFunction_Vectorcall (kwnames=0x0, nargsf=<optimized out>, stack=<optimized out>, func=0x7fffcf07a2a0) at /usr/local/src/conda/python-3.13.5/Objects/call.c:413
#23 _PyObject_VectorcallDictTstate (tstate=0x555555ab55b0 <_PyRuntime+283024>, callable=0x7fffcf07a2a0, args=<optimized out>, nargsf=<optimized out>, kwargs=<optimized out>)
    at /usr/local/src/conda/python-3.13.5/Objects/call.c:135
#24 0x0000555555815d4a in _PyObject_Call_Prepend (kwargs=0x0, args=0x7fffc57c2740, obj=<optimized out>, callable=0x7fffcf07a2a0, tstate=0x555555ab55b0 <_PyRuntime+283024>)
    at /usr/local/src/conda/python-3.13.5/Objects/call.c:504
#25 slot_tp_call (self=<optimized out>, args=0x7fffc57c2740, kwds=0x0) at /usr/local/src/conda/python-3.13.5/Objects/typeobject.c:9565
#26 0x000055555570407c in _PyObject_MakeTpCall (tstate=0x555555ab55b0 <_PyRuntime+283024>, callable=0x7fffc5f2ab30, args=0x7ffff7f90980, nargs=1, keywords=0x0)
    at /usr/local/src/conda/python-3.13.5/Objects/call.c:242
#27 0x00005555555f9468 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555ab55b0 <_PyRuntime+283024>, frame=<optimized out>, frame@entry=0x7ffff7f90090, throwflag=throwflag@entry=0)
    at /usr/local/src/conda/python-3.13.5/Python/generated_cases.c.h:1843
#28 0x000055555577a4cb in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7f90090, tstate=0x555555ab55b0 <_PyRuntime+283024>)
    at /usr/local/src/conda/python-3.13.5/Include/internal/pycore_ceval.h:119
#29 _PyEval_Vector (kwnames=0x0, argcount=<optimized out>, args=0x7fffffffcdf0, locals=0x0, func=0x7fffceb98680, tstate=0x555555ab55b0 <_PyRuntime+283024>)
    at /usr/local/src/conda/python-3.13.5/Python/ceval.c:1816
#30 _PyFunction_Vectorcall (kwnames=0x0, nargsf=<optimized out>, stack=0x7fffffffcdf0, func=0x7fffceb98680) at /usr/local/src/conda/python-3.13.5/Objects/call.c:413
#31 _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x7fffffffcdf0, callable=0x7fffceb98680, tstate=0x555555ab55b0 <_PyRuntime+283024>)
    at /usr/local/src/conda/python-3.13.5/Include/internal/pycore_call.h:168
#32 vectorcall_unbound (nargs=<optimized out>, args=0x7fffffffcdf0, func=<optimized out>, unbound=<optimized out>, tstate=<optimized out>)
    at /usr/local/src/conda/python-3.13.5/Objects/typeobject.c:2570
#33 vectorcall_method (nargs=2, args=0x7fffffffcdf0, name=0x555555a79d80 <_PyRuntime+39264>) at /usr/local/src/conda/python-3.13.5/Objects/typeobject.c:2601
#34 slot_mp_subscript (self=<optimized out>, arg1=<optimized out>) at /usr/local/src/conda/python-3.13.5/Objects/typeobject.c:9338
#35 0x00005555555f6c9d in _PyEval_EvalFrameDefault (tstate=0x555555ab55b0 <_PyRuntime+283024>, frame=<optimized out>, throwflag=<optimized out>)
    at /usr/local/src/conda/python-3.13.5/Python/generated_cases.c.h:446
#36 0x00005555557c9171 in PyEval_EvalCode (co=co@entry=0x7ffff73fe3a0, globals=globals@entry=0x7ffff77344c0, locals=locals@entry=0x7ffff77344c0)
    at /usr/local/src/conda/python-3.13.5/Python/ceval.c:604
#37 0x0000555555807010 in run_eval_code_obj (tstate=tstate@entry=0x555555ab55b0 <_PyRuntime+283024>, co=co@entry=0x7ffff73fe3a0, globals=globals@entry=0x7ffff77344c0, 
    locals=locals@entry=0x7ffff77344c0) at /usr/local/src/conda/python-3.13.5/Python/pythonrun.c:1381
#38 0x00005555558049cc in run_mod (mod=mod@entry=0x555555d356b0, filename=filename@entry=0x7ffff76b1530, globals=globals@entry=0x7ffff77344c0, locals=locals@entry=0x7ffff77344c0, 
    flags=flags@entry=0x7fffffffd258, arena=arena@entry=0x7ffff775c9f0, interactive_src=0x0, generate_new_source=0) at /usr/local/src/conda/python-3.13.5/Python/pythonrun.c:1466
#39 0x0000555555801876 in pyrun_file (fp=fp@entry=0x555555bb1e80, filename=filename@entry=0x7ffff76b1530, start=start@entry=257, globals=globals@entry=0x7ffff77344c0, 
    locals=locals@entry=0x7ffff77344c0, closeit=closeit@entry=1, flags=0x7fffffffd258) at /usr/local/src/conda/python-3.13.5/Python/pythonrun.c:1295
#40 0x00005555558014a8 in _PyRun_SimpleFileObject (fp=fp@entry=0x555555bb1e80, filename=filename@entry=0x7ffff76b1530, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffd258)
    at /usr/local/src/conda/python-3.13.5/Python/pythonrun.c:517
#41 0x00005555558012bc in _PyRun_AnyFileObject (fp=0x555555bb1e80, filename=filename@entry=0x7ffff76b1530, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffd258)
    at /usr/local/src/conda/python-3.13.5/Python/pythonrun.c:77
#42 0x00005555557ff6ae in pymain_run_file_obj (skip_source_first_line=0, filename=0x7ffff76b1530, program_name=0x7ffff7768030) at /usr/local/src/conda/python-3.13.5/Modules/main.c:410
#43 pymain_run_file (config=0x555555a87ca8 <_PyRuntime+96392>) at /usr/local/src/conda/python-3.13.5/Modules/main.c:429
#44 pymain_run_python (exitcode=0x7fffffffd24c) at /usr/local/src/conda/python-3.13.5/Modules/main.c:696
#45 Py_RunMain () at /usr/local/src/conda/python-3.13.5/Modules/main.c:775
#46 0x00005555557b4d97 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at /usr/local/src/conda/python-3.13.5/Modules/main.c:829
#47 0x00007ffff7cb66b5 in __libc_start_call_main (main=main@entry=0x5555557b4ce0 <main>, argc=argc@entry=2, argv=argv@entry=0x7fffffffd4b8) at ../sysdeps/nptl/libc_start_call_main.h:58
#48 0x00007ffff7cb6769 in __libc_start_main_impl (main=0x5555557b4ce0 <main>, argc=2, argv=0x7fffffffd4b8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fffffffd4a8) at ../csu/libc-start.c:360
#49 0x00005555557b418e in _start ()

cphyc avatar Jul 13 '25 17:07 cphyc