SilverWebBuzz

Segmentation Fault (Core Dumped): Why It Crashes

Segmentation Fault (Core Dumped)
Get in Touch With Us
Submitting the form below will ensure a prompt response from us.

    What is Segmentation fault (core dumped)

    • Segmentation fault: the process attempted an invalid memory access and received SIGSEGV, so it was terminated.
    • Core dumped: the default action for some fatal signals is to terminate the process and write a core dump (a memory/process-state snapshot) that can be analyzed with a debugger.

    Immediate actions that save time

    Confirm the signal/exit

    echo $?

    1. 139 commonly indicates SIGSEGV (11), but rely on logs/debugger output for certainty.2. Record the exact reproducer
    • full command line, inputs, working directory
    • version/build info (– version , package version, commit hash)
    • whether it’s inside container/WSL/VM/CI
    3. Check if it’s reproducible
    • If it crashes only once, suspect unstable hardware/overclock, corrupted binaries, or nondeterministic concurrency issues.

    Get a useful backtrace

    If you have a core file on disk

    1. Find it (common: core, core . in the working directory; may differ by system policy).
    gdb -q /path/to/executable /path/to/core
    In gdb:

    gdb

    set pagination off
    bt
    bt full
    info threads
    thread apply all bt full

    If your system stores cores via systemd

    coredumpctl list –reverse | head
    coredumpctl gdb

    Then in gdb :
    gdb
    thread apply all bt full

    If you can’t get a core dump

    Run under the debugger:

    gdb -q –args /path/to/executable [args…]
    run
    thread apply all bt full

    If the backtrace is mostly ?? : you’re missing debug symbols or using a different binary than the one that crashed. Fix that before guessing.

    Fast root-cause isolation by scenario

    You control the source (C/C++/Rust/Fortran)

    1. Rebuild for debugging:

    • include symbols, reduce optimization, keep frame pointers (recommended).

    2. Reproduce under gdb; identify the first stack frame in your code.

    3. If the crash is inside malloc/free/memcpy/strlen, assume earlier memory corruption.

    4. Use memory tooling (best ROI):

    • AddressSanitizer for out-of-bounds/use-after-free/double-free
    • UndefinedBehaviorSanitizer for UB-driven crashes
    • Valgrind if sanitizers aren’t possible

    5. High-frequency bug classes:

    • out-of-bounds read/write
    • use-after-free / double-free
    • null/dangling pointer dereference
    • stack overflow (deep recursion / huge stack arrays)
    • data race (nondeterministic crash locations)

    Prebuilt app / packaged binary

    Prioritize environment and ABI mismatch:1. Remove library overrides and injection:
    • temporarily unset LD_LIBRARY_PATH, remove LD_PRELOAD, disable third-party plugins/extensions.
    2. Check whether it only happens on one machine/container image:
    • suspect mismatched glibc/libstdc++/driver stack.
    3. Update the app; if it. started after an update, test a known-good prior version.

    Python: segmentation fault core dumped

    Most often, a native extension (.so) issue:

    1. Reproduce in a fresh venv with minimal dependencies.
    2. Upgrade/reinstall the suspected wheel/extension.
    3. Bisect imports until the crash disappears; the last enabled native module is usually the culprit.
    4. If you own the extension: rebuild with symbols and debug it like C/C++.

    Node.js

    Common cause: native addons compiled against a different Node/V8 ABI:

    • reinstall dependencies, rebuild addons, align Node version to addon expectations.

    JVM (Java/Kotlin/Scala)

    Most JVM segfaults involve JNI/JNA or low-level runtime/flags:

    • remove non-default JVM flags, update JVM, isolate JNI libraries; use the JVM crash log if present.

    What fixed looks like

    • the original reproducer no longer crashes across repeated runs, and
    • the fix is covered by a regression test (or sanitizer run is clean on the reproducer if you can rebuild).

    Minimal output to paste into a bug report

    • exact command + inputs (or a minimal reproducer)
    • version/build id
    • OS/kernel/arch + container/VM info if relevant
    • thread apply all bt full output (from core or live gdb)
    • whether it reproduces with plugins/extensions disabled and with a clean environment

    About Author

    Bhavik Koradiya is the CEO / Co. Founder of Silver WebBuzz Pvt. Ltd. Having 18+ years Experience in LAMP technology. I have expert in Magento, Joomla, WordPress, Opencart, e-commerce and many other open source. Specialties: Magento, WordPress, OpenCart, Joomla, JQuery, Any Open source.

    Related Q&A

    Scroll to Top