Re: How do I get a coredump file from an application?

From: Kurt Hackenberg <kh_at_panix.com>
Date: Thu, 07 Oct 2021 03:08:02 UTC
On Wed, Oct 06, 2021 at 12:37:55PM +0300, Odhiambo Washington wrote:

>And an Exim developer has given me this task - to get Exim to
>create dump.
>I quote him below:
>
>*Arranging one is hard as Exim is setuid.  I've not tried **on a BSD, but
>Linux requires some deliberate relaxation of security*

You said you've already set the sysctl kern.sugid_coredump.

That developer seems to have missed that, apparently, Exim catches the
signal SIGSEGV, which means that signal will never cause a coredump.
You could confirm that Exim catches that signal by searching the
source code for calls to signal() or sigaction(), or for "SIGSEGV", or
for the log string "maybe attempt to write to immutable memory".

If Exim catches that signal, then the only way to get a coredump is to
make Exim not catch that signal -- that is, temporarily remove the
call to signal() or sigaction().

See the man pages signal(3) and sigaction(2).

Attached are two small sample programs that demonstrate a segmentation
violation without and with catching the signal.  When the signal is
not caught, the OS writes a coredump file; when the signal is caught,
no coredump is produced.