Core dump

From vpsget wiki
Jump to: navigation, search

How to switch core dump function between node and container.

File on the node:

/proc/sys/kernel/core_pattern

Original value (dump works on node):

|/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e

Edit the line so the core dump is working inside a container but isn't working on the node:

echo "/var/dump/core.%e.%p.%h.%t" >> /proc/sys/kernel/core_pattern

The /proc/sys/kernel/core_pattern take value on boot from /etc/sysctl.conf

kernel.core_pattern = /var/dump/core.%p

You can always apply values from sysctl.con with next command:

sysctl -p

A code for generating segmentation fail error:

#include <stdio.h>
 
int main()
{
int *null_p = NULL;
*null_p = 10; //write to null pointer memory area,Segmentation fault will happen
return 0;
}

Compile it with gcc:

# gcc seg.c -o seg

Run to test

# ./seg
Segmentation fault (core dumped)

check the /var/dump/ for core file