🔍
Artificial Intelligence Cybersecurity Windows Mac Android iPhone Software How-To Guides Reviews Comparisons Productivity Internet Apps Cloud Business Software About Contact

How to Fix "Segmentation Fault (Core Dumped)" Error in Linux

A segmentation fault (segfault) error with "core dumped" message means a program tried to access memory it was not allowed to access. This commonly happens when compiling software from source or running poorly written programs. Here is how to diagnose and fix it.

Fix 1: Check for Hardware Issues

Segfaults are often caused by faulty hardware, especially RAM. Run memtest86+ by selecting it from your GRUB boot menu. If it is not installed, run sudo apt install memtest86+. Let the test run for at least one full pass. If errors are found, your RAM needs replacement. Also check for overheating with sensors command (install with sudo apt install lm-sensors).

Fix 2: Reinstall the Software

If the segfault only happens with one program, the installation may be corrupted. Remove and reinstall the software with sudo apt remove packagename followed by sudo apt install packagename. For software compiled from source, delete the source directory, re-download it, and recompile from scratch.

Fix 3: Increase Stack Size

Some programs need more stack memory than the default allows. Run ulimit -s unlimited in the terminal before running the program that crashes. To make this permanent, add ulimit -s unlimited to your ~/.bashrc file. This is a common fix for scientific software and game servers.

Fix 4: Compile with Debug Flags

If you are compiling from source and getting segfaults, recompile with debug flags to identify the issue. Add -g -O0 -Wall to your CFLAGS. Run the program inside gdb (GNU Debugger) with gdb ./program, then type run. When it crashes, type bt (backtrace) to see exactly where the crash happened.