Skip to content

Support generating backtraces in emulated code #1033

Closed
@Aaron1011

Description

@Aaron1011

Once rust-lang/rust#60026 is merged, Miri will have support for panicking via unwinding.

However, we will still lack support for printing backtraces from the panic hook (currently, Miri builds libstd without the backtrace feature, so nothing is printed).

Unlike the implementation of panicking, getting this to work will require modifying a third party-crate. Specifically, we will need to modify backtrace-rs, which is used by libstd to generate backtraces.

This will require Miri to expose some sort of API to the outside world for the first time. At a minimum, backtrace-rs needs a way to get a list of Frames from Miri (the definition of Frame is up to us).

This bring up an interesting question: do we ever want to stabilize this API? For printing panic backtraces, it's sufficient for this API to be unstable - Miri builds libstd using nightly Rust, so we can just enable some internal feature. However, it seems reasonable for third-party crates using backtrace-rs to 'just work' under Miri. This means that whatever mechanism backtrace-rs uses to communicate with Miri will (eventually) need to be stable as well.

One way to go about this would be to have Miri define some special foreign function (e.g. __rust_miri_magic_get_backtrace), rather than an intrinsic. Conceptually, this would make Miri just another target platform, which happens to guarantee the existence of some foreign function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-shimsArea: This affects the external function shimsC-projectCategory: a larger project is being tracked here, usually with checkmarks for individual steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions