Enabling Coredump in Ubuntu core


I am trying to enable coredump for snaps in UC18.
When I try to set ulimit -c unlimited it is not taking effect.
Also when I try to set the /proc/sys/fs/suid_dumpable set to 1 it fails.
Can I know which interface needs to be used to write /proc/sys/fs.

Also which interface needs to be used to /proc/sys/kernel/core_pattern.

Is there a better way to enable coredump for snaps in general.


AFAIK there are no built in interfaces allow reading core dumps. Given that those are memory dumps of a process all kinds of privileged information may be stored there.

Should we grow such interface, it should allow read access to /var/lib/systemd/coredump/* and quite likely execution of coredumpctl. I don’t think we should allow overriding /proc/sys/kernel/core_pattern and have snaps fight over which one handles the core dumps.

@jdstrand may have some thoughts on whether such interface is feasible and under what conditions.

Allowing snaps to process core dumps in the general case seems a little awkward for the reasons outlined so any interfaces that might be used to support a tooling for processing core dumps would be superprivileged.

OTOH, I think I prefer the current implementation pattern of snap run --<thing> with possible supporting snap set config for the system. Eg, this could be used to set the system ulimit, core_pattern, suid_dumpable, etc. We currently support snap run --gdb, perhaps like with snap run --strace we could support args, eg, snap run --gdb='-c /path/to/core' .... Are there use cases where something like this wouldn’t be sufficient?

Thanks for the details. Let me rephrase my question. Let us say I have a bunch of snaps and also have a managing snap from the same publisher.
All individual snaps would have inbuilt capability to coredump. The Managing snap should have the capability to collect and pass on the coredump to another entity in cloud for remote debugging. Given this requirement, I would like to know how to enable coredump in each snaps from the same publisher. The interfaces required by managing snap to collect them.