-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Describe the bug
When using cimport numpy and numpy is not available at runtime, a segmentation fault is thrown.
To Reproduce
I used the following code
# distutils: language=c++
# cython: language_level=3, binding=True
cimport numpy as np
def test():
passand uninstalled numpy before importing the module. For Cython 3.0a1 and Cython 0.29.24 this leads to an import error, while for any version newer than Cython 3.0a1 this causes a segmentation fault.
Expected behavior
No segmentation fault should be thrown.
Environment (please complete the following information):
- OS: tested on Windows and Fedora
- Python version: tested on 3.7 and 3.9
- Cython version >3.0a1
Additional context
running the import in gdb leads to the following backtrace:
Program received signal SIGSEGV, Segmentation fault.
__Pyx_CLineForTraceback (c_line=3988, tstate=0x55555555afa0) at src/test.cpp:5923
5923 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
(gdb) bt
#0 __Pyx_CLineForTraceback (c_line=3988, tstate=0x55555555afa0) at src/test.cpp:5923
#1 __Pyx_AddTraceback (filename=0x7ffff7fba89b "test.pyx", py_line=2, c_line=3988,
funcname=0x7ffff7fba886 "init test") at src/test.cpp:6105
#2 __pyx_pymod_exec_test (__pyx_pyinit_module=<optimized out>) at src/test.cpp:4057
#3 0x00007ffff7ddcdc3 in PyModule_ExecDef (module=<module at remote 0x7fffea250090>, def=<optimized out>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Objects/moduleobject.c:399
#4 0x00007ffff7ddcd34 in exec_builtin_or_dynamic (mod=<module at remote 0x7fffea250090>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/import.c:2248
#5 _imp_exec_builtin_impl (mod=<module at remote 0x7fffea250090>, module=<optimized out>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/import.c:2341
#6 _imp_exec_builtin (module=<optimized out>, mod=<module at remote 0x7fffea250090>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/clinic/import.c.h:388
#7 0x00007ffff7d6a36b in cfunction_vectorcall_O (
func=<built-in method exec_dynamic of module object at remote 0x7fffea3746d0>, args=0x7fffea2de8f8,
nargsf=<optimized out>, kwnames=<optimized out>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Objects/methodobject.c:516
#8 0x00007ffff7d63fc7 in do_call_core (kwdict={}, callargs=(<module at remote 0x7fffea250090>,),
func=<built-in method exec_dynamic of module object at remote 0x7fffea3746d0>, tstate=<optimized out>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/ceval.c:5095
#9 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/ceval.c:3580
#10 0x00007ffff7d5d00d in _PyEval_EvalFrame (throwflag=0,
f=Frame 0x7fffea2d7ac0, for file <frozen importlib._bootstrap>, line 228, in _call_with_frames_removed (f=<built-in method exec_dynamic of module object at remote 0x7fffea3746d0>, args=(<module at remote 0x7fffea250090>,), kwds={}), tstate=0x55555555afa0) at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Include/internal/pycore_ceval.h:40
#11 _PyEval_EvalCode (tstate=<optimized out>, _co=<optimized out>, globals=<optimized out>, locals=<optimized out>,
args=<optimized out>, argcount=<optimized out>, kwnames=0x0, kwargs=0x7fffea2d7e18, kwcount=0, kwstep=1,
defs=0x0, defcount=0, kwdefs=0x0, closure=0x0, name='_call_with_frames_removed',
qualname='_call_with_frames_removed') at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/ceval.c:4327
#12 0x00007ffff7d6acee in _PyFunction_Vectorcall (func=<optimized out>, stack=<optimized out>,
nargsf=<optimized out>, kwnames=<optimized out>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Objects/call.c:396
#13 0x00007ffff7d6305e in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x7fffea2d7e08,
callable=<function at remote 0x7fffea38b430>, tstate=0x55555555afa0)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Include/cpython/abstract.h:118
#14 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7fffea2d7e08,
callable=<function at remote 0x7fffea38b430>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Include/cpython/abstract.h:127
#15 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, tstate=0x55555555afa0)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/ceval.c:5075
#16 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/ceval.c:3487
#17 0x00007ffff7d6afe3 in _PyEval_EvalFrame (throwflag=0,
f=Frame 0x7fffea2d7c80, for file <frozen importlib._bootstrap_external>, line 1181, in exec_module (self=<ExtensionFileLoader(name='rapidfuzz.test', path='/home/max/RapidFuzz/.venv/lib64/python3.9/site-packages/rapidfuzz/test.cpython-39-x86_64-linux-gnu.so') at remote 0x7fffea2498b0>, module=<module at remote 0x7fffea250090>),
tstate=0x55555555afa0) at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Include/internal/pycore_ceval.h:40
#18 function_code_fastcall (tstate=0x55555555afa0, co=<optimized out>, args=<optimized out>, nargs=2,
globals=<optimized out>) at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Objects/call.c:330
#19 0x00007ffff7d5e5eb in _PyObject_VectorcallTstate (kwnames=0x0, nargsf=<optimized out>, args=0x7fffea310f50,
callable=<function at remote 0x7fffea34f790>, tstate=0x55555555afa0)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Include/cpython/abstract.h:118
#20 PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7fffea310f50,
callable=<function at remote 0x7fffea34f790>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Include/cpython/abstract.h:127
#21 call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, tstate=0x55555555afa0)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/ceval.c:5075
--Type <RET> for more, q to quit, c to continue without paging--
#22 _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Python/ceval.c:3504
#23 0x00007ffff7d6afe3 in _PyEval_EvalFrame (throwflag=0,
f=Frame 0x7fffea310dd0, for file <frozen importlib._bootstrap>, line 680, in _load_unlocked (spec=<ModuleSpec(name='rapidfuzz.test', loader=<ExtensionFileLoader(name='rapidfuzz.test', path='/home/max/RapidFuzz/.venv/lib64/python3.9/site-packages/rapidfuzz/test.cpython-39-x86_64-linux-gnu.so') at remote 0x7fffea2498b0>, origin='/home/max/RapidFuzz/.venv/lib64/python3.9/site-packages/rapidfuzz/test.cpython-39-x86_64-linux-gnu.so', loader_state=None, submodule_search_locations=None, _set_fileattr=True, _cached=None, _initializing=True) at remote 0x7fffea2492b0>, module=<module at remote 0x7fffea250090>), tstate=0x55555555afa0)
at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Include/internal/pycore_ceval.h:40
#24 function_code_fastcall (tstate=0x55555555afa0, co=<optimized out>, args=<optimized out>, nargs=1,
globals=<optimized out>) at /usr/src/debug/python3.9-3.9.7-1.fc34.x86_64/Objects/call.c:330
For the full backtrace check the following file:
backtrace.txt
Metadata
Metadata
Assignees
Labels
No labels