-
-
Notifications
You must be signed in to change notification settings - Fork 15k
NormalizeArrayLen MIR opt unsound due to missed writes #105929
Copy link
Copy link
Closed
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The opt, as written today, will miscompile something that looks like this:
The bug is roughly on this line:
rust/compiler/rustc_mir_transform/src/normalize_array_len.rs
Line 270 in 696563e
This makes an attempt to detect other writes to the
slice_ptrlocal, but it misses a lot of cases. Taking a reference like in the example above is an easy one, butSetDiscriminantis also missed, as well as writes to any aliasing pointers.As far as I can tell this needs
Rvalue::Castsupport in custom MIR to reproduce.@rustbot label A-mir-opt T-compiler requires-nightly