From: Milian Wolff <milian.wolff@kdab.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
namhyung@kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho <acme@kernel.org>
Subject: Re: Broken dwarf unwinding - wrong stack pointer register value?
Date: Tue, 23 Oct 2018 12:34:08 +0200 [thread overview]
Message-ID: <2086866.px82jjA6i7@agathebauer> (raw)
In-Reply-To: <20181023040356.GA6218@tassilo.jf.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3681 bytes --]
On Dienstag, 23. Oktober 2018 06:03:56 CEST Andi Kleen wrote:
> > So what if my libm wasn't compiled with -fasynchronous-unwind-tables? We
>
> It's default (64bit since always and 32bit now too) Unless someone disabled
> it.
Excellent, good to know. Since [1] doesn't explicitly disable it, I would
assume the information should be available.
[1]: https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?
h=packages/glibc
> However libm might be partially written in assembler and hand written
> assembler often has problems with unwind tables because the programmer has
> to get them correct explicitely.
Yes, that could be the case. I'm unsure about the glibc build system and what
actually gets compiled, but I found a potential source at [2]:
[2]: https://github.com/bminor/glibc/blob/
43b1048ab9418e902aac8c834a7a9a88c501620a/sysdeps/ieee754/dbl-64/e_hypot.c
I believe this is what is used on my system, since I can spot calls to
__issignaling@@GLIBC_2.18 etc. in the disassembly of __hypot_finite ([3]),
which matches the sources referenced in [2].
[3]: https://paste.kde.org/poywa7y2z
If [2] is used, then it's not hand written assembler but code compiled by the
compiler. So unwinding should work, even from the prologue?
I have since also figured out how to dump the .eh_frame contents in a human
readable format via readelf. Remember, __hypot_finite on my system is at
offset 0x29660 of libm, so I think the following are the corresponding
.eh_frame contents:
```
$ readelf --debug-dump=frames /usr/lib/libm.so.6 |& less
...
00002b60 000000000000004c 00002b64 FDE cie=00000000
pc=0000000000029660..00000000000299ce
DW_CFA_advance_loc: 6 to 0000000000029666
DW_CFA_def_cfa_offset: 16
DW_CFA_offset: r13 (r13) at cfa-16
DW_CFA_advance_loc: 2 to 0000000000029668
DW_CFA_def_cfa_offset: 24
DW_CFA_offset: r12 (r12) at cfa-24
DW_CFA_advance_loc: 1 to 0000000000029669
DW_CFA_def_cfa_offset: 32
DW_CFA_offset: r6 (rbp) at cfa-32
DW_CFA_advance_loc: 6 to 000000000002966f
DW_CFA_def_cfa_offset: 40
DW_CFA_offset: r3 (rbx) at cfa-40
DW_CFA_advance_loc: 29 to 000000000002968c
DW_CFA_def_cfa_offset: 80
DW_CFA_advance_loc2: 291 to 00000000000297af
DW_CFA_remember_state
DW_CFA_def_cfa_offset: 40
DW_CFA_advance_loc: 5 to 00000000000297b4
DW_CFA_def_cfa_offset: 32
DW_CFA_advance_loc: 1 to 00000000000297b5
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 2 to 00000000000297b7
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 2 to 00000000000297b9
DW_CFA_def_cfa_offset: 8
DW_CFA_advance_loc: 7 to 00000000000297c0
DW_CFA_restore_state
DW_CFA_advance_loc1: 88 to 0000000000029818
DW_CFA_remember_state
DW_CFA_def_cfa_offset: 40
DW_CFA_advance_loc: 1 to 0000000000029819
DW_CFA_def_cfa_offset: 32
DW_CFA_advance_loc: 1 to 000000000002981a
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 2 to 000000000002981c
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 2 to 000000000002981e
DW_CFA_def_cfa_offset: 8
DW_CFA_advance_loc: 18 to 0000000000029830
DW_CFA_restore_state
DW_CFA_nop
```
I notice that this does not touch the rsp register at all, even though it's
mutated by the code, leading to the issue. See again this paste for the
disassembly at [3], and note that the broken sample frame points at
0x0000000000029688 <+40>: sub $0x28,%rsp
Can someone at least confirm whether unwinding from a function prologue via
.eh_frame (but without .debug_frame) should actually be possible?
Thanks
--
Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3826 bytes --]
next prev parent reply other threads:[~2018-10-23 10:34 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-20 22:39 Broken dwarf unwinding - wrong stack pointer register value? Milian Wolff
2018-10-21 20:32 ` Milian Wolff
2018-10-22 10:35 ` Milian Wolff
2018-10-22 11:17 ` Milian Wolff
2018-10-22 13:58 ` Andi Kleen
2018-10-22 19:26 ` Milian Wolff
2018-10-23 4:03 ` Andi Kleen
2018-10-23 10:34 ` Milian Wolff [this message]
2018-10-24 14:48 ` Andi Kleen
2018-10-30 22:34 ` Milian Wolff
2018-11-01 22:08 ` PEBS level 2/3 breaks dwarf unwinding! [WAS: Re: Broken dwarf unwinding - wrong stack pointer register value?] Milian Wolff
2018-11-02 11:26 ` Jiri Olsa
2018-11-02 17:56 ` Milian Wolff
2018-11-05 20:51 ` Jiri Olsa
2018-11-05 22:54 ` Milian Wolff
2018-11-06 0:10 ` Andi Kleen
2018-11-06 8:39 ` Jiri Olsa
2018-11-06 17:26 ` Andi Kleen
2018-11-06 20:04 ` Milian Wolff
2018-11-06 20:24 ` Andi Kleen
2018-11-07 22:41 ` Milian Wolff
2018-11-08 12:41 ` Milian Wolff
2018-11-09 0:55 ` Andi Kleen
2018-11-09 0:54 ` Andi Kleen
2018-11-10 21:42 ` Travis Downs
2018-11-11 1:07 ` Andi Kleen
[not found] ` <CAOBGo4zirLiKX8VcROAE=kAD0+qkF0E-cBv9DtBiQr=_obDv5w@mail.gmail.com>
2018-11-11 2:54 ` Travis Downs
2018-11-12 3:26 ` Andi Kleen
2018-11-14 13:20 ` Milian Wolff
2018-11-15 2:05 ` Travis Downs
2018-11-15 9:10 ` Milian Wolff
2018-11-15 19:00 ` Andi Kleen
2018-11-15 2:15 ` Travis Downs
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=2086866.px82jjA6i7@agathebauer \
--to=milian.wolff@kdab.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
/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).