Core dumps in snapd

In a classic Ubuntu system, to enable core files to be generated when the application crashes we need to run “ulimit -c unlimited”. Is this required to generate core files in the snap environment ?

3 Likes

@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

@jdstrand
Is there a way to enable core dumps on core permanently & properly?

I am helping a customer snap a project and they are getting DENIEDs in the apparmor profile when the core dump tries to use /proc/sys/kernel/core_pattern.

3 Likes

I suspect this might best be handled by a core snap config option. In this manner, the owner of the system or a gadget snap could set this and snaps don’t have to.

If someone wanted to implement a crash handling snap, then we should consider a crash-handler-support interface (name TBD).

2 Likes

We have a customer asking how to enable core dumps. Has there been any progress on this?

This seems to be pretty important for tracking any issues in the production.

1 Like

@sborovkov do you want to implement a crash handing snap? If this is a commercial priority for you, then the other pieces @jdstrand mentioned (core snap config option and crash-handler-support interface) can be considered.

@abeato Regarding your reply in June 2017. It has become important for me to enable core dumps now in a snap which is running in devmode confinement.
Do your comments still apply ?

They apply, although in devmode some steps might not be relevant - but it will not hurt to still do all of them.

2 Likes

Is there any update on this recently. Can we enable coredumps ?

I tried this to retrieve a Chromium core, but it doesn’t seem to work anymore.