-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add basic backtrace functionality #12070
Conversation
/// print everything as a backtrace. | ||
/// | ||
/// Sadly we don't have filenames/line numbers at this point, but hey, at least | ||
/// this is better than nothing!. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: extra .
Updated with comments (plus a much better test) |
👍 This is a huge win |
let out = p.finish_with_output(); | ||
assert!(!out.status.success()); | ||
let s = str::from_utf8(out.error).unwrap(); | ||
assert!(s.contains("stack backtrace") && s.contains("foo::h")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the ::h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just making sure that we're demangling at least a little bit. Each symbol is of the form path::h<hash>
, so we should be guaranteed that with the foo
function in the backtrace that foo::h
should show up somewhere.
Pushed with comments addressed |
Can we enable backtracing by default? Maybe just for uncaught failure? |
Perhaps, I'm afraid to do this too often, I figured task failure could be semi-normal in some circumstances, so I figured it would be better to opt in instead of opt out. Perhaps we should get some mileage with this added first though. I don't want to overwhelm tests too much with backtraces everywhere if that turns out to be the normal case. |
Hm, it appears that this doesn't seem to be that useful on linux at all. From what I can tell, With this in light, here's a summary of the backtrace methods that I know of:
|
As another option, we could also modify codegen to emit a symbol table into the crate map and we could iterate the crate maps looking for the right symbol. I'm not sure if this can be done super efficiently, but it would in theory be robust enough to get us away from |
Wouldn't it be simpler to build with line number debug info? (the equivalent of the old -Z debug-info option, if that still exists in some form). |
How would debug info help this? The backtrace functionality doesn't need debug info, the only functionality we need is translation from an address to a symbol name. I'm unaware of a lightweight library which does that. Unless we're willing to bundle our own dwarf parser, I'm not sure that debug info would help us much. |
dwarf debug info includes address <-> symbol mapping and it would be the most universal way to get symbol names across all platforms. I think libunwind did so well in your tests because it does parse dwarf debug info. |
Hm, do you know how to get access to this data? I am unaware of any debug info that we emit other than that necessary to unwind a frame on the stack. Does the unwinding api from libgcc_s expose symbol functionality at all? That would be the best way to go about this. |
gcc unwinding code does not do symbol lookup, but it has libbacktrace bundled with it does. But I thought you've already tried libbacktrace (or else what does 'backtrace' above refer to?) |
Ah, by |
I think it's a static lib (I'm talking about his one). |
cc me |
Whenever a failure happens, if a program is run with `RUST_LOG=std::rt::backtrace` a backtrace will be printed to the task's stderr handle. Stack traces are uncondtionally printed on double-failure and rtabort!(). Closes rust-lang#10128
I'm in the process of integrating |
minor: clarify error message Clarify that the server is a whole is OK, and that it's only a single requests that's dead
Fix issue rust-lang#12034: add autofixes for unnecessary_fallible_conversions fixes rust-lang#12034 Currently, the `unnecessary_fallible_conversions` lint was capable of autofixing expressions like `0i32.try_into().unwrap()`. However, it couldn't autofix expressions in the form of `i64::try_from(0i32).unwrap()` or `<i64 as TryFrom<i32>>::try_from(0).unwrap()`. This pull request extends the functionality to correctly autofix these latter forms as well. changelog: [`unnecessary_fallible_conversions`]: Add autofixes for more forms
Whenever a failure happens, if a program is run with
RUST_LOG=std::rt::backtrace
a backtrace will be printed to the task's stderrhandle. Stack traces are uncondtionally printed on double-failure and
rtabort!().
Closes #10128
This PR is an improvement over the previous iteration in a few ways:
I have yet to actually get symbols from backtraces on windows, but at this point I'm convinced that it's something wrong my my VM installation. All documentation and examples I can find point to doing almost exactly what's impemented. The good news is that the only part in question for the windows implementation is the address => symbol translation (stack walking is working just fine).