How do I find core files for my own code in Ubuntu 20.04?
in this question
The following things are suggested:
ulimit -c unlimited
ulimit -a
to set the limit to something other than zero. It was previously 0 on my system.
No core files after segfault.
So,
sudo systemctl enable apport.service
(though this seems distro-related, not developer related). No corefiles in /var/crash
or working directory after that.
There's also:
sudo sysctl -w kernel.core_pattern=core.%u.%p.%t # to enable core generation
systemctl restart apport # to restore default apport settings
Nothing still.
Looking in /var/log/apport.log
shows
ERROR: apport (pid 34940) Fri Dec 24 11:48:47 2021: executable does not belong to a package, ignoring
Oh good! Ubuntu has disabled core dumps for my own code, destroying a valuable debugging tool.
How can get apport off my back and get core dumps for my own executable?
Got it.
Disable apport
sudo systemctl disable apport
Then, set kernel.core_pattern
sudo sysctl -w kernel.core_pattern=core.%u.%p.%t # to enable core generation
then change ulimit
ulimit -c unknown
Core dump is in the working directory now.
The changes don't persist past reboot (for me).