mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: libexecinfo with musl
Date: Wed, 21 Aug 2019 23:07:39 -0400	[thread overview]
Message-ID: <20190822030739.GH9017@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAOrPor=_FVcruEHCi+cD6s4=mdCuSyAshn+vQ64bWZykXbDwcQ@mail.gmail.com>

On Wed, Aug 21, 2019 at 05:32:44PM -0700, Guillaume Quintard wrote:
> Hi,
> 
> Apologies if this has already been answered before, information is a bit
> hard to find on the topic.
> 
> This is what brings me here:
> https://github.com/mikroskeem/libexecinfo/issues/2
> 
> I'm trying to build and run a bigger program (varnish) that requires
> backtrace(), and while it compiles, executing backtrace() results in a
> segfault.

It "requires" backtrace? For actual operation, or for printing stack
traces in the event of a crash? The latter is highly inadvisible as it
increases attack surface dramatically; if it's only needed for the
latter this functionality should just be patched out.

> It looks like the function __builtin_frame_address doesn't really
> do what it should.
> 
> It's apparently a builtin function from the compiler, but I sort of
> understood it also requires some support from the libc. If that's the case,
> would someone care to explain the specifics to help us decide if we should
> just cut the backtrace() feature from varnish on musl, or if we should work
> towards feature parity.

backtrace should not require any "support from libc". My guess at
what's happening is that it fails to trace past main's stack frame
back into the call point in libc startup code, since libc lacks unwind
info. A working backtrace implementation needs to be prepared for this
possibility and stop if it reaches back to an address without unwind
info. Perhaps it's trying to use frame pointers instead (also not
present), wrongly misinterpreting non-frame-pointer data in %rbp as a
frame pointer, and blindly following that without validating it...

Rich


  reply	other threads:[~2019-08-22  3:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22  0:32 Guillaume Quintard
2019-08-22  3:07 ` Rich Felker [this message]
2019-08-23 14:21   ` Florian Weimer
2019-08-26 21:56     ` Guillaume Quintard
2019-08-28  8:06       ` Tuan Hoang
2019-08-28 19:07         ` Guillaume Quintard
2019-08-22 17:17 ` Tuan Hoang

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=20190822030739.GH9017@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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.
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).