'Can't choose core dump location other than /tmp
I'm working with an Azure pipeline running on an Ubuntu 20.04 agent. I want to capture a core dump because the app I'm developing is crashing. I've done this:
ulimit -c unlimited
sudo service apport stop
sudo sysctl kernel.core_pattern=$(Agent.TempDirectory)/coredump.%e.%s.%t
When the process crashes I see Segmentation fault
- no dumps are generated. If I change the pattern to refer to /tmp/coredump.%e.%s.%t
then it says Segmentation fault (core dumped)
- but in this case I can't access the files in that directory (no permission on Azure). /tmp
is the only directory I can dump to, but I can't access it.
I've replicated this issue on my local Ubuntu VM - there are dumps in /tmp
in the second case, but the app doesn't crash in the same way locally, so this doesn't help. Any other directory, and the dump fails.
Anyone know how I can get out of this Catch22?
Solution 1:[1]
• In the first case, the dump files were stored in ‘/tmp’ directory on Ubuntu 20.04 Azure VM but you were not able to access them. It is because core dumps are handled by ‘Apport’ process, and it is by default disabled in stable releases. Thus, would suggest you to please enable the ‘Apport’ process by the below command and the dumps can be found in ‘/var/crash/’ path.
sudo systemctl enable apport.service
• Once done, would suggest you to please execute the below command such that you will be able to access the core dump files at the location as desired by you on the Ubuntu Azure VM. This command allows you to set the location of core dumps by editing the ‘/etc/sysctl.conf’ file. Also, please check the core dumps at ‘/var/lib/apport/coredump/’ path location as after enabling the ‘Apport’ service, the dumps would probably be stored there.
sudo sysctl -w kernel.core_pattern=/var/crash/core-%e.%p.%h.%t
• The above commands when executed should enable you to access the core dump at the above specified location. For checking how the core dumps are handled by the kernel, execute the below command: -
$ cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport %p %s %c
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | KartikBhiwapurkar-MT |