-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Insert checks for enum discriminants when debug assertions are enabled #141759
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
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @vakaras Some changes occurred in compiler/rustc_codegen_ssa Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to the CTFE machinery rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
This comment has been minimized.
This comment has been minimized.
6d3fe75 to
a7dd718
Compare
This comment has been minimized.
This comment has been minimized.
a7dd718 to
4f3342e
Compare
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.
54b6e74 to
b03960e
Compare
This comment has been minimized.
This comment has been minimized.
b03960e to
228b656
Compare
This comment has been minimized.
This comment has been minimized.
228b656 to
d1d8f88
Compare
This comment has been minimized.
This comment has been minimized.
d1d8f88 to
93b24d7
Compare
This comment has been minimized.
This comment has been minimized.
93b24d7 to
c2a8415
Compare
This comment has been minimized.
This comment has been minimized.
c2a8415 to
d769d6b
Compare
This comment has been minimized.
This comment has been minimized.
d769d6b to
68665ad
Compare
This comment has been minimized.
This comment has been minimized.
68665ad to
1225079
Compare
This comment has been minimized.
This comment has been minimized.
1225079 to
c52f534
Compare
|
looks like its stuck |
Insert checks for enum discriminants when debug assertions are enabled
Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following:
```rust
let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) };
```
An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++.
This check is similar to Miri's capabilities of checking for valid construction of enum values.
This PR is inspired by saethlin@'s PR
#104862. Thank you so much for keeping this code up and the detailed comments!
I also pair-programmed large parts of this together with vabr-g@.
r? `@saethlin`
|
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing d41e12f (parent) -> b63223c (this PR) Test differencesShow 56 test diffsStage 1
Stage 2
Additionally, 16 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard b63223c152212832ce37a109e26cc5f84c577532 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (b63223c): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 690.233s -> 690.587s (0.05%) |
Culprit PRs: - rust-lang/rust#142927 - rust-lang/rust#141759 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
Insert checks for enum discriminants when debug assertions are enabled
Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following:
```rust
let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) };
```
An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++.
This check is similar to Miri's capabilities of checking for valid construction of enum values.
This PR is inspired by saethlin@'s PR
rust-lang#104862. Thank you so much for keeping this code up and the detailed comments!
I also pair-programmed large parts of this together with vabr-g@.
r? `@saethlin`
|
I think this has landed in 1.90.0. A library I use that does this in a proc-macro now panics. Can fix easily. Maybe needed to be included in breaking changes here: https://github.com/rust-lang/rust/releases/tag/1.90.0 |
|
Turning UB into a deterministic crash is not a breaking change. If you think the check is wrong you should file an issue. If you think that this would be useful to include in the release notes to raise awareness, you should file an issue or create a PR. (Though it's unclear to me how adding a bullet to the release notes would have changed things for you 🤷) |
Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following:
An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++.
This check is similar to Miri's capabilities of checking for valid construction of enum values.
This PR is inspired by saethlin@'s PR
#104862. Thank you so much for keeping this code up and the detailed comments!
I also pair-programmed large parts of this together with vabr-g@.
r? @saethlin