From: Ian Rogers <irogers@google.com>
To: "Fāng-ruì Sòng" <maskray@google.com>
Cc: Travis Downs <travis.downs@gmail.com>, linux-perf-users@vger.kernel.org
Subject: Re: Call graph dwarf unwinding fails with lld
Date: Wed, 25 May 2022 20:55:15 -0700 [thread overview]
Message-ID: <CAP-5=fWLH4S7FUrv1pWc0Wk3Amo0qkLOURm0nqQnA8+MhFbR_Q@mail.gmail.com> (raw)
In-Reply-To: <CAFP8O3+KNmZsiiReXXtsWk682Dozs4=QL67k4KbqbX003u37Fg@mail.gmail.com>
On Wed, May 25, 2022 at 1:10 AM Fāng-ruì Sòng <maskray@google.com> wrote:
>
> On Wed, May 25, 2022 at 12:50 AM Ian Rogers <irogers@google.com> wrote:
> >
> > On Tue, May 24, 2022 at 1:50 PM Travis Downs <travis.downs@gmail.com> wrote:
> > >
> > > I have been tracking down an issue locally where `perf record
> > > --call-graph=dwarf` stopped working in the sense that unwinding always
> > > failed.
> > >
> > > Turns out it was related to `lld` - binaries linked with `lld` don't
> > > seem to unwind correctly with `--call-graph=dwarf`. I've confirmed
> > > that the `.eh_frame` sections are there, but I guess they are
> > > different after using this linker.
> > >
> > > Has anyone run into this?
> >
> > I was unaware but thanks for filing the bug!
> >
> > > There's an open LLVM issue at https://github.com/llvm/llvm-project/issues/53156
> > >
> > > ... but no activity since it was filed, though it is not clear if the
> > > problem is really with lld or the unwinders.
> > >
> > > In a related question: perf supports more than one DWARF unwinding
> > > implementation, depending on what libraries are available at build
> > > time, right? Is there a way to select which unwinder is used at
> > > runtime?
> >
> > I don't think so. There are two build options NO_LIBUNWIND=1 and
> > NO_LIBDW_DWARF_UNWIND=1. I played around with the example from the
> > bug, confirmed no difference with the eh_frames and hand verified
> > them, I also added -fno-omit-frame-pointer -O0 and -static. I've not
> > got a good handle on the issue but my suspicion is that the
> > eh_frame_hdr is broken - it is at least something that lld generates.
> > If I change the eh_frame_hdr finding to some findable but unexpected
> > offset like eh_frame here:
> > https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/tools/perf/util/unwind-libunwind-local.c?h=perf/core#n286
> > and then test with a working linker the unwinding is broken similarly
> > to with lld. I was looking for a useful tool (objdump, llvm-objdump,
> > readelf, dwarfdump) to look at the eh_frame_hdr but I didn't see one.
> > Perhaps someone has a suggestion or maybe pahole can do it. Hopefully
> > this gives a lead for you to dig into for the bug.
> >
> > Thanks,
> > Ian
>
> I left a comment on
> https://github.com/llvm/llvm-project/issues/53156#issuecomment-1136777149
> that the perf issue is related to unsupported `ld.lld --rosegments`
> and `ld.bfd -z separate-code` layouts.
Thanks Fangrui! I commented on the bug (thanks for the help!) and I
think the bug is with libunwind assuming that sections are consecutive
in memory, at different offsets, etc. lld is playing games to reduce
file size and ultimately that's broken the perf unwinding. Perhaps
someone can figure out how to better drive libunwind from perf, but I
think it is wrong in its offset assumptions. libdw based unwinding is
no better from my testing, overall this is a fairly major
bug/regression.
Thanks,
Ian
> --
> 宋方睿
next prev parent reply other threads:[~2022-05-26 3:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-24 20:49 Call graph dwarf unwinding fails with lld Travis Downs
2022-05-25 7:50 ` Ian Rogers
2022-05-25 8:10 ` Fāng-ruì Sòng
2022-05-26 3:55 ` Ian Rogers [this message]
2022-05-26 4:16 ` Fangrui Song
2022-05-26 4:25 ` Ian Rogers
2022-05-26 14:39 ` Arnaldo Carvalho de Melo
2022-05-27 6:05 ` Fāng-ruì Sòng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP-5=fWLH4S7FUrv1pWc0Wk3Amo0qkLOURm0nqQnA8+MhFbR_Q@mail.gmail.com' \
--to=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=maskray@google.com \
--cc=travis.downs@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).