Error Codes Wiki

Linux Core Dump Segfault Analysis Guide — What It Means & How to Fix It

Errorkernel error

About Linux Core Dump Segfault Analysis Guide

Analyze and debug Linux segmentation fault core dumps to identify the cause of crashes in applications and services. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: A segmentation fault (SIGSEGV) occurs when a program attempts to access memory it is not allowed to. Core dumps capture the program's memory state at the time of the crash for post-mortem analysis. Core dump generation must be enabled: ulimit -c unlimited sets the maximum core dump size. systemd-coredump on modern distros stores core dumps in /var/lib/systemd/coredump/. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Null pointer dereference — the program tried to use a pointer that points to address 0. Buffer overflow — writing past the end of an allocated buffer into protected memory. Use-after-free — accessing memory that has already been deallocated. Stack overflow from deep recursion exceeding the stack size limit. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Enable core dumps: ulimit -c unlimited && echo '/tmp/core.%e.%p' | sudo tee /proc/sys/kernel/core_pattern. Reproduce the crash to generate a core dump file. Analyze with gdb: gdb /path/to/binary /tmp/core.program.12345 then run 'bt full' for a full backtrace. If debug symbols are missing, install them: apt install binary-dbgsym or dnf debuginfo-install binary. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

How do I enable core dumps permanently?

Add 'ulimit -c unlimited' to /etc/profile or set it in /etc/security/limits.conf: '* soft core unlimited'. For systemd services, set LimitCORE=infinity in the service unit file.

Overview

Analyze and debug Linux segmentation fault core dumps to identify the cause of crashes in applications and services.

Key Details

  • A segmentation fault (SIGSEGV) occurs when a program attempts to access memory it is not allowed to
  • Core dumps capture the program's memory state at the time of the crash for post-mortem analysis
  • Core dump generation must be enabled: ulimit -c unlimited sets the maximum core dump size
  • systemd-coredump on modern distros stores core dumps in /var/lib/systemd/coredump/

Common Causes

  • Null pointer dereference — the program tried to use a pointer that points to address 0
  • Buffer overflow — writing past the end of an allocated buffer into protected memory
  • Use-after-free — accessing memory that has already been deallocated
  • Stack overflow from deep recursion exceeding the stack size limit

Steps

  1. 1Enable core dumps: ulimit -c unlimited && echo '/tmp/core.%e.%p' | sudo tee /proc/sys/kernel/core_pattern
  2. 2Reproduce the crash to generate a core dump file
  3. 3Analyze with gdb: gdb /path/to/binary /tmp/core.program.12345 then run 'bt full' for a full backtrace
  4. 4If debug symbols are missing, install them: apt install binary-dbgsym or dnf debuginfo-install binary

Tags

core-dumpsegfaultsigsegvgdbdebugging

Related Items

More in Kernel Error

Frequently Asked Questions

Add 'ulimit -c unlimited' to /etc/profile or set it in /etc/security/limits.conf: '* soft core unlimited'. For systemd services, set LimitCORE=infinity in the service unit file.