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

Produce backtraces for miri internals #280

Merged
merged 8 commits into from
Aug 3, 2017
Merged

Produce backtraces for miri internals #280

merged 8 commits into from
Aug 3, 2017

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Aug 2, 2017

fixes #251

oli-obk added 3 commits August 2, 2017 16:59
before we built in debug mode for testing,
but then installed miri, which builds in release mode.

So we built in release mode anyway but tested slowly in debug mode
@@ -192,7 +228,7 @@ impl<'tcx> Error for EvalError<'tcx> {
TypeNotPrimitive(_) =>
"expected primitive type, got nonprimitive",
ReallocatedWrongMemoryKind(_, _) =>
"tried to reallocate memory from one kind to another",
"tried to EvalErrorKindreallocate memory from one kind to another",
Copy link
Member

Choose a reason for hiding this comment

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

This looks like an accidental edit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

regex replacements :/ good catch

#[macro_export]
macro_rules! err {
($($tt:tt)*) => { Err($crate::interpret::EvalErrorKind::$($tt)*.into()) };
}
Copy link
Member

Choose a reason for hiding this comment

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

What about moving this to error.rs? I think it'd make more sense to have it there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

macro ordering is important. If we move it to error.rs, we need to ensure that the mod error is the first one in the list, otherwise the modules above don't get the macro.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. I did not know that. I got used to ordering not mattering in Rust. ;)

Copy link
Member

Choose a reason for hiding this comment

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

macros 2.0 will solve it.

#[cfg(debug_assertions)]
const MIRI_PATH: &str = "target/debug/miri";
#[cfg(not(debug_assertions))]
const MIRI_PATH: &str = "target/release/miri";
Copy link
Member

Choose a reason for hiding this comment

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

Can't you use -C debug-assertions to enable debug assertions in a release build? In that case this may use an outdated binary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know how else to make this distinction

Copy link
Member

Choose a reason for hiding this comment

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

I pushed a commit that hopefully should fix this. (#rust IRC channel was very helpful :) )

});
});
true
});
Copy link
Member

Choose a reason for hiding this comment

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

The backtrace crate also has this type which just captures the entire backtrace at once:
http://alexcrichton.com/backtrace-rs/backtrace/struct.Backtrace.html
Why did you end up doing the more manual capturing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because... reasons... I'll use that one instead xD

#[cfg(not(debug_assertions))]
const MIRI_PATH: &str = "target/release/miri";
fn miri_path() -> String {
format!("target/{}/miri", env!("PROFILE"))
Copy link
Member

Choose a reason for hiding this comment

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

You can do this with const and concat!("target/", env!("PROFILE"), "/miri").

Copy link
Member

Choose a reason for hiding this comment

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

Ah, nice. Will do.

fn miri_path() -> String {
format!("target/{}/miri", env!("PROFILE"))
const fn miri_path() -> &'static str {
concat!("target/", env!("PROFILE"), "/miri")
Copy link
Member

Choose a reason for hiding this comment

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

You don't need a const fn. You can use a plain const.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, right. Done.

@oli-obk oli-obk merged commit 726b027 into master Aug 3, 2017
@oli-obk oli-obk deleted the archeology branch August 3, 2017 21:02
@RalfJung
Copy link
Member

RalfJung commented Aug 4, 2017

This has incurred a HUGE performance regression in validation mode. There, we frequently generate an Err and catch it again, and it seems capturing a backtrace is extremely expensive.

@RalfJung
Copy link
Member

RalfJung commented Aug 4, 2017

Probably resolving symbols takes a while; this could involve loading debug info and whatnot. I suppose we will, after all, have to switch to the more low-level API you used first.

@oli-obk
Copy link
Contributor Author

oli-obk commented Aug 4, 2017

Let's get rid of the captures then. They aren't pretty anyway.

@oli-obk
Copy link
Contributor Author

oli-obk commented Aug 4, 2017

I resolve symbols on the low level API, too. Alternatively we can just capture the stack frame pointers, but I think fixing the captures is cleaner

@RalfJung
Copy link
Member

RalfJung commented Aug 4, 2017

Wait but capturing them was the entire point wasn't it? Also see rust-lang/backtrace-rs#30. We can delay resolving until printing.

@RalfJung
Copy link
Member

RalfJung commented Aug 4, 2017

To further improve performance, we could check RUST_BACKTRACE and only actually capture and print anything if it is non-empty.

@eddyb
Copy link
Member

eddyb commented Aug 4, 2017

@oli-obk error-chain checks RUST_BACKTRACE, you should've just used that, lol.

@RalfJung
Copy link
Member

RalfJung commented Aug 4, 2017

I am now going back to @oli-obk's original approach, plus checking RUST_BACKTRACE, plus delaying symbol resolution until printing.

@oli-obk
Copy link
Contributor Author

oli-obk commented Aug 4, 2017

@eddyb error-chain is hard to integrate with our system due to the extensibility of the error via the machine. I have not found a way to make error-chain create a generic error type

@RalfJung
Copy link
Member

RalfJung commented Aug 4, 2017

See #283.

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.

Provide inner (miri) backtraces
3 participants