<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rui-Tech</title>
    <description>The latest articles on DEV Community by Rui-Tech (@legacycpp).</description>
    <link>https://dev.to/legacycpp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3830024%2Ff4f48e4a-2672-44a3-8ee0-76063145b056.png</url>
      <title>DEV Community: Rui-Tech</title>
      <link>https://dev.to/legacycpp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/legacycpp"/>
    <language>en</language>
    <item>
      <title>A Step-By-Step Guide for Handling Crash of Legacy C++ Application</title>
      <dc:creator>Rui-Tech</dc:creator>
      <pubDate>Sat, 04 Apr 2026 18:46:32 +0000</pubDate>
      <link>https://dev.to/legacycpp/a-step-by-step-guide-for-handling-crash-of-legacy-c-application-2h7h</link>
      <guid>https://dev.to/legacycpp/a-step-by-step-guide-for-handling-crash-of-legacy-c-application-2h7h</guid>
      <description>&lt;p&gt;You're on call. Production system crashed. No stack trace, no error message — just a dead process and maybe a core file.&lt;/p&gt;

&lt;p&gt;Now what?&lt;/p&gt;

&lt;p&gt;Do not be panic! Follow this guide step by step. You'll have a methodical approach to finding the root cause, whether you have debug symbols, a stripped binary, or nothing at all.&lt;/p&gt;

&lt;p&gt;Let's go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decision Tree – Your Quick Reference Flowchart
&lt;/h2&gt;

&lt;p&gt;Do not get lost -- keep the map in hand. Here is the complete decision map.&lt;/p&gt;

&lt;p&gt;CRASH&lt;br&gt;
|&lt;br&gt;
v&lt;br&gt;
HAVE CORE FILE? ──&lt;strong&gt;No&lt;/strong&gt;──&amp;gt; Enable cores (Path B) ──&amp;gt; Rerun crashed App&lt;br&gt;
|&lt;br&gt;
&lt;strong&gt;Yes&lt;/strong&gt; (Path A)&lt;br&gt;
|&lt;br&gt;
v&lt;br&gt;
HAVE DEBUG SYMBOLS? ──&lt;strong&gt;Yes&lt;/strong&gt;──&amp;gt; Debug (Path A4)&lt;br&gt;
|&lt;br&gt;
&lt;strong&gt;No&lt;/strong&gt;&lt;br&gt;
|&lt;br&gt;
v&lt;br&gt;
HAVE SYMBOL FILE? ──&lt;strong&gt;Yes&lt;/strong&gt;──&amp;gt; Load with -s flag (Step A6)&lt;br&gt;
|&lt;br&gt;
&lt;strong&gt;No&lt;/strong&gt;&lt;br&gt;
|&lt;br&gt;
v&lt;br&gt;
CAN REPRODUCE WITH SYMBOLS? ──&lt;strong&gt;Yes&lt;/strong&gt;──&amp;gt; Recompile with -g (Step A7)&lt;br&gt;
|&lt;br&gt;
&lt;strong&gt;No&lt;/strong&gt;&lt;br&gt;
|&lt;br&gt;
v&lt;br&gt;
HAVE ORIGINAL BUILD? ──&lt;strong&gt;Yes&lt;/strong&gt;──&amp;gt; Map addresses with addr2line (Step A8)&lt;br&gt;
|&lt;br&gt;
&lt;strong&gt;No&lt;/strong&gt;&lt;br&gt;
|&lt;br&gt;
v&lt;br&gt;
FALLBACK: Register analysis + instruction dump (Step A9)&lt;/p&gt;
&lt;h2&gt;
  
  
  Path A: Have a Core File
&lt;/h2&gt;

&lt;p&gt;The first question to ask: has a core file already been generated? Follow Step A1 to find out.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step A1: Locate the Core File
&lt;/h3&gt;

&lt;p&gt;Normally core files reside in the application's working directory and have names like &lt;code&gt;core*.*&lt;/code&gt;. Use the following commands to locate the core file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Common locations: &lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; core&lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; /var/core/
find / &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"core*"&lt;/span&gt; &lt;span class="nt"&gt;-type&lt;/span&gt; f 2&amp;gt;/dev/null

&lt;span class="c"&gt;# Check core pattern to know where cores go, then search again&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/sys/kernel/core_pattern
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;If you found a core file&lt;/strong&gt; → Continue with Step A2
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If not found&lt;/strong&gt; → Go to Path B
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Path B: No Core File Generated
&lt;/h2&gt;

&lt;p&gt;If no core file was generated yet, you need to enable core dumps and rerun the crashed app. Follow Steps B1 to B6 to generate a core file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step B1: Check Core Dump Settings
&lt;/h3&gt;

&lt;p&gt;Most production systems disable core file generation. That is why you did not find any core file yet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Check ulimit&lt;/span&gt;
&lt;span class="nb"&gt;ulimit&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt;
&lt;span class="c"&gt;# If 0 → core dump disabled&lt;/span&gt;

&lt;span class="c"&gt;# 2. Check core pattern&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/sys/kernel/core_pattern
&lt;span class="c"&gt;# If starts with '|' → core file was piped elsewhere&lt;/span&gt;
&lt;span class="c"&gt;# If empty or default → cores go to current directory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step B2: Enable Core Dumps
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Temporary enable core dump (only valid for the current session)&lt;/span&gt;
&lt;span class="nb"&gt;ulimit&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; unlimited

&lt;span class="c"&gt;# Permanent enable core dump (requires root access)&lt;/span&gt;
&lt;span class="c"&gt;# A core file will be generated whenever a crash happens&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"* soft core unlimited"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/security/limits.conf
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"* hard core unlimited"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/security/limits.conf

&lt;span class="c"&gt;# For systemd services (add to service file)&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;Service]
&lt;span class="nv"&gt;LimitCORE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;infinity
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pro Tips&lt;/strong&gt;: A core file can be large (e.g., 10 GB). The safer approach is the temporary option – enable core dumps only for the current session.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step B3: Set Core Location
&lt;/h3&gt;

&lt;p&gt;After core dumps are enabled, you can define where core files go. The easiest method, which works for 80% of applications, is to run the application from its working directory – the core file will be written there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Option 1: Local directory&lt;/span&gt;
&lt;span class="nb"&gt;ulimit&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; unlimited
&lt;span class="nb"&gt;cd&lt;/span&gt; /path/to/working/dir
./myapp

&lt;span class="c"&gt;# Option 2: Custom location (requires root)&lt;/span&gt;
&lt;span class="c"&gt;# Core files go to /var/core/ with pattern: core.&amp;lt;binary&amp;gt;.&amp;lt;pid&amp;gt;.&amp;lt;timestamp&amp;gt;&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"/var/core/core.%e.%p.%t"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /proc/sys/kernel/core_pattern

&lt;span class="c"&gt;# Make permanent (if the app is a systemd service)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"kernel.core_pattern=/var/core/core.%e.%p.%t"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/sysctl.conf
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"kernel.core_uses_pid=1"&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/sysctl.conf
&lt;span class="nb"&gt;sudo &lt;/span&gt;sysctl &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step B4: Check Permissions
&lt;/h3&gt;

&lt;p&gt;The core directory must be writable by the process user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Core directory must be writable for the process user&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /var/core
&lt;span class="c"&gt;# If it doesn't exist or has wrong permissions, create and fix it:&lt;/span&gt;
&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /var/core
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;1777 /var/core

&lt;span class="c"&gt;# Check who runs the process&lt;/span&gt;
ps aux | &lt;span class="nb"&gt;grep &lt;/span&gt;myapp
&lt;span class="c"&gt;# Ensure that user can write to the core location&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step B5: Test Core Dump
&lt;/h3&gt;

&lt;p&gt;To verify your settings work, run a small program that crashes intentionally, then locate the core file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Test with a crashing program&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; test_crash.cpp &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
int main() {
    int* p = nullptr;
    *p = 42;
    return 0;
}
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;g++ &lt;span class="nt"&gt;-o&lt;/span&gt; test_crash test_crash.cpp
&lt;span class="nb"&gt;ulimit&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; unlimited
./test_crash
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; core&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If core appears → your settings work&lt;/li&gt;
&lt;li&gt;If no core → check system settings from Step B1 and B3 again.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step B6: Rerun the Crashed App to Produce a Core File
&lt;/h3&gt;

&lt;p&gt;Rerun the crashed application. As expected, it will crash again – but this time, a core file will be generated. Then proceed to Step A2.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step A2: Identify Which Binary Created the Core
&lt;/h3&gt;

&lt;p&gt;Now you have two things: a core file (named &lt;code&gt;core&lt;/code&gt; in the example) and your application binary (&lt;code&gt;myapp&lt;/code&gt; in the example). Before debugging, verify that this core file actually came from the application &lt;em&gt;myapp&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use file command&lt;/span&gt;
file core
&lt;span class="c"&gt;# Output: core: ELF 64-bit core file, x86-64, version 1, from './myapp'&lt;/span&gt;

&lt;span class="c"&gt;# Or use gdb&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; info files
&lt;span class="c"&gt;# Shows: Core was generated by `./myapp'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: Did your application binary create this core file?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;If No&lt;/strong&gt; → Repeat Step A1 or go back to Path B until you locate the correct core file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If Yes&lt;/strong&gt; → Continue with Step A3
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step A3: Check for Debug Symbols
&lt;/h3&gt;

&lt;p&gt;To debug the binary, you need debug symbols. First, check whether the current binary already includes them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check if the binary has debug symbols&lt;/span&gt;
file ./myapp
&lt;span class="c"&gt;# If output says "stripped" → no symbols&lt;/span&gt;
&lt;span class="c"&gt;# If output says "not stripped" → has symbols&lt;/span&gt;

&lt;span class="c"&gt;# Or use nm&lt;/span&gt;
nm ./myapp 2&amp;gt;&amp;amp;1 | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-10&lt;/span&gt;
&lt;span class="c"&gt;# If "no symbols" → stripped&lt;/span&gt;
&lt;span class="c"&gt;# If shows function names → has symbols&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Decision Question&lt;/strong&gt;: Does the binary have debug symbols?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;If yes&lt;/strong&gt; → Continue to Path A4: Debug Immediately
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If no&lt;/strong&gt; → Go to Path A5: Find or Create Symbols
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Path A4: Debug with Symbols (Happy Path)
&lt;/h3&gt;

&lt;p&gt;You now have a binary with debug symbols and a core file. Debugging can start immediately using GDB.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Load core with binary&lt;/span&gt;
gdb ./myapp core

&lt;span class="c"&gt;# Essential commands&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; bt full          &lt;span class="c"&gt;# Full backtrace with locals&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; info threads     &lt;span class="c"&gt;# All threads&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; thread apply all bt  &lt;span class="c"&gt;# Backtrace all threads&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; frame 0          &lt;span class="c"&gt;# Select crash frame&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; info locals      &lt;span class="c"&gt;# Local variables&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; print variable   &lt;span class="c"&gt;# Print specific variable&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; list             &lt;span class="c"&gt;# Show source code&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Done! You have the crash location and state.&lt;/p&gt;

&lt;h3&gt;
  
  
  Path A5: Stripped Binary – Get Symbol File
&lt;/h3&gt;

&lt;p&gt;A stripped binary contains no debug symbols. However, your team may have archived symbols in a separate file. Industry practice is to build with debug symbols, strip the binary, store the symbols separately on your artifact servers, then deploy only the stripped binary to production system.&lt;/p&gt;

&lt;p&gt;Every binary has a unique &lt;strong&gt;Build ID&lt;/strong&gt; (a fingerprint). You can use this Build ID to find the matching standalone symbol file.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step A5.1: Get the Build ID from the Core Dump or Binary
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# From core dump&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core &lt;span class="nt"&gt;-batch&lt;/span&gt; &lt;span class="nt"&gt;-ex&lt;/span&gt; &lt;span class="s2"&gt;"info files"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Build ID"&lt;/span&gt;

&lt;span class="c"&gt;# Or from binary&lt;/span&gt;
readelf &lt;span class="nt"&gt;-n&lt;/span&gt; ./myapp | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Build ID"&lt;/span&gt;
&lt;span class="c"&gt;# Output example: Build ID: a1b2c3d4e5f67890abcdef1234567890&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step A5.2: Find the Symbol File Using That Build ID
&lt;/h4&gt;

&lt;p&gt;Your symbol files should be stored somewhere (CI artifacts, symbol server, or build archive). Search for the file containing this Build ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find /symbols &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="s2"&gt;"Build ID: a1b2c3d4e5f67890abcdef1234567890"&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt; &lt;span class="se"&gt;\;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Better practice&lt;/strong&gt;: Store symbol files by Build ID path so you don't need to grep:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# If stored as /symbols/a1/b2c3d4e5f67890...&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; /symbols/a1/b2c3d4e5f67890abcdef1234567890
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then continue to Step A6.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step A6: Debug with Separate Symbols
&lt;/h3&gt;

&lt;p&gt;Now you can debug using the stripped binary, symbol file, and core dump. Suppose the symbol file is named &lt;code&gt;myapp.dbg&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Method 1: Link binary to symbols (if --add-gnu-debuglink was used)&lt;/span&gt;
gdb ./myapp core
&lt;span class="c"&gt;# GDB auto-loads myapp.dbg if it's in the same directory&lt;/span&gt;

&lt;span class="c"&gt;# Method 2: Manual symbol loading&lt;/span&gt;
gdb &lt;span class="nt"&gt;-s&lt;/span&gt; myapp.dbg &lt;span class="nt"&gt;-e&lt;/span&gt; ./myapp &lt;span class="nt"&gt;-c&lt;/span&gt; core

&lt;span class="c"&gt;# Method 3: Recombine into full binary&lt;/span&gt;
eu-unstrip ./myapp myapp.dbg &lt;span class="nt"&gt;-o&lt;/span&gt; myapp.full
gdb ./myapp.full core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Path A7: No Symbol File Found – Reproduce with Debug Symbols
&lt;/h3&gt;

&lt;p&gt;When no matching symbol file exists, rebuild the source code with debug symbols enabled. This will produce a binary with debug symbols.&lt;/p&gt;

&lt;p&gt;Add these flags to your build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nt"&gt;-g&lt;/span&gt; &lt;span class="nt"&gt;-O0&lt;/span&gt; &lt;span class="nt"&gt;-fno-omit-frame-pointer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For GCC/Clang:&lt;/strong&gt; Add to &lt;code&gt;CFLAGS&lt;/code&gt; and &lt;code&gt;CXXFLAGS&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;CFLAGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"-g -O0 -fno-omit-frame-pointer"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;CXXFLAGS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"-g -O0 -fno-omit-frame-pointer"&lt;/span&gt;
make clean &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; make
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For CMake:&lt;/strong&gt; Use Debug build type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cmake &lt;span class="nt"&gt;-DCMAKE_BUILD_TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Debug &lt;span class="nb"&gt;.&lt;/span&gt;
make
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, follow Step B6 – rerun the new binary. If the crash occurs again, capture the core file and debug using Path A4.&lt;/p&gt;

&lt;p&gt;If you cannot make a debug build work, or you prefer not to reproduce the crash, you can still try Step A8 or Step A9.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do you have the unstripped original build?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;If yes&lt;/strong&gt; → Continue with Step A8
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If no&lt;/strong&gt; → Go to Step A9
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step A8: Map Addresses from Stripped Binary
&lt;/h3&gt;

&lt;p&gt;If you have the original build tree (unstripped binary) but the crashed binary in production is stripped, the core dump contains raw addresses that you can map back to source lines using the unstripped binary.&lt;/p&gt;

&lt;p&gt;The core dump stores &lt;strong&gt;raw addresses&lt;/strong&gt; (e.g., &lt;code&gt;0x55a3d8e2f4a0&lt;/code&gt;). The unstripped binary tells you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which function contains &lt;code&gt;0xf4a0&lt;/code&gt; (offset from base)&lt;/li&gt;
&lt;li&gt;Which source code line that address corresponds to
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Get the crash address from core dump&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core &lt;span class="nt"&gt;-batch&lt;/span&gt; &lt;span class="nt"&gt;-ex&lt;/span&gt; &lt;span class="s2"&gt;"info registers"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"rip"&lt;/span&gt;
&lt;span class="c"&gt;# Output: rip            0x55a3d8e2f4a0   0x55a3d8e2f4a0&lt;/span&gt;

&lt;span class="c"&gt;# 2. Find the memory map to calculate offset&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core &lt;span class="nt"&gt;-batch&lt;/span&gt; &lt;span class="nt"&gt;-ex&lt;/span&gt; &lt;span class="s2"&gt;"info proc mappings"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"r-x"&lt;/span&gt;
&lt;span class="c"&gt;# Output: 0x55a3d8e00000 0x55a3d8f00000 r-xp /path/to/myapp&lt;/span&gt;
&lt;span class="c"&gt;# Base address = 0x55a3d8e00000&lt;/span&gt;

&lt;span class="c"&gt;# 3. Calculate offset within the binary&lt;/span&gt;
offset &lt;span class="o"&gt;=&lt;/span&gt; crash_address - base_address
&lt;span class="c"&gt;# offset = 0x55a3d8e2f4a0 - 0x55a3d8e00000 = 0x2f4a0&lt;/span&gt;

&lt;span class="c"&gt;# 4. Use addr2line with the UNSTRIPPED binary (from your build)&lt;/span&gt;
addr2line &lt;span class="nt"&gt;-e&lt;/span&gt; /path/to/unstripped/myapp &lt;span class="nt"&gt;-f&lt;/span&gt; 0x2f4a0
&lt;span class="c"&gt;# Output:&lt;/span&gt;
&lt;span class="c"&gt;# processRequest&lt;/span&gt;
&lt;span class="c"&gt;# /src/myapp/src/handler.cpp:127&lt;/span&gt;

&lt;span class="c"&gt;# 5. Get full backtrace using addresses&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core &lt;span class="nt"&gt;-batch&lt;/span&gt; &lt;span class="nt"&gt;-ex&lt;/span&gt; &lt;span class="s2"&gt;"bt"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"0x"&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $NF}'&lt;/span&gt; | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read &lt;/span&gt;addr&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;offset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$((&lt;/span&gt;addr &lt;span class="o"&gt;-&lt;/span&gt; base_address&lt;span class="k"&gt;))&lt;/span&gt;
    addr2line &lt;span class="nt"&gt;-e&lt;/span&gt; /path/to/unstripped/myapp &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nv"&gt;$offset&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step A9: No Symbols, Can't Reproduce – Fallback Analysis
&lt;/h3&gt;

&lt;p&gt;You have nothing: no symbol file, no original build, and you cannot reproduce the crash with a debug build. This is the "desert island" scenario. You can still extract forensic evidence from the core dump.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Get crash address and registers&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core &lt;span class="nt"&gt;-batch&lt;/span&gt; &lt;span class="nt"&gt;-ex&lt;/span&gt; &lt;span class="s2"&gt;"info registers"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; crash_info.txt

&lt;span class="c"&gt;# 2. Get backtrace (even without names)&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core &lt;span class="nt"&gt;-batch&lt;/span&gt; &lt;span class="nt"&gt;-ex&lt;/span&gt; &lt;span class="s2"&gt;"bt"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; backtrace.txt

&lt;span class="c"&gt;# 3. Examine instructions near crash&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core &lt;span class="nt"&gt;-batch&lt;/span&gt; &lt;span class="nt"&gt;-ex&lt;/span&gt; &lt;span class="s2"&gt;"x/20i &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;rip-40"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; instructions.txt

&lt;span class="c"&gt;# 4. Check system library frames&lt;/span&gt;
gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core &lt;span class="nt"&gt;-batch&lt;/span&gt; &lt;span class="nt"&gt;-ex&lt;/span&gt; &lt;span class="s2"&gt;"bt"&lt;/span&gt; 2&amp;gt;&amp;amp;1 | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"libc|libstdc"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  What you can learn from raw analysis:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gdb &lt;span class="nt"&gt;-c&lt;/span&gt; core
&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; info registers
rax &lt;span class="o"&gt;=&lt;/span&gt; 0x0              → Null pointer dereference
rip &lt;span class="o"&gt;=&lt;/span&gt; 0x55...          → Crash &lt;span class="k"&gt;in &lt;/span&gt;your code &lt;span class="o"&gt;(&lt;/span&gt;not system library&lt;span class="o"&gt;)&lt;/span&gt;
rsp &lt;span class="o"&gt;=&lt;/span&gt; 0x7ff...         → Stack pointer valid

&lt;span class="o"&gt;(&lt;/span&gt;gdb&lt;span class="o"&gt;)&lt;/span&gt; x/10i &lt;span class="nv"&gt;$rip&lt;/span&gt;&lt;span class="nt"&gt;-20&lt;/span&gt;
0x55...:  mov    %rax, %rdi
0x55...:  &lt;span class="nb"&gt;test&lt;/span&gt;   %rdi, %rdi
0x55...:  je     0x55...    &lt;span class="c"&gt;# Jump if null&lt;/span&gt;
0x55...:  mov    &lt;span class="o"&gt;(&lt;/span&gt;%rdi&lt;span class="o"&gt;)&lt;/span&gt;, %rdx   &lt;span class="c"&gt;# CRASH HERE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Deduced&lt;/strong&gt;: Null pointer dereference in a function that takes a pointer parameter and doesn't check it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Action&lt;/strong&gt;: Review code for functions that accept pointers and call them without null checks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Command Reference
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Enable cores&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ulimit -c unlimited&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Find cores&lt;/td&gt;
&lt;td&gt;&lt;code&gt;find / -name "core*" 2&amp;gt;/dev/null&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check binary for symbols&lt;/td&gt;
&lt;td&gt;&lt;code&gt;file ./myapp&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Get build ID&lt;/td&gt;
&lt;td&gt;`readelf -n ./myapp&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extract symbols&lt;/td&gt;
&lt;td&gt;{% raw %}&lt;code&gt;objcopy --only-keep-debug myapp myapp.dbg&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debug with symbols&lt;/td&gt;
&lt;td&gt;&lt;code&gt;gdb -s myapp.dbg -e myapp -c core&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Map address to line&lt;/td&gt;
&lt;td&gt;&lt;code&gt;addr2line -e myapp -f 0x12345&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List function addresses&lt;/td&gt;
&lt;td&gt;`nm ./myapp&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check core pattern&lt;/td&gt;
&lt;td&gt;{% raw %}&lt;code&gt;cat /proc/sys/kernel/core_pattern&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Set core location&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo "/var/core/core.%e.%p" &amp;gt; /proc/sys/kernel/core_pattern&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Pro Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Always compile with &lt;code&gt;-g&lt;/code&gt; even for release, then strip separately&lt;/li&gt;
&lt;li&gt;Store debug symbols with Build ID as filename for easy retrieval&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;-fno-omit-frame-pointer&lt;/code&gt; for reliable backtraces&lt;/li&gt;
&lt;li&gt;Test core dump generation in your production environment&lt;/li&gt;
&lt;li&gt;Document your symbol server location in runbooks&lt;/li&gt;
&lt;li&gt;Set up automatic core collection in production&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;This workflow covers every scenario from "no core file" to "full debug symbols". Bookmark it for your next production crash.&lt;/p&gt;




</description>
      <category>cpp</category>
      <category>linux</category>
      <category>legacy</category>
      <category>coredump</category>
    </item>
  </channel>
</rss>
