From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81010 invoked by alias); 19 Apr 2017 19:48:34 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 80767 invoked by uid 89); 19 Apr 2017 19:48:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=realistic, H*M:180, stuck, trusted X-Spam-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Message-ID: <1492631295.21701.180.camel@klomp.org> Subject: Re: frame unwinding patches From: Mark Wielaard To: Ulf Hermann Cc: elfutils-devel@sourceware.org Date: Wed, 19 Apr 2017 19:48:00 -0000 In-Reply-To: References: <1487201610-8381-1-git-send-email-mark@klomp.org> <3915502.JGE1jdPxOT@milian-kdab2> <75e83a7d-b372-3436-ba7a-3a49900e92dd@qt.io> <20170403211516.GB9584@stream> <1491560851.8380.162.camel@klomp.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.12.11 (3.12.11-22.el7) Mime-Version: 1.0 X-SW-Source: 2017-q2/txt/msg00044.txt.bz2 On Tue, 2017-04-11 at 12:16 +0200, Ulf Hermann wrote: > > I do agree with Jan that frame pointer unwinding is notoriously > > untrustworthy. Even with some sanity checks it is hard to know whether > > you are doing a correct unwind. gdb gets away with it through pretty > > advanced frame sniffers, which take a lot of low-level compiler > > generation knowledge to get correct (and even then...). You only restore > > the pc, stack and frame pointer registers (maybe incorrectly). So > > afterwards, even if you got valid CFI data you might be stuck. >=20 > Yes, especially with mixed stack traces, where part of the stack has > CFI and part of it doesn't, we quickly run into guesswork. I've > regenerated the binaries as suggested, with the result being that > raise() from libc actually has CFI, but doesn't set a frame pointer. > So, the frame pointer unwinder can find raise() in the link register, > but it sets up the FP register with the wrong value. Then raise() is > unwound using CFI, which mixes up the registers some more. At that > point we're lost. I don't see an easy way out of this. That might just mean that the testcase is slightly unrealistic. Getting a reliable backtrace through signal handlers when not having full CFI is probably not something we can expect to work. That doesn't mean having a frame pointer based fallback is a bad thing. We probably should find a more realistic testcase. And maybe in the future add an interface to allow people to unwind through "pure CFI" or mixed mode with frame markers that tell the caller whether the registers can be trusted or not. > I will keep a version of the frame unwinding for perfparser as it's > still better than not unwinding at all, but I do understand that it's > not really suitable for mainline elfutils. Really I do think it would be nice to have. I certainly didn't mean it isn't suitable for mainline. We just should be realistic about the expectations. IMHO if at all possible we should get this upstream so you don't have to carry extra patches. Cheers, Mark