-
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 #99179
Comments
If there's not a big performance hit, and it just changes behavior, then I think we should just unconditionally enable it, saves people the hassle of needing to know to enable that flag in CI as well if you want the better checks. In any case, I'll try and implement this, we can probably get away with not changing the rust code side at all, and just always passing |
Also, looks like we're not emitting |
We do emit noundef attributes for params and returns -- maybe you're testing |
What I don't get is how. Does noundef have no effect on unoptimised builds / is it ignored? (As in, in order to get the effect of memory sanitizer here, do you have to run an optimized build?) I see that we have rust/compiler/rustc_codegen_llvm/src/builder.rs Lines 467 to 488 in 95e8b86
|
Attributes should be configured somewhere around here: rust/compiler/rustc_codegen_llvm/src/abi.rs Lines 46 to 52 in 95e8b86
rust/compiler/rustc_codegen_llvm/src/abi.rs Lines 75 to 93 in 95e8b86
|
They are not set as a compile-time optimization. It would be fine to always emit them with memory sanitizer, as they impact its behavior. |
Ahhh! Thank you! So https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/ty/layout.rs#L3223-3226= is where noundef is given to params/return values with validity invariants. And yeah, we don't tell LLVM that anything is noundef if we have no opts on. Maybe we should, but only if memory sanitizer is enabled? (or unconditionally?) Since it's giving msan information it needs. Not sure how many people run msan in CI and don't run it in release, but it seems non-obvious that you would need to. |
The memory sanitizer supports "eager checks", which will check initialization for noundef parameters and return values. It can be enabled by passing true as the fourth parameter to MemorySanitizerOptions. The corresponding clang option is
-fsanitize-memory-param-retval
. Not sure whether we need an option or can just unconditionally enable it.The text was updated successfully, but these errors were encountered: