19

I have enabled a unlimited core file size using ulimit:

ulimit -a
core file size          (blocks, -c) unlimited
...

I believe I have triggered a core dump but I can't locate the core file in my home, var/... etc...

Do you know where Ubuntu configures the core dump location?

jcalfee314
  • 745
  • 3
  • 9
  • 23
  • @djf the OP didn't specify what program was causing core dumps. It may not be programmers code. It may be Unity for all we know. – Rich Homolka Jan 26 '15 at 23:48
  • 1
    How is this a SuperUser question? This is about running a debugger which only programmers use. This should be migrated back to SO. – Homer6 Mar 01 '18 at 05:04

3 Answers3

31

By default, the Ubuntu kernel is configured to use apport to log coredumps. You can override this by overwriting /proc/sys/kernel/core_pattern, check the "Naming of core dump files" section in man core for details. For example:

echo '/tmp/core.%e.%p.%t' | sudo tee /proc/sys/kernel/core_pattern

Apport writes core dumps to /var/crash/_path_to_program.userid.crash, BUT it will only do so for applications installed from the main ubuntu apt repositories.

More info on apport: https://wiki.ubuntu.com/Apport

maccam94
  • 411
  • 4
  • 3
  • 1
    To write core dumps for non-package programs as well, create a file named *~/.config/apport/settings* with the following contents: *[main]* *unpackaged=true* – greuze Oct 31 '18 at 09:01
  • Modifying the */proc/sys/kernel/core_pattern* does not work for me in Ubuntu 18.04 – greuze Oct 31 '18 at 09:03
6

I think this is a more Linux kernel thing than a specific Ubuntu thing. Check out

cat /proc/sys/kernel/core_pattern

Check out the core file man page

Rich Homolka
  • 31,057
  • 6
  • 55
  • 80
  • 13
    That does not tell you where it puts the file. The question named Ubuntu 14.04. It is not clear at all by following the command in `/proc/sys/kernel/core_pattern` where one would find the file. – jcalfee314 Feb 20 '15 at 01:49
  • 1
    For me, that core_pattern kernel pseudofile references a program called 'apport'... which has no man page nor much helpful output. So still searching for my dumped cores. :( – gojomo Jun 09 '15 at 14:34
  • 1
    apport is the standard linux desktop core handler it reports back to your distro usually. – kkron Sep 09 '15 at 02:16
  • How to open this folder? `cd /usr/share/apport/apport` don't work. – mrgloom Feb 09 '16 at 20:04
1

On Ubuntu 16.04.3 LTS, my core dump was located at:

/var/lib/systemd/coredump/core.application-name.0.24d47e89526c4c7e90953998d2c33d1e.19672.1516049424000000000000

So, to run it in gdb, you can run:

apt install gdb gdb /path/to/your/binary/application-name /var/lib/systemd/coredump/core.application-name.0.24d47e89526c4c7e90953998d2c33d1e.19672.1516049424000000000000

Homer6
  • 468
  • 4
  • 9