How to generate a core dump in Linux on a segmentation fault?

前端 未结 12 1232
余生分开走
余生分开走 2020-11-22 17:06

I have a process in Linux that\'s getting a segmentation fault. How can I tell it to generate a core dump when it fails?

12条回答
  •  执念已碎
    2020-11-22 17:34

    Ubuntu 19.04

    All other answers themselves didn't help me. But the following sum up did the job

    Create ~/.config/apport/settings with the following content:

    [main]
    unpackaged=true
    

    (This tells apport to also write core dumps for custom apps)

    check: ulimit -c. If it outputs 0, fix it with

    ulimit -c unlimited
    

    Just for in case restart apport:

    sudo systemctl restart apport
    

    Crash files are now written in /var/crash/. But you cannot use them with gdb. To use them with gdb, use

    apport-unpack  
    

    Further information:

    • Some answers suggest changing core_pattern. Be aware, that that file might get overwritten by the apport service on restarting.
    • Simply stopping apport did not do the job
    • The ulimit -c value might get changed automatically while you're trying other answers of the web. Be sure to check it regularly during setting up your core dump creation.

    References:

    • https://stackoverflow.com/a/47481884/6702598

提交回复
热议问题