-musl
platforms do not include unwind tables for libc
#134592
Labels
C-bug
Category: This is a bug.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
O-musl
Target: The musl libc
T-bootstrap
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
In certain cases, it may be desirable to capture a backtrace from a signal handler which includes stack frames prior to signal handling.
Consider this program, which attempts to demonstrate the problem in a concise way - please note that the actual implementation is more complex, in order to deal with signal safety:
When built for
x86_64-unknown-linux-gnu
, it produces the following output:When built for
x86_64-unknown-linux-musl
, this is the output:Observe that at one point the backtrace walks through
syscall
- while in this instance this is because the same thread issuing the syscall receives the signal, it is conceivable - and quite likely - that any arbitrary thread may be caught making a syscall or otherwise inside of libc if some other thread were to send a signal for such purpose.This is caused by a combination of two similar but technically distinct problems:
rt_sigaction
syscall directly.I have not tracked down the build configuration for the musl platform; however, the second issue should be easily addressable in one of two ways:
Unwind tables are not included in musl because - as best I can guess - there is concern over memory utilization in extreme environments , and because it is further assumed that unwinding through libc is an unlikely case as this will most likely occur when unwinding from a signal handler - already uncommon - and only when the application is one that does unwinding which, while common, is still a subset of libc's consumers.
As backtraces are a first-class component of Rust's error handling design, and because this functionality works as intended and expected on
-gnu
- a Tier 1 platform - it seems reasonable to correct the behavior on-musl
, particularly if it is indeed as straightforward as building without two flags. For users who require to exclude as much as is necessary from compiled artifacts, including unwind tables and the unwinder, it is still possible to strip the exception handling information at a later time -strip
just needs to be configured to remove.eh_frame
or.debug_info
.I can do the work if someone could point me in the direction of build configuration.
The text was updated successfully, but these errors were encountered: