Skip to content

Use gimli instead of libbacktrace by default #189

Closed
@alexcrichton

Description

@alexcrichton

This issue is intended to track the switch from the C library libbacktrace by default on many platforms to using Gimli by default on these platforms to symbolicate a backtrace. The rationale for this is that the C library libbacktrace has had a number of security issues historically and we're including it in every single Rust binary by default on relevant platforms (in libstd), so correctness is quite important to us.

Platforms that use libbacktrace by default are:

  • MinGW Windows.
  • macOS (when built in libstd, in the crate coresymbolication is on by default).
  • Linux / other cfg(unix) targets.

The usage of libbacktrace is relatively simple. We're either consulting the debuginfo, if available, what the symbol name for an address is or we're consulting the dynamic symbol table (aka dladdr on Unix, but I don't think this is exactly how libbacktrace gets its).

There's one caveat in our usage of libbacktrace in that we have to manually feed in a filename for the current executable to libbacktrace for macOS/Windows platforms. For other Unix platforms I think it finds it through the dynamic library iteration APIs in libc.

Another final caveat is that to fully replace libbacktrace all of the support we use for gimli must be #![no_std]. That way it can be included into the standard library, and the standard library can't depend on itself!

Today the gimli-symbolize feature of this crate actually doesn't depend on gimli at all but rather goes through external crates like addr2line, findshlibs, and memmap. I suspect that we'll probably need to drop the dependencies on findshlibs and memmap in favor of manually calling the libc APIs here, but if we can work around that it would be great! Note, though, that we don't need full featured platform support in these crates.

I think the best thing to do is to probably read up on how libbacktrace acquires debug information to parse. I think it's quite different for Windows/Mac/Linux but I suspect it's relatively straightforward and shouldn't really require that much of libstd/crates.io.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gimliRelated to the gimli implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions