4

I was trying to generate a core file in Ubuntu 18.04. My program generates a core file, but I'm not able to find it.

$ ./a.out
Segmentation fault (core dumped)
$ ls -lrt
total 32
-rwxrwxrwx 1 sanjay sanjay   302 Mar  4 16:38 segmentation.cpp
-rwxrwxrwx 1 sanjay sanjay 28720 Mar  4 16:47 a.out
Zanna
  • 70,465
sam
  • 41
  • 1
  • 1
  • 2

2 Answers2

13

Since non-programming users can learn little from coredumps, your shell likely suppresses them by default by setting the ulimit value to zero:

$ ulimit -c
0

You can set the value to any non-zero size, or simply remove the limit altogether using ulimit -c unlimited

See help ulimit or refer to man bash for details.

steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • 3
    already set ulimit to unlimited – sam Mar 06 '19 at 14:46
  • But not able to find out where system generate core file – sam Mar 06 '19 at 14:47
  • @sam it should be generated in the current directory – steeldriver Mar 06 '19 at 14:55
  • 2
    no its not generated in the current folder , /tmp/cores/ also – sam Mar 06 '19 at 15:15
  • @sam confirm that the ulimit is set right, because I was able to, using a test program that WILL error out, generate a segv and a core dump in the working dir – Thomas Ward Mar 06 '19 at 21:38
  • 1
    @sam ALSO it's not the general ulimit (also set to unlimited in my system), its' the coredump ulimit which you get with ulimit -c - make sure that is 'unlimited' as well. – Thomas Ward Mar 06 '19 at 21:47
  • i have installed ubuntu on window 10 as " window subsystem for linux" . So is this a issue why i am not able to find out core file – sam Mar 07 '19 at 03:15
  • @sam yes it very well may be: see for example Core dump file is unavailable #1262 – steeldriver Mar 07 '19 at 03:22
  • my problem is that i have tracked down the problem to crash flles being created by apport in /var/crash. I have no problem with this behavior in general, but for a specific invocation or a command I want an actual core dump I can run gdb on without having to decode some crash file (which I'm not even equipped to do yet!) – Michael May 27 '20 at 23:23
0

check out Where do I find the core dump in ubuntu 16.04LTS?

In Ubuntu the core dumps are handled by Apport and can be located in /var/crash/. But it is disabled by default in stable releases