-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Backtrace does not include file and line number on non-Linux platforms #24346
Comments
This does work on some platforms for binaries compiled with debug-info (which E.g. on x86-64 linux, I get: fn foo() {
panic!()
}
fn bar() {
foo()
}
fn main() {
bar()
}
|
I'm using rustc 1.0.0-nightly (6436e34 2015-04-08) (built 2015-04-08) on OS X 10.10.3. |
rustc 1.2.0-nightly (0cc99f9 2015-05-17) (built 2015-05-17) in OS X 10.9.4 won't print line number. |
👍 on this one, sorely needed! |
Any news on this? |
Looks like this has gotten even worse lately; type names seem to get mangled now. For instance I get this:
for a regular |
The results right now in 1.5 are utterly useless: > cargo run
Running `target\debug\day21bin.exe`
thread '<main>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore\option.rs:366
stack backtrace:
0: 0x4517a7 - <unknown>
1: 0x45915e - <unknown>
2: 0x415d1c - <unknown>
3: 0x41648b - <unknown>
4: 0x44e9c2 - <unknown>
5: 0x473cd8 - <unknown>
6: 0x46e130 - <unknown>
7: 0x410530 - <unknown>
8: 0x4107df - <unknown>
9: 0x410a9a - <unknown>
10: 0x410dd4 - <unknown>
11: 0x40153e - <unknown>
12: 0x4587e8 - <unknown>
13: 0x441da1 - <unknown>
14: 0x4586f7 - <unknown>
15: 0x402a0a - <unknown>
16: 0x4013b4 - <unknown>
17: 0x4014e7 - <unknown>
18: 0x7ffaf70a8101 - <unknown>
Process didn't exit successfully: `target\debug\day21bin.exe` (exit code: 101) This is on Windows, but both Powershell and Cygwin64 produce identical results. |
Can confirm on macos 10.10.5 $ rustc --version
rustc 1.5.0 (3d7cd77e4 2015-12-04)
$ rustc -g file_embed.rs
$ RUST_BACKTRACE=1 ./file_embed
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 9, message: "Bad file descriptor" } }', ../src/libcore/result.rs:738
stack backtrace:
1: 0x100ff9b88 - sys::backtrace::tracing::imp::write::h06df28c2a8d245f9t9s
2: 0x100ffb1ef - panicking::log_panic::_<closure>::closure.39451
3: 0x100ffac92 - panicking::log_panic::h9348b1b0af36ae6aCYw
4: 0x100ff52c6 - sys_common::unwind::begin_unwind_inner::h005d402245ebd8560cs
5: 0x100ff53fe - sys_common::unwind::begin_unwind_fmt::h440d2eb18c439fa86bs
6: 0x100ff9217 - rust_begin_unwind
7: 0x1010166b0 - panicking::panic_fmt::h4c8d12e3c05f3b8cZEK
8: 0x100ff3566 - result::_<impl>::unwrap::unwrap::h5984419141872088150
9: 0x100ff2a3d - write_cpp::hf673fd381a899287Gca
10: 0x100ff4340 - main::h35317f0a7a25286cpia
11: 0x100ffaa12 - sys_common::unwind::try::try_fn::h4733637608193038088
12: 0x100ff9058 - __rust_try
13: 0x100ffa8b9 - rt::lang_start::h44a8548d0ff91511KVw
14: 0x100ff4789 - main |
From what I can tell you are the original authors of the line number in backtraces functionality (or at least familiar with the code) so I was wondering if one of you could chime in? I'm most curios about whether the current situation is expected (ie. it is a known deficit of the current implementation) or if things should be working on os x (and thus there may be bug in the implementation)? |
Correction: I do get line numbers on Linux. I no longer have the exact test-case I had before, but an attempt at reproducing it does show line numbers. |
@TimNN OSX support for filename and line numbers is unimplemented - the dladdr-based implementation here calls to |
Bump, also not working for me on OS X 10.11 with yesterday's nightly. The nightly on Gentoo Linux properly displays the line numbers however. Unfortunately I do most of my dev work on my Macbook so this makes debugging very difficult. |
After some investigating this seems to be a limitation of dladdr. dladdr is, as far as I can tell, unable to retrieve the source filename or line number (the filename it gets is the name of the compiled binary, which is not what we're looking for). And, since OS X uses clang by default, GCC's libbacktrace is unavailable on that platform. I'm not sure if there is an implementation similar to libbacktrace that could be used to accomplish this on OS X, but I think that would most likely need to be the approach taken here. |
@TimNN sure, here's a summary of what I know:
Yes it's intentional there is no file/line information on OSX. If there's a library we could use, however, we could consider linking to it! |
I have the same issue on Mac. My work-around is like that this:
Not as nice as to see the filenames directly but better than nothing. |
So what is the plan with this? Is there any ETA? |
@korczis Someone who feels sufficiently motivated will have to track down the appropriate libraries/APIs on Windows, OSX, BSD, etc and integrate them. |
As @emoon saying, lldb can do it. Thanks. rust-lang/rfcs#1669 is relatived. |
So I think that at this point this bug is basically about OSX. I've seen really good backtrace line numbers on MSVC and Linux, so OSX is the only major desktop platform at least left that needs this. @sujayakar has done some awesome work and discovered that the The |
Thanks! I stopped trying to make lldb work with Rust back in October... but lldb stack traces via I'm shipping rust binaries to win/max/linux, so bug reports need good stack traces. Do you mean I shoul use backtrace-rs from |
Yep - here's a hook that should be equivalent to the standard library's format-wise for reference: https://github.com/sfackler/rust-log-panics/blob/master/src/lib.rs#L51 |
@sfackler backtrace-rs (after a few seconds) adds line numbers for the outer crate, but can't seem to resolve line numbers for other (local, debug) crates where most frames are at. Using OS X, nightly-2017-02-04, backtrace 0.3.0. |
To find the dSYM files you can use the DebugSymbols framework. That's what gdb/lldb use. You can find some information about using it here: https://github.com/jrmuizel/dsym-find/blob/master/dsym-find.c |
Is it necessary that we wait for upstream acceptance of libbacktrace patches? OS X has been waiting a while to get good runtime errors, and the workarounds are unreliable. |
@jrmuizel DebugSymbols is a private framework. At that point, we might as well use the private CoreSymbolication framework which will handle the whole process. I've fixed the issues for that pull request. I'd be happy to put together one for the Rust codebase (should be pretty minimal, there's no API changes) if that's acceptable. |
@JohnColanduoni I think such a PR would be great. I'd also love to see this be upgraded from "papercut". I ship server software that other people run; backtraces are crucial. |
+1 Another workaround I'm currently using is the trace-error crate. There are caveats though:
|
Triage: there hasn't been any comments here in a long time, but there has been a ton of changes in the past 18 months. Is this still an issue? |
I've haven't been hit by this since a long time on two macos machines. -> cat src/main.rs
fn main() {
panic!("Hello, world!");
}
|
Yeah, I think this has been fixed for a while. |
Backtraces still do not have line numbers for me (as of 1.36.0-nightly), on macOS 10.12.6. fn main() {
panic!();
}
|
@kornelski: ah, I'm not using |
This is torture. |
I don't get line numbers or filenames in tracebacks from my [lib] crate on Mac 10.14.6, Rust 1.42.0. I am building the crate with There are no .dSYM files in With the same code- Perhaps this issue should be reopened? Happy to provide more information to help track this down. |
When a Rust program run with
RUST_BACKTRACE=1
panics it outputs backtrace which only has function names (with noisy hashes), but doesn't include file names and line numbers.During development (not necessarily in release builds), I'd prefer something like:
Sometimes line numbers are very important, e.g. if the panic is some generic out-of-bounds assertion, and the function uses vectors and slices in many places, just the name is not enough to pinpoint the offending expression.
The text was updated successfully, but these errors were encountered: