Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable backtrace feature in the generated Xargo.toml #1589

Merged
merged 1 commit into from
Oct 21, 2020

Conversation

Aaron1011
Copy link
Member

This allows the normal std panic hook to print a backtrace if
RUST_BACKTRACE=1 and -Z miri-disable-isolation are set

README.md Outdated
`RUST_BACKTRACE=1 cargo miri test` will not do what you expect.

To get a backtrace, you need to disable isolation
[using `-Zmiri-disable-isolation`](#miri-flags)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be a flag to pretend that RUST_BACKTRACE=1 is set even when isolation is enabled?

Copy link
Member Author

@Aaron1011 Aaron1011 Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could - do you think that wanting to opt-out of isolation only for RUST_BACKTRACE is a common usecase?

I think it might be better to add more fine-grained isolation in a separate PR. We could add -Zmiri-env-include=VAR, which would pass through VAR to the emulated program while leaving the isolation mode unaffected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these seem like potentially reasonable next steps, but the PR is useful even without them.

README.md Outdated Show resolved Hide resolved
8: std::rt::lang_start_internal
RUSTLIB/std/src/rt.rs:51:25
9: std::rt::lang_start
RUSTLIB/std/src/rt.rs:65:5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this stacktrace ever changes we'll have to adjust quite a few tests... I can see why you asked for a --bless^^

@Aaron1011 Aaron1011 force-pushed the enable-normal-backtrace branch from f490787 to e73ac8e Compare October 20, 2020 17:48
@Aaron1011
Copy link
Member Author

@RalfJung: I've added an example

README.md Outdated Show resolved Hide resolved
This allows the normal std panic hook to print a backtrace if
`RUST_BACKTRACE=1` and `-Z miri-disable-isolation` are set
@Aaron1011 Aaron1011 force-pushed the enable-normal-backtrace branch from e73ac8e to 05bb560 Compare October 20, 2020 22:28
@RalfJung
Copy link
Member

Thanks! I am surprised that this even works for cross-interpretation; it used to be that backtrace depended heavily on C libraries but I guess we now benefit from all that being replaced by Rust code now. (Or does it avoid even linking in the debug symbol parsing when Miri is used?)

@bors r+

@bors
Copy link
Contributor

bors commented Oct 21, 2020

📌 Commit 05bb560 has been approved by RalfJung

@bors
Copy link
Contributor

bors commented Oct 21, 2020

⌛ Testing commit 05bb560 with merge 496c83e...

@bors
Copy link
Contributor

bors commented Oct 21, 2020

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 496c83e to master...

@bors bors merged commit 496c83e into rust-lang:master Oct 21, 2020
@bjorn3
Copy link
Member

bjorn3 commented Oct 21, 2020

(Or does it avoid even linking in the debug symbol parsing when Miri is used?)

The debuginfo handling has been replaced by addr2line on non-Windows systems by default for a while now. (rust-lang/backtrace-rs#324) One of the reasons for this switch was:

Secondarily, it means this library no longer needs a C compiler. Being an all-Rust crate generally makes it much easier to cross-compile, port, etc.

@RalfJung
Copy link
Member

It seems to work even for Windows though. :)

@bjorn3
Copy link
Member

bjorn3 commented Oct 21, 2020

On Windows a system library is used. Because miri doesn't perform any linking, it is fine if that system library turns out to be missing. For unix backtrace-rs used to use libbacktrace, which gets compiled in build.rs, thus requiring a C toolchain for the target platform. Since the switch to gimli it only depends on libunwind for unwinding, which is a system library and also not used for miri anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants