-
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
Enable eager checks for memory sanitizer #99207
Conversation
r? @cuviper (rust-highfive has picked a reviewer for you, use r? to override) |
Question: @nikic , were the eager checks added in LLVM 15? (So I'd add an |
The option was added in LLVM 14. |
Strange, I was expecting that run to fail because LLVM version too old, and I'd need to put a min-llvm-version on memory-eager.rs |
bb0d344
to
51c53a5
Compare
Okay, I think gnu-llvm-12 doesn't have sanitizer support, so the tests were skipped. I compiled a llvm 12 locally and tested that the code worked using it. (Not having the eager checks, but it worked) |
d94eff8
to
f419937
Compare
From the perspective of the Rust alone enabling eager checks by default sounds fine to me. Though I wonder about mixed C/C++ builds. Clang disables eager checks by default, it also has a different understanding which arguments have undef attribute. Both cases could lead to false negatives. The side with eager checks might falsely consider the caller to be responsible for checking the undef argument and assumes the argument to be initialized. For that reason I would lean towards exposing this functionality behind a flag and matching the clang default. What do you think? |
A LLVM person would need to answer if that's a problem. But I do know that you get false positives if you don't have all code built with memory sanitizer, so "being careful about your dependency build flags" is already a thing. I'm wary of making it opt-in since most code doesn't need it to be opt in. We could add a mandatory parameter for eager checks and show a warning if the user doesn't pick one, perhaps. That'll communicate this change pretty clearly, but is rather loud. Not sure. |
It is a problem. It is impossible to detect uninitialized arguments of integer types, floating point types, and data pointers in calls from Rust to C when eager checks enabled in both clang and rustc. Currently the Rust side doesn't have noundef attribute for those types, so argument is not checked. The C side does have the attribute and assumes it was already checked. There is an analogous issue when the eager checks are enabled only in rustc. The implementation that preserves the existing default sound fine to me, if you would like to land it. With regards to the change of the default, I would wait for further support of the idea. |
The code looks fine, but I don't have enough background in msan to judge if we should, so I'm re-rolling... r? rust-lang/compiler |
I have less background to know if we should or not. Let's cc @rust-lang/compiler |
☔ The latest upstream changes (presumably #100511) made this pull request unmergeable. Please resolve the merge conflicts. |
f419937
to
16525cc
Compare
I don't really have any background here to judge if this is a good change or not. I imagine this might need a compiler MCP, but not sure. Going to go ahead and nominate to get discussed in the compiler meeting, since that seems like to easiest way to get feedback here. |
Talked about this in compiler meeting. Seems like we're good to just enable this. @bors r+ |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#99207 (Enable eager checks for memory sanitizer) - rust-lang#101253 (fix the suggestion of format for asm_sub_register) - rust-lang#101450 (Add `const_extern_fn` to 1.62 release notes.) - rust-lang#101556 (Tweak future opaque ty pretty printing) - rust-lang#101563 (Link UEFI target documentation from target list) - rust-lang#101593 (Cleanup themes (tooltip)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Adapt test for msan message change Similar to rust-lang#100445, this adapts the new test added by rust-lang#99207 to some relatively recent [LLVM changes](llvm/llvm-project@057cabd) that removed the function name from msan messages. Found via our experimental rust + llvm @ HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/13347#018321b2-0cc3-4c91-b4db-774477e8b074 `@rustbot` label +llvm-main
Fixes #99179