-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Source file names are included into a release binary even if abort upon panic is enabled #75263
Comments
dont use rust. see #40552 privacy isnt a thing they want to think or fix. paths should be less issue than the username in your binary |
|
Marking this for prioritisation request as some people have privacy concerns over file names showing up in their production apps |
Why is |
I've never heard of I went ahead and threw this into a project's [build]
rustflags = ["--remap-path-prefix=/home/jmn/Projects/mprojects/mbot=src", "--remap-path-prefix=/home/jmn/.cargo=cargo", "--remap-path-prefix=/home/jmn/.rustup=rustup"] It did get rid of mentions of |
Assigning |
anyone from compiler team going to comment on this or just ignore it? workarounds dont actually work |
@unpavedmop This is a piece of team infrastructure that's open to the public, not a discussion forum. The "comment" was "Marking this for prioritisation request as some people have privacy concerns over file names showing up in their production apps" and receiving a P-medium tag. If you disagree, check out P-high to see what kinds of bugs they consider more pressing concerns. |
This sounds like the compiler version is being embedded in the binary.
I can't reproduce this.
|
I tried using a library like in the original reproduction instructions, and if I modify
|
@jyn514 how do you propose that in a cargo.toml otherwise devs cant expect to tell people use this set of flags, and its hardcoded path |
@unpavedmop You put it in your README. Same way ripgrep instructs people to use a nightly compiler and It's your users' fault if they don't follow the official build instructions, same way it would be if they patched the code and introduced a privacy problem that way. |
Hmm, I think this is duplicate of #40552 (or the other way around). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@Subsentient could you please paste the exact commands you're running to replicate this? I'm running
I've tried this on two different machines (one running Ubuntu 20.04, the other running Debian 10) and neither reproduces the issue. |
@jyn514 , but what about the test in my original message? Remap flags are helpful to hide the names of the parent folders of a project. But these flags can't help to hide a relative source file name. |
@Subsentient , what story in the news are you talking about? Can you please provide a link to it? |
See #66955. To summarize: there is a bug that |
Moderation note: Folks, please keep comments directed toward constructively resolving the problem at hand, just like you would any other issue. Further unconstructive meta commentary will be removed. If you have questions about our moderation, please do not respond here. Instead, please email the mods at [email protected]. |
Ok, this is related to release vs debug mode somehow, panic=abort has nothing to do with it. With a blank Cargo.toml this works properly:
but the same thing without --release (and without incremental) does not:
|
@Subsentient , @jyn514 , here is instruction to reproduce original problem (instruction was added to the first message).
|
@dmitry-zakablukov I was able to omit those symbols altogether with Again, the reason this happens with panic=abort is because that still runs the panic hook: #75263 (comment). I would expect if you override the panic hook that might also let the compiler optimize out the strings: https://doc.rust-lang.org/std/panic/fn.set_hook.html. I'm going to close this issue because there have been many different unrelated issues reported and most of them are being drowned in drama. I've opened #84125 for the issue with --remap-path-prefix I ran into at the end, and there are already some other related open issues, such as #66955. If you think --remap-path-prefix should be passed by default, see #40552. @Monadic-Cat I couldn't reproduce the bug in #75263 (comment) - if you run into it again in release mode, could you please open a new issue? It might be #73167 if you have rust-src installed. Debug mode is tracked by #84125. |
@jyn514 , setting custom panic hook only doesn't resolve my issue. |
I'm not sure there is a plan to stabilize this, I don't see a tracking issue.
Because they do different things. Aborting immediately is different from printing a panic message and then aborting, and is much harder to debug. In particular, it doesn't allow setting RUST_BACKTRACE=1 to see where the panic happens. |
I did have |
Oh sorry I misunderstood - the tracking repo for -Z build-std is https://github.com/rust-lang/wg-cargo-std-aware. |
Is there a way to remove that information? Since --remap-prefix doesn't seem to affect it. |
A workaround I found to remove the home dir data from the .wasm binary I'm distributing:
Xargo.toml: [dependencies]
std = {default-features=false, features=["panic_immediate_abort"]}
This removes all mentions of my home dir from the .wasm binary. |
Can you open an issue about that with more details? |
Looks like there are already similar issues about this. |
Good day!
I have found, that if a library contains code that may panic (slices, unwraps, etc.), then a filename of such source file will be included in a binary. Release build doesn't change this behavior, neither debug symbols stripping do.
I have tried to turn on "abort" for panic in release profile. Even though this resulted in a smaller binary size, it doesn't wipe out source file names from the binary.
Here is a small reproducible code.
If I build this example with a command
cargo build --release
on Windows, then asymbols_test.exe
will contain a stringengine\src\lib.rs
.==============================
So what should I do, if I want to distribute my program to the clients and do not want them to find out file names of my source files (which are a business secret)? How to strip source file names from the binary?
UPD: How to reproduce the problem on Windows:
On *nix systems change slashes to '/' and remove '.exe' in the last command.
The text was updated successfully, but these errors were encountered: