roi_saumon
roi_saumon

Reputation: 604

no core dump in /var/crash

I am trying to understand a bit how the core dump work.

I use the test.c file to generate a core dump :

#include <stdio.h>                                                              

void foo()                                                                      
{                                                                               
        int *ptr = 0;                                                           
        *ptr = 7;                                                               
}                                                                               

int main()                                                                      
{                                                                               
        foo();                                                                  
        return 0;                                                               
}

I compile with

gcc test.c -o test

Which gives me the following message when I run ./test

Segmentation fault (core dumped)

My file

/proc/sys/kernel/core_pattern 

contains :

|/usr/share/apport/apport %p %s %c %d %P

I checked that I have the permissions to write to the directory

/var/crash/

but after the core dump there is nothing in this folder (/var/crash/). I am using Linux release 17.04. Do you know what can go wrong here?

edit

I forgot to mention that I set the limits with :

ulimit -c unlimited

so the output of

ulimit -c

reads :

unlimited

I even tried to do what they say here in section How to enable apport, so I added a hash sign in front of

'problem_types': ['Bug', 'Package']

But with all of this the core dump cannot be found in /var/cash

Upvotes: 6

Views: 9632

Answers (3)

Patrick Roocks
Patrick Roocks

Reputation: 3259

I was also struggling to get coredumps and I had the same problem with ulimit. The session specific setting suggested by Niranjan also didn't work for me.

Finally I found the solution at https://serverfault.com/questions/216656/how-to-set-systemwide-ulimit-on-ubuntu

in /etc/security/limits.conf add:

root - core unlimited
*    - core unlimited

And log out / log in.

Then

ulimit -c

on the terminal should return "unlimited" and core dumps are generated.

Upvotes: 1

Mayank Jain
Mayank Jain

Reputation: 2564

This link contains a checklist for why coredump is not generated. Adding the list below in case link becomes inaccessible in future.

  • The core would have been larger than the current limit.
  • You don't have the necessary permissions to dump core (directory and file). Notice that core dumps are placed in the dumping process' current directory which could be different from the parent process.
  • Verify that the file system is writeable and have sufficient free space.
  • If a sub directory named core exist in the working directory no core will be dumped.
  • If a file named core already exist but has multiple hard links the kernel will not dump core.
  • Verify the permissions on the executable, if the executable has the suid or sgid bit enabled core dumps will by default be disabled. The same will be the case if you have execute permissions but no read permissions on the file.
  • Verify that the process has not changed working directory, core size limit, or dumpable flag.
  • Some kernel versions cannot dump processes with shared address space (AKA threads). Newer kernel versions can dump such processes but will append the pid to the file name.
  • The executable could be in a non-standard format not supporting core dumps. Each executable format must implement a core dump routine.
  • The segmentation fault could actually be a kernel Oops, check the system logs for any Oops messages.
  • The application called exit() instead of using the core dump handler.

Upvotes: 3

Niranjan Nagaraju
Niranjan Nagaraju

Reputation: 923

What filesize limit have you set for coredumps in your machine? You can check it using

$ ulimit -c

If it is set to 0, then no coredumps will be generated - This is the default setting in most distros.

You can enable coredumps by setting it to 'unlimited' or using a specific filesize limit.

$ ulimit -c unlimited

Upvotes: 0

Related Questions