Skip to content
Latchkey

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

  1. Identify the extension active at the crash (the last Python frame printed).
  2. Pin and force-reinstall it and NumPy together so ABIs match.
  3. Re-run to confirm the segfault is gone.
Terminal
pip install --force-reinstall --no-cache-dir numpy scipy

Get a faulthandler traceback to localize it

Enable faulthandler to capture the native frame and confirm which extension faults.

Terminal
python -X faulthandler -m pytest

How 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →