Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210716155735.GC13220@brightrain.aerifal.cx>
Date: Fri, 16 Jul 2021 11:57:35 -0400
From: Rich Felker <dalias@...c.org>
To: Timo Teras <timo.teras@....fi>
Cc: musl@...ts.openwall.com
Subject: Re: option to enable eh_frame

On Fri, Jul 16, 2021 at 12:16:25PM +0300, Timo Teras wrote:
> Hi,
> 
> This has been discussed few times, and I know there are arguments also
> not to do this. But at this time we at Alpine think the reasons to keep
> eh_frame outweight the reasons to not include it.

As explained on the tracker issue, what you'r requesting is a patch to
make a configure option that changes the public interface contract of
musl, making different interface contract profiles. This is not a
change to be made lightly. There has been *some* consideration in the
past for accepting this kind of option in the opposite direction:
omitting large functionality that might not be needed in some contexts
(like iconv), but where the default is to have it and omitting it is
just a choice particular users can make for working in a very
constrained environment. But if you add the option, you're essentially
making "having it" the de facto default, even if configure has
"disable" as the default. Once something is using it, there's an
implicit requirement to have it.

Honestly, proposing that it always be available (or configurable but
on by default) would be less controversial than a configure option.
I'd still be against it but at least some of the badness is gone.

> Main arguments against .eh_frame being:
> 
> 1) Having .eh_frame makes it seem like C++ exception throwing works
>    through C-library functions (e.g. throwing exception form qsort
>    callback to return over qsort back to application).
> 
>    Counter arguments:
>    - C++ exceptions is just one way to jump through musl functions.
>      E.g. setjmp/longjmp can do that just fine even without .eh_frame
> 
> 2) Having application unwind itself for backtrace printing purposes
>    especially in signal handler is bad. This is agreed, but there's
>    still other cases when unwinding is good for debugging, and other
>    reasons. The fix for this root cause is to remove the unwinding from
>    signal handlers.

The debugger already can do debugging/unwinding because it has access
to the debug information (if you've installed it) and there is a
clear, understood-by-users contract that this information is not an
inherent part of the program but something optional for external
debugging tools only.

> Arguments to have .eh_frame:
>  - It allows debugging things even if musl-dbg is not or cannot be
>    installed for some reason (e.g. gdb, valgrind), or is no longer
>    available
>  - libunwind/libexecinfo will start to work and give meaningful
>    backtraces

This is explicitly a reason not to. backtrace() considered harmful.

>  - Continuous kernel based profiling (e.g. perf record -g dwarf) will
>    work

This already works if you have debug info.

> Given that the main arguments against are either making UB crash, or
> not the best fix, and keeping eh_frame enables useful features to work,
> I think it would make sense to allow enabling it.
> 
> Please consider the the attached patch to make it a configure option to
> enable keeping eh_frame (defaulting still to not keeping it).

You can solve this problem just as well for the things you want to
have work by including the (part of) the debug info you want in the
main libc.so binary: .debug_frame. Of course I can't stop Alpine from
doing it in a different way locally, but I would strongly recommend
you do that rather than making a contract that diverges from musl.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.