Facebook Twitter Instagram
    WiredRevolution.com
    • Home
    • About
    • Contact Us
    • Essential Linux Commands
    • Sitemap
    Facebook Twitter Instagram
    WiredRevolution.com
    guides

    How to create and debug a core dump file

    RyanBy RyanNovember 2, 2012Updated:November 2, 20122 Mins Read
    Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Email

    Debugging programs is not fun or easy but knowing how to create and analyze a core file dump from a dying program makes your life a bit easier.

    First off check the system core dump size limit.
    $ ulimit -c
    0

    Set the maximum size of core files created to unlimited. This must be done each time you start a new login session as it will only change this limit for the current shell.
    $ ulimit -c unlimited

    $ ulimit -c
    unlimited

    Here is the source code for a simple C program that will produce a segfault and a coredump.
    vim coredump.c

    #include <sys/types.h>
    #include <signal.h>
    main()
    {
    kill(getpid(), SIGSEGV);
    }

    Build the program.
    $ make coredump
    cc coredump.c -o coredump

    Now you can run it.
    $ ./coredump
    Segmentation fault (core dumped)

    The core file should now exist in the execution directory.
    $ ls core.*
    core.12345

    Use gdb to look at the core file. This show you the stack trace for each thread in the program. This must be done on the same system since a different system may have different libraries and the results might not be correct.
    $ gdb coredump core.12345
    Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
    Loaded symbols for /lib64/libc.so.6
    Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
    Loaded symbols for /lib64/ld-linux-x86-64.so.2
    Core was generated by `./coredump'.
    Program terminated with signal 11, Segmentation fault.
    #0 0x00000031ba830717 in kill () from /lib64/libc.so.6

    (gdb) thread apply all bt
    Thread 1 (Thread 27701):
    #0 0x00000031ba830717 in kill () from /lib64/libc.so.6
    #1 0x00000000004004f2 in main ()
    (gdb) q

    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Email
    Previous ArticleValve opens registration for Steam for Linux beta
    Next Article Install Virtualbox on Ubuntu 12.10: the missing kernel module fix

    Related Posts

    How to test the syntax of a Python script

    Fix insync Gnome Shell extension error on Ubuntu

    Safely and atomically change a symlink target

    Most Commented
    March 12, 2009

    Fix blue tinted video in Ubuntu

    September 10, 2010

    Setup SSH access between VirtualBox Host and Guest VMs

    March 8, 2011

    Install GNOME Shell in Ubuntu 10.10 Maverick

    April 4, 2009

    Setup the PS3 Bluetooth Controller on Ubuntu

    October 22, 2008

    How to correctly use LD_LIBRARY_PATH

    Recent Comments
    • Execute command on linux virtual machine (or server) from windows commandline on Setup SSH access between VirtualBox Host and Guest VMs
    • Solved: How to SSH to a VirtualBox guest externally through a host? - Daily Developer Blog on Setup SSH access between VirtualBox Host and Guest VMs
    • How to SSH to a VirtualBox guest externally through a host? [closed] – Code D3 on Setup SSH access between VirtualBox Host and Guest VMs
    • How to copy and paste from VirtualBox? [duplicate] on Setup SSH access between VirtualBox Host and Guest VMs
    • Jackie Laguna on Fix OpenGL: ChoosePixelFormat SketchUp error in WINE
    © 2025 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.