From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8380 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: _Unwind_Backtrace crashes Date: Thu, 27 Aug 2015 22:00:06 +0200 Message-ID: <20150827200005.GF3609@port70.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1440705628 22947 80.91.229.3 (27 Aug 2015 20:00:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Aug 2015 20:00:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8392-gllmg-musl=m.gmane.org@lists.openwall.com Thu Aug 27 22:00:21 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZV3LQ-000805-8A for gllmg-musl@m.gmane.org; Thu, 27 Aug 2015 22:00:20 +0200 Original-Received: (qmail 28033 invoked by uid 550); 27 Aug 2015 20:00:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28010 invoked from network); 27 Aug 2015 20:00:18 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:8380 Archived-At: * Andy Lutomirski [2015-08-27 11:55:24 -0700]: > This works on glibc. It aborts on musl on i386 using the latest git version. > > I suspect it's because whatever calls main isn't properly annotated, > but I don't know how to debug this without rebuilding gcc, which is > kind of a mess. > > #define _GNU_SOURCE > > #include > #include > #include > #include > #include > #include > > static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *), > int flags) > { > struct sigaction sa; > memset(&sa, 0, sizeof(sa)); > sa.sa_sigaction = handler; > sa.sa_flags = SA_SIGINFO | flags; > sigemptyset(&sa.sa_mask); > if (sigaction(sig, &sa, 0)) > err(1, "sigaction"); > } > > _Unwind_Reason_Code trace_fn(struct _Unwind_Context * ctx, void *opaque) > { you might want to add dprintf(1, "ip: %16p cfa: %16p\n", (void*)_Unwind_GetIP(ctx), (void*)_Unwind_GetCFA(ctx)); here, so you see if trace_fn is called at all (and s/printf/dprintf/g so you see what is printed before the crash) > return _URC_NO_REASON; > } > > static void sigusr1(int sig, siginfo_t *info, void *ctx_void) > { > printf("In signal handler. Trying to unwind.\n"); > _Unwind_Backtrace(trace_fn, 0); > } > > int main() > { > printf("Unwind directly\n"); > _Unwind_Backtrace(trace_fn, 0); > > printf("Unwind from signal handler\n"); > sethandler(SIGUSR1, sigusr1, 0); > raise(SIGUSR1); > > printf("OK\n"); > } > > > -- > Andy Lutomirski > AMA Capital Management, LLC