Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What component actually dumps core?

Tags:

coredump

I am unsure whether this is the C library or some other stuff which dumps contents to core file and make a program Exit. What i mean here is that is the glibc or libc handles the SIGSEGV and creates the core dump in the handler function ? Please explain.

like image 316
Amit Avatar asked Apr 12 '26 03:04

Amit


2 Answers

In linux, the kernel process execution and signal handling mechanisms are responsible.

http://lxr.linux.no/#linux+v2.6.32/fs/exec.c#L1752

void do_coredump(long signr, int exit_code, struct pt_regs *regs)
    {
    ...

http://lxr.linux.no/#linux+v2.6.32/kernel/signal.c#L1926

            if (sig_kernel_coredump(signr)) {
                    if (print_fatal_signals)
                            print_fatal_signal(regs, info->si_signo);
                    /*
                     * If it was able to dump core, this kills all
                     * other threads in the group and synchronizes with
                     * their demise.  If we lost the race with another
                     * thread getting here, it set group_exit_code
                     * first and our do_group_exit call below will use
                     * that value and ignore the one we pass it.
                     */
                    do_coredump(info->si_signo, info->si_signo, regs);
like image 54
Joe Koberg Avatar answered Apr 17 '26 14:04

Joe Koberg


When there's no other handler, the kernel will generate the core file if ulimit -c is greater than 0 for the process.