Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who generate a core dump file? Kernel or glibc?

(Here I'm targeting only Linux)

I'm assuming core is generated by the glibc's default signal handler.

But if I google most of result says OS generate a core dump. If OS generates core, signal handler will be called first (or) core dumped first?

like image 313
Arunprasad Rajkumar Avatar asked Jan 07 '14 10:01

Arunprasad Rajkumar


1 Answers

The kernel itself generates the coredump. See the core handling routines in the linux kernel source here:

http://lxr.linux.no/linux+v3.12.6/fs/coredump.c

If the process receives any of the following signals 1, the kernel responds by attempting a coredump.

#define SIG_KERNEL_COREDUMP_MASK (\
rt_sigmask(SIGQUIT)   |  rt_sigmask(SIGILL)    | \
rt_sigmask(SIGTRAP)   |  rt_sigmask(SIGABRT)   | \
rt_sigmask(SIGFPE)    |  rt_sigmask(SIGSEGV)   | \
rt_sigmask(SIGBUS)    |  rt_sigmask(SIGSYS)    | \
rt_sigmask(SIGXCPU)   |  rt_sigmask(SIGXFSZ)   | \
SIGEMT_MASK  

This coredump is configurable, and can be disabled or controlled in several ways, including the file /proc/sys/kernel/core_pattern, and ulimit. One can also control the delivery of these signals through the signal handling mechanisms.

like image 86
Peter Avatar answered Sep 20 '22 00:09

Peter