Unable to create a core file for my crashed program

10,235

Solution 1

Your real question appears to be not "where is my core dump", but rather "how can I modify /proc/sys/kernel/core_pattern".

sudo bash -c 'echo core.%e.%p > /proc/sys/kernel/core_pattern'

should do the trick.

Solution 2

You need to adjust your core dump size limit with following command:

ulimit -S -c maximum-core-dump-size

The the value is given in Kb.

Solution 3

you do not need to use core pattern. its just dumps in that format %e.%p

what you need to do is #ulimit -c unlimited

and check #ulimit -a

and confirm if core file size is set properly. You will get the core as core.pid after that.

Solution 4

My understanding is that using ulimit is not permanent, i.e. if you reboot then the limit goes back to 0. To have unlimited permanent, you need to change /etc/security/limits.conf. Similarly for core pattern etc, change /etc/sysctl.conf.

Share:
10,235
Surjya Narayana Padhi
Author by

Surjya Narayana Padhi

I feel passionate to work in computer vision. It like a magic to me. Giving machines intelligence is so cool thing. I like to work various projects which are cool. Like to learn any technology on my way to accomplish a cool project. Exploring data,applying machine learning techniques for prediction or statistical methods to get insights is so awesome. Creating nice visualization using python is so nice. My hobby : Reading recent science news, Astrology, music

Updated on June 18, 2022

Comments

  • Surjya Narayana Padhi
    Surjya Narayana Padhi about 2 years

    I am using Ubuntu 12.04 LTS. I wrote a simple program as follows to create crash

    // null.c
    #include<stdio.h>
    
    int main()
    {
       int *p = NULL;
       int k=*p;
       printf("%d",sizeof(0));
       return 0;
    }
    

    Now I run with "gcc -g null.c" and then "./a.out" and the output is as expected.

    Segmentation fault (core dumped)
    

    Now I want to see the core dump file using gdb. I did the following things

    1. I checked the current directory, there is no core dump file
    2. I tried tried to change the /proc/sys/kernel/core_pattern with the content "core.%e.%p". But i am not able to write into the file. It is saying "Fsync Failed".
    3. I used the "sudo vi /proc/sys/kernel/core_pattern". Still can't write into the file.

    I want to create the core dump in my current directory. What to do now?

  • LF00
    LF00 almost 3 years
    root user get Operation not permitted.