Core dumps in snapd

@jenny.murphy there are a few things needed in a Ubuntu Core system to generate core files:

  1. ulimit -c unlimited is indeed still needed. Note that this needs to be set in the parent process, which means you will have to modify systemd unit files if we are talking about a daemon.
  2. Whenever we run a program from a snap, there is a point when snap-confine is called, which in turn runs the program. This executable has setuid set. This means that by default, a core dump will not be generated if one of its children crashes. To override this, you must set properly a kernel variable called suid_dumpable, for instance by doing
    sudo sh -c 'echo 1 > /proc/sys/fs/suid_dumpable'
  3. Last, you need to make sure that the core file will be written to a folder where the snap can write. If you want to get a core of a snap called, say, my-snap, to make sure that it will be possible to write the file, you will have to modify core_pattern (temporarily) with something like
    sudo sh -c 'echo /home/<my-user>/snap/my-snap/core > /proc/sys/kernel/core_pattern

HTH

7 Likes