-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Accessing DST field of packed struct calculates the wrong field address #80925
Comments
The labels are incorrect. Neither does this require nightly, nor is it related to const-eval. This is I-unsound on stable. |
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.
Assigning |
@rustbot label -I-prioritize +P-medium |
@rustbot labels -T-types Discussed in types team on-site -- we think this is a MIR building bug, in any case, not part of T-types. Throwing hot 🥔 back to compiler team. |
It was actually a bug in the codegen backend, introduced when support for |
Ah, scratch that -- there was a different related bug (the size_of_val / align_of_val computation for packed structs with This here was caused by the codegen backend just never considering packed types when computing the offset of the unsized field. Almost always this happened to work since the unsized field is a slice/str and so its alignment (and therefore its offset) is dynamically known, but when dyn trait tails are involved this starts to go wrong. |
…affleLapkin fix dynamic size/align computation logic for packed types with dyn trait tail This logic was never updated to support `packed(N)` where `N > 1`, and it turns out to be wrong for that case. Fixes rust-lang#80925 `@bjorn3` I have not looked at cranelift; I assume it basically copied the size-of-val logic and hence could use much the same patch.
…fleLapkin fix dynamic size/align computation logic for packed types with dyn trait tail This logic was never updated to support `packed(N)` where `N > 1`, and it turns out to be wrong for that case. Fixes rust-lang#80925 `@bjorn3` I have not looked at cranelift; I assume it basically copied the size-of-val logic and hence could use much the same patch.
fix dynamic size/align computation logic for packed types with dyn trait tail This logic was never updated to support `packed(N)` where `N > 1`, and it turns out to be wrong for that case. Fixes rust-lang/rust#80925 `@bjorn3` I have not looked at cranelift; I assume it basically copied the size-of-val logic and hence could use much the same patch.
Execute with Miri:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7e7d31feebbea4c3caceaccff1fa6bac
The problem is that
rust/compiler/rustc_codegen_ssa/src/mir/place.rs
Lines 181 to 182 in 6526e5c
rust/compiler/rustc_mir/src/interpret/place.rs
Line 413 in 6526e5c
The text was updated successfully, but these errors were encountered: