Skip to content

Backtraces stop at thread boundaries #4066

Open
@oli-obk

Description

@oli-obk

When an action is performed that miri cannot handle (or UB is hit), the backtrace shown ends at the start of the thread in which the failure happened. As an example

extern {
    fn unknown();
}

fn bad() { unsafe { unknown() } }

fn main() {
    std::thread::spawn(bad);
}

fails with

error: unsupported operation: can't call foreign function `unknown` on OS `linux`
 --> src/main.rs:5:21
  |
5 | fn bad() { unsafe { unknown() } }
  |                     ^^^^^^^^^ can't call foreign function `unknown` on OS `linux`
  |
  = help: if this is a basic API commonly used on this target, please report an issue with Miri
  = help: however, note that Miri does not aim to support every FFI function out there; for instance, we will not support APIs for things such as GUIs, scripting languages, or databases
  = note: BACKTRACE on thread `unnamed-1`:
  = note: inside `bad` at src/main.rs:5:21: 5:30

pointing solely to the function bad.

In this simple example that is not an issue, but if a crate spawns a thread somewhere in its internals, it may not be clear why the thread is even running. I don't think it would be expensive to collect a backtrace at every thread spawn and store this information in the thread data structure itself (as we're not going through the backtrace crate, but just iterating over miri's stack).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticserrors and warnings emitted by miriC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancementE-good-first-issueA good way to start contributing, mentoring is available

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions