Skip to content

Instantly share code, notes, and snippets.

@jdmichaud
Last active July 30, 2025 10:38
Show Gist options
  • Save jdmichaud/5b2dbbc606ead60fe5ff1ee663301e24 to your computer and use it in GitHub Desktop.
Save jdmichaud/5b2dbbc606ead60fe5ff1ee663301e24 to your computer and use it in GitHub Desktop.
Core dump gdb debug crash

Write a buggy program:

int main() {
    int *p = 0;
    *p = 42;
    return 0;
}

Compile it with debug options:

cc -ggdb3 crash.c -o crash

Enable core dump (on ubuntu 24.04.2):

ulimit -c unlimited
sudo service apport stop

Crash it

$ ./crash 
Segmentation fault (core dumped)

Debug it:

gdb crash core

You can debug a stripped crashed program if you kept the debug version handy:

$ cp crash crash.debug
$ strip crash
$ ./crash
$ gdb --quiet crash.debug core
Reading symbols from crash.debug...
[New LWP 21153]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./crash'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000627af1f6213d in main () at crash.c:3
3           *p = 42;
(gdb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment