mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Matt Wozniski <godlygeek@gmail.com>
To: Matt Wozniski <godlygeek@gmail.com>, musl@lists.openwall.com
Cc: nsz@port70.net
Subject: Re: [musl] Unwinding multithreaded musl applications with elfutils fails
Date: Sat, 1 Apr 2023 22:57:09 -0400	[thread overview]
Message-ID: <CACg5n_P1HxMUqUrt9dF_QmHBuvwp9Sw5GhgXi5Un6CJDssC1dg@mail.gmail.com> (raw)
In-Reply-To: <20230331114009.GF3630668@port70.net>

On Fri, Mar 31, 2023 at 7:40 AM Szabolcs Nagy <nsz@port70.net> wrote:
>
> * Matt Wozniski <godlygeek@gmail.com> [2023-03-30 22:43:28 -0400]:
> > Using the elfutils eu-stack program or libdw's dwfl_getthread_frames
> > API to unwind multithreaded applications linked against musl libc on
> > x86-64 fails, getting stuck on `__clone`:
>
> musl has limited cfi debug info support (target specific), likely the
> unwinder needs a
>
>   .cfi_undefined rip
>
> in the clone start function to know where the stack frames end.
...
> musl supports building things without any cfi debug info since c
> does not require unwind support, but linux systems nowadays assume
> unwind tables are part of the platform abi so musl based distros
> should probably include it.
...
> musl does not guarantee frame-pointers either

So, if I understand what you're saying correctly: musl itself doesn't
guarantee the ability to unwind through it at all (neither using DWARF
unwind tables nor using frame pointers), but musl based distros like
Alpine ought to include proper unwind tables. Does that mean that you
don't consider the lack of CFI for `__clone` a defect in musl, but
that it's still worth reporting to the Alpine musl maintainers as a
defect in Alpine's musl build?

If so, what would distro maintainers have to do in order to remedy
that defect? Would it be patches to the (target specific) `clone.s` to
add appropriate CFI when building musl for the distro?

> (it could figure out the end with the same heuristic that gdb uses,
> but apparently elfutils is not smart enough).
>
> some backtracers may want cleared frame-pointer (rbp=0) to detect
> the end.
...
> rbp=0 may be the reason why backtrace in the main thread works, so it
> may be enough to do that in threads too.

And it sounds like both of these are workarounds that elfutils might
be able to pursue in the absence of correct unwind information built
into musl itself. Thanks, that gives a useful direction to dig in.

Thanks for the reply!

  reply	other threads:[~2023-04-02  2:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  2:43 Matt Wozniski
2023-03-31 11:40 ` Szabolcs Nagy
2023-04-02  2:57   ` Matt Wozniski [this message]
2023-04-03 16:14     ` Szabolcs Nagy

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=CACg5n_P1HxMUqUrt9dF_QmHBuvwp9Sw5GhgXi5Un6CJDssC1dg@mail.gmail.com \
    --to=godlygeek@gmail.com \
    --cc=musl@lists.openwall.com \
    --cc=nsz@port70.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).