-
Notifications
You must be signed in to change notification settings - Fork 18
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
RUST_BACKTRACE=full can't find source files if the running application changes its working directory #2
Comments
This appears to be a platform thing. Windows and macOS use absolute pathes while Linux has relative ones. I guess we could do some simple source path discovery using |
Is current_exe the path that the binary is in? I worry that this will break for the binary after its been |
Yes, that would indeed break things. I did a bit of debugging through |
This might be too hacky but I was thinking you could try using https://doc.rust-lang.org/std/macro.option_env.html to read |
Mhh, this would require some pretty complex path discovery logic since you can I think it would be best to just fix libbacktrace. There is some code in there to create abs paths, however it is only used for symbols without line number information. Moving it out of the https://github.com/ianlancetaylor/libbacktrace/blob/master/dwarf.c#L2874 I'll create an issue in libbacktrace in order to figure this out -- if we're lucky, we can just move the abs path code out of the |
Hey, I just want to see where we are at with this issue. I see the comments in the libbacktrace issue you filed and the backtrace-rs issue you recently commented on, particularly about libbacktrace no longer being maintained. I'd love to get this issue and #1 resolved, and I'm interested in contributing PRs to help fix both issues so I can finally start using this wonderful crate. With libbacktrace no longer maintained what do you imagine is the next step to getting the path issue resolved? |
Fixes source printing after switching the working dir to something != the root source directory by ditching libbacktrace. Resolves #2
Hi Jane, thank you for your interest in helping out! Right now, we're in a worse place than before, with libbacktrace now being the default on macOS as well. On the positive side, due to either improvements in rustc or gimli, gimli now "only" takes 19s to build (vs. the previous 30s) on my 6c/12t machine. Pretty meh, but still better than essentially killing source printing of this crate on Linux in a lot of situations, I would think. For now, with the option of just fixing libbacktrace becoming very unlikely, I propose we change backtrace-rs to use coresymbolication on macOS again and gimli on Linux. Oddly, this also builds gimli on Mac despite only adding the feature in a conditional If you want to help out, it would likely be best to talk to the gimli / backtrace-rs people on how to push gimli further to allow it to be the default in backtrace-rs one day. Regarding issue #1, I think this is mostly resolved, but let's talk about this in the other issue. I'll post there in a moment. |
As far as I know @alexcrichton is the definition of "gimli/backtrace-rs" people, so I'm gonna ping him from this issue so it ends up in his notification queue and when hes around and has time we can talk to him about it. |
I think this is reality as well unfortunately :(
I would think the same! I'd actually recommend using gimli on macOS as well if you can, and gimli should also work on MinGW now, entirely obsoleting libbacktrace in theory
Yes that's a Cargo issue, I found the same thing when compiling backtrace itself :). FWIW I'd like to work more on the compile time of the gimli feature of
I've mostly just been recently idly working on this issue - rust-lang/backtrace-rs#189 - but if others are willing to help out that'd be great! At this point I think the major issues are:
I'm curious to push this forward as well! |
Well, sign me up to help on rust-lang/backtrace-rs#189, I've never really spent time trying to optimize build times so that sounds like a fun project. |
Fixes source printing after switching the working dir to something != the root source directory by ditching libbacktrace. Resolves athre0z#2
Thanks for the response @alexcrichton! I now also switched to gimli on macOS. I had previously skimmed through the gimli issue in backtrace-rs and read something about it not working on macOS yet, so I didn't even try that before. Seems to be working fine! |
ianlancetaylor/libbacktrace#72 seems relevant and has a reproducible bug
why? https://github.com/ianlancetaylor/libbacktrace still seems maintained, from looking at recent commits |
When originally posting this, the library hadn't received any commits on 1+ year (as can be seen by the hole in the activity graph here). Looks like it being more actively maintained again now, which is good to hear! |
This version will print source lines
this version will hit the subsequent line in color-backtrace/src/lib.rs and skip printing all the src lines.
The filenames in my binary all use relative paths, I noticed that in your screenshot it seems to use absolute paths.
I imagine the fix is as simple as generating the rust binaries with absolute paths in the debug info, but I have no idea how to force it to compile that way. Either that or store the crate root somewhere in the binary and use that during filename resolution rather than expecting it to work relative to the current directory.
The text was updated successfully, but these errors were encountered: