Date: Wed, 6 Oct 2021 23:08:02 -0400 From: Kurt Hackenberg <kh@panix.com> To: questions@freebsd.org Subject: Re: How do I get a coredump file from an application? Message-ID: <YV5kktlieKXBTmVM@rain.home> In-Reply-To: <CAAdA2WOviDitn6NJiAEgc65XzyK30Zd3Xq8K1NiWqDTeWjLj6g@mail.gmail.com> References: <CAAdA2WPSfnbWLi3FZYmqONCYGg_7wgEObq8TzKbaY-cd8G13yw@mail.gmail.com> <ba885bec-33e7-c935-3a3a-b6138e4f7447@panix.com> <CAAdA2WOviDitn6NJiAEgc65XzyK30Zd3Xq8K1NiWqDTeWjLj6g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--GRouKV0dixOUsezT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --GRouKV0dixOUsezT Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="segv.c" /* cause SIGSEGV (segmentation violation) by using an invalid address */ int main(int argc, char *argv[], char *envp[]) { int *badptr = (int *)(~0UL); *badptr = 0; return 0; } --GRouKV0dixOUsezT Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="catch_segv.c" /* Demonstrate how to catch SIGSEGV (segmentation violation, bad address). */ #include <signal.h> #include <stdio.h> #include <stdlib.h> static void sighdlr(int sig) { printf("SIGSEGV\n"); exit(0); } int main(int argc, char *argv[], char *envp[]) { int *badptr = (int *)(~0UL); /* invalid address */ if (signal(SIGSEGV, sighdlr) != SIG_ERR) *badptr = 0; /* do the bad thing */ else perror("signal()"); return 0; } --GRouKV0dixOUsezT--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YV5kktlieKXBTmVM>