-
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
miri: Detect uninitialized integers and floats #88670
Conversation
Some changes occured to the CTFE / Miri engine cc @rust-lang/miri |
676451f
to
06ca933
Compare
06ca933
to
5e17e7b
Compare
This comment has been minimized.
This comment has been minimized.
5e17e7b
to
37f449a
Compare
This comment has been minimized.
This comment has been minimized.
37f449a
to
bac42ff
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bac42ff
to
fa8f887
Compare
Rebased to fix merge conflicts. |
This comment has been minimized.
This comment has been minimized.
fa8f887
to
1f9dd13
Compare
This comment has been minimized.
This comment has been minimized.
1f9dd13
to
ef82e09
Compare
ef82e09
to
17fbcab
Compare
I can squash, too, but I'll wait for you to review first :) |
@@ -212,6 +212,10 @@ struct ValidityVisitor<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> { | |||
} | |||
|
|||
impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M> { | |||
fn allow_uninit_and_ptr_numbers(&self) -> bool { | |||
!M::enforce_number_initialization(self.ecx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that might be confusing about this is that enforce_number_initialization
also controls whether pointer numbers are allowed. Should I rename enforce_number_initialization
to something like enforce_number_validity
(and maybe rename the Miri-the-tool flag too)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like enforce_number_validity. :)
Also, what is the point of introducing fn allow_uninit_and_ptr_numbers
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like enforce_number_validity. :)
Ok, I'll rename to that :)
One thing though: will it be confusing because enforce_validity
also exists?
Also, what is the point of introducing
fn allow_uninit_and_ptr_numbers
here?
It's not really necessary anymore; I'll remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing though: will it be confusing because enforce_validity also exists?
On a broad level it seems consistent. It gets a bit subtle but I think we can handle this with comments/documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, and if we have to, we can rename the flag later too. Anyway, I updated this PR and the miri PR with the rename :)
5d4ca51
to
0599958
Compare
Looking good, apart from a final comment nit. :) |
Change the Miri engine to allow configuring whether to check initialization of integers and floats. This allows the Miri tool to optionally check for initialization if requested by the user.
0599958
to
d8a1454
Compare
Done! Thanks for your help with this PR :) |
Sure, thanks for your patience. :) |
📌 Commit d8a1454 has been approved by |
☀️ Test successful - checks-actions |
Tested on commit rust-lang/rust@800a156. Direct link to PR: <rust-lang/rust#88670> 💔 miri on windows: test-pass → build-fail (cc @oli-obk @eddyb @RalfJung). 💔 miri on linux: test-pass → build-fail (cc @oli-obk @eddyb @RalfJung).
Finished benchmarking commit (800a156): comparison url. Summary: This change led to large relevant regressions 😿 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
I cannot quite explain why there would be any perf change here... if anything this should improve perf since two conditionals got replaced by a constant |
Maybe there's a mismatch between |
No, in rustc the check is only ever invoked by the CTFE query code after obtaining the final result. |
So that we get rust-lang/rust#88670.
Add flag to check for uninitialized numbers Closes #1340. Companion rustc PR that implements this in the Miri engine: rust-lang/rust#88670 r? `@RalfJung`
I'm pretty sure this is noise, likely due to the introduction of randomized hashing as part of incr-comp verification that hasn't lasted long enough yet to bump noise levels up as part of perf collection. Unmarking as a regression. |
Part of rust-lang/miri#1340.
Companion Miri PR: rust-lang/miri#1904
r? @RalfJung