Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBacktrace does not include file and line number on non-Linux platforms #24346
Comments
This was referenced Apr 12, 2015
This comment has been minimized.
This comment has been minimized.
|
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()
}
|
This comment has been minimized.
This comment has been minimized.
|
I'm using rustc 1.0.0-nightly (6436e34 2015-04-08) (built 2015-04-08) on OS X 10.10.3. |
alexcrichton
added
the
O-macos
label
Apr 13, 2015
This comment has been minimized.
This comment has been minimized.
nareix
commented
May 21, 2015
|
rustc 1.2.0-nightly (0cc99f9 2015-05-17) (built 2015-05-17) in OS X 10.9.4 won't print line number. |
TimNN
referenced this issue
Aug 10, 2015
Closed
stack trace line numbers are missing on macos #25677
This comment has been minimized.
This comment has been minimized.
FredrikNoren
commented
Sep 27, 2015
|
|
jdm
added
the
I-papercut
label
Sep 27, 2015
This comment has been minimized.
This comment has been minimized.
|
Any news on this? |
This was referenced Nov 7, 2015
This comment has been minimized.
This comment has been minimized.
FredrikNoren
commented
Dec 8, 2015
|
Looks like this has gotten even worse lately; type names seem to get mangled now. For instance I get this:
for a regular |
This comment has been minimized.
This comment has been minimized.
coriolinus
commented
Dec 22, 2015
|
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. |
This comment has been minimized.
This comment has been minimized.
OllyGinger
commented
Dec 26, 2015
|
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 |
This comment has been minimized.
This comment has been minimized.
|
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)? |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@TimNN OSX support for filename and line numbers is unimplemented - the dladdr-based implementation here calls to |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@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! |
mbrubeck
changed the title
Backtrace does not include file and line number
Backtrace does not include file and line number on Mac OS
Apr 21, 2016
mbrubeck
changed the title
Backtrace does not include file and line number on Mac OS
Backtrace does not include file and line number on non-Linux platforms
May 9, 2016
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
korczis
commented
Jun 1, 2016
•
|
So what is the plan with this? Is there any ETA? |
This comment has been minimized.
This comment has been minimized.
|
@korczis Someone who feels sufficiently motivated will have to track down the appropriate libraries/APIs on Windows, OSX, BSD, etc and integrate them. |
This comment has been minimized.
This comment has been minimized.
|
As @emoon saying, lldb can do it. Thanks. rust-lang/rfcs#1669 is relatived. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@JohnColanduoni holy cow that's awesome! I think we'd definitely be up to merge that as soon as it's ready! Also if you're feeling inspired you could try upstreaming a local soundness fix as well :) |
This comment has been minimized.
This comment has been minimized.
And this one as well 55e2b7e#diff-29b9b4427b4e6fd7450b277c2bc4fed5 libbacktrace accepting GitHub pull requests is something new (?) |
This comment has been minimized.
This comment has been minimized.
beatgammit
commented
Feb 22, 2017
|
This discussion has mostly been about MacOSX, but does anyone know where to start looking on FreeBSD (and probably other BSDs)? I use FreeBSD for my production servers, and it would be very nice to have this working on that platform. I'll poke around, but it would be nice if someone could give mea hint as to where to start. |
This comment has been minimized.
This comment has been minimized.
|
IIRC the issue with the BSDs is that there are some memory safety concerns about how libbacktrace handles malformed DWARF data, and the ability for an attacker to manipulate current_exe on those platforms (see here). libbacktrace supports ELF already, so it's not an issue on that side of things. |
This comment has been minimized.
This comment has been minimized.
lilith
commented
Mar 1, 2017
|
Line numbers are important to my development process. If I didn't have a linux box, I'd be dead in the water with Rust right now (particularly given my use of closures). I'm confused as to why this is labeled I-papercut. Is anyone here still using OS X, and if so, what tools are you using to mitigate this? How do you debug? I must be missing something. |
This comment has been minimized.
This comment has been minimized.
|
I use a debugger to debug. The third party backtrace crate can produce line numbers on OSX, though it seems to be a bit unreliable on whether that actually ends up working. |
This comment has been minimized.
This comment has been minimized.
|
Specifically, break on Also, prefer That's not to say that this isn't a large drain on productivity. |
This comment has been minimized.
This comment has been minimized.
lilith
commented
Mar 1, 2017
|
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 |
This comment has been minimized.
This comment has been minimized.
|
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 |
jdm
referenced this issue
Mar 3, 2017
Closed
9.1 says there are line numbers in the backtrace, but it's lying #497
This comment has been minimized.
This comment has been minimized.
lilith
commented
Mar 9, 2017
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
lilith
commented
May 22, 2017
|
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. |
This comment has been minimized.
This comment has been minimized.
|
@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. |
Mark-Simulacrum
added
the
O-android
label
Jun 25, 2017
This comment has been minimized.
This comment has been minimized.
lilith
commented
Jul 22, 2017
|
@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. |
This comment has been minimized.
This comment has been minimized.
+1 Another workaround I'm currently using is the trace-error crate. There are caveats though:
|
Mark-Simulacrum
added
C-bug
and removed
I-papercut
labels
Jul 22, 2017
JohnColanduoni
referenced this issue
Jul 23, 2017
Closed
Add libbacktrace support for Apple platforms #43422
kennytm
referenced this issue
Aug 2, 2017
Merged
RFC: Implicit caller location (third try to the unwrap/expect line info problem) #2091
bors
added a commit
that referenced
this issue
Aug 10, 2017
mbrubeck
referenced this issue
Oct 25, 2017
Merged
Add libbacktrace support for Apple platforms (resubmitted) #44251
This comment has been minimized.
This comment has been minimized.
|
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? |
This comment has been minimized.
This comment has been minimized.
nbigaouette-eai
commented
Dec 20, 2018
|
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!");
}
|
This comment has been minimized.
This comment has been minimized.
|
Yeah, I think this has been fixed for a while. |
kornelski commentedApr 12, 2015
•
edited
When a Rust program run with
RUST_BACKTRACE=1panics 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.