From nobody Thu Oct 7 03:08:02 2021 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C9E9A12DA6B3 for ; Thu, 7 Oct 2021 03:08:19 +0000 (UTC) (envelope-from kh@panix.com) Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4HPx8y1FFHz4mMK for ; Thu, 7 Oct 2021 03:08:18 +0000 (UTC) (envelope-from kh@panix.com) Received: from rain.home (pool-96-230-243-2.bstnma.fios.verizon.net [96.230.243.2]) by mailbackend.panix.com (Postfix) with ESMTPSA id 4HPx8q04qNz3mbW for ; Wed, 6 Oct 2021 23:08:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=panix.com; s=panix; t=1633576091; bh=A12OEFWtPcovwJt/R0+CJKqoVseB05k/WzU0GAmwLCI=; h=Date:From:To:Subject:References:In-Reply-To; b=RFHbzeq3GjjxSy5cZsehRn6XlR9FQOkB8WShqNCYs4TB85eKWaK+4VS0Zt9zj1S3P kPVgGt1YAmOiFSFMF850gE2SHkzXO63AXHCG3Dt5SuMMEsfrnjiZagpRfc7WDzNr38 qv/h0yesq+yE0yW4zY5Id58DzIZWySi+w181EekI= Date: Wed, 6 Oct 2021 23:08:02 -0400 From: Kurt Hackenberg To: questions@freebsd.org Subject: Re: How do I get a coredump file from an application? Message-ID: References: List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="GRouKV0dixOUsezT" Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4HPx8y1FFHz4mMK X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; dkim=pass header.d=panix.com header.s=panix header.b=RFHbzeq3; dmarc=none; spf=pass (mx1.freebsd.org: domain of kh@panix.com designates 166.84.1.89 as permitted sender) smtp.mailfrom=kh@panix.com X-Spamd-Result: default: False [1.11 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[166.84.1.89:from]; R_SPF_ALLOW(-0.20)[+ip4:166.84.1.64/26]; HAS_ATTACHMENT(0.00)[]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[panix.com:+]; RECEIVED_SPAMHAUS_PBL(0.00)[96.230.243.2:received]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+]; ASN(0.00)[asn:2033, ipnet:166.84.0.0/16, country:US]; SUBJECT_ENDS_QUESTION(1.00)[]; DWL_DNSWL_NONE(0.00)[panix.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.98)[-0.982]; R_DKIM_ALLOW(-0.20)[panix.com:s=panix]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-csrc]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; DMARC_NA(0.00)[panix.com]; MIME_BAD_ATTACHMENT(1.60)[c]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_SPAM_SHORT(0.99)[0.992]; RCVD_IN_DNSWL_NONE(0.00)[166.84.1.89:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] X-ThisMailContainsUnwantedMimeParts: N --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 #include #include 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--