Python "Segmentation fault (core dumped)" in a C extension in CI
A native extension dereferenced bad memory and the OS killed the process. Python prints no traceback because the interpreter itself crashed - the cause is in the C layer, often an ABI mismatch or an incompatible compiled wheel.
What this error means
The job ends abruptly with "Segmentation fault (core dumped)" or "Fatal Python error: Segmentation fault" and a non-zero exit, with no Python traceback.
python
Fatal Python error: Segmentation fault
Current thread 0x00007f... (most recent call first):
File "app/infer.py", line 22 in run
Segmentation fault (core dumped)Common causes
A C-extension ABI mismatch
Two binary packages (e.g. NumPy and a dependent) built against incompatible ABIs crash when they interact.
An incompatible or corrupted wheel for the runner
A wheel built for a different CPU/instruction set or a corrupted download faults at runtime.
How to fix it
Reinstall the binary stack consistently
- Identify the extension active at the crash (the last Python frame printed).
- Pin and force-reinstall it and NumPy together so ABIs match.
- Re-run to confirm the segfault is gone.
Terminal
pip install --force-reinstall --no-cache-dir numpy scipyGet a faulthandler traceback to localize it
Enable faulthandler to capture the native frame and confirm which extension faults.
Terminal
python -X faulthandler -m pytestHow to prevent it
- Keep binary dependencies pinned and ABI-consistent.
- Prefer wheels built for the runner architecture.
- Enable faulthandler in CI to diagnose native crashes quickly.
Related guides
Python "numpy.core.multiarray failed to import" (ABI) in CIFix "ImportError: numpy.core.multiarray failed to import" in CI - a C extension was built against a different…
Python "ValueError: numpy.dtype size changed" (binary incompatibility) in CIFix "ValueError: numpy.dtype size changed, may indicate binary incompatibility" in CI - a Cython/C extension…
Python "ImportError: libffi.so.X: cannot open shared object file" in CIFix "ImportError: libffi.so.X: cannot open shared object file" in CI - a Python extension needs the system li…