-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Misaligned reference from drop field in packed struct #99838
Comments
We have a pass to add moves for drops in packed structs, but it doesn't fire in this case. That's because there's a bug here - this computation cannot just take into account the innermost field, it needs to compute a minimum of some sort. |
@JakobDegen is this a regression? What did you exactly expected the output to be? (I'd like to run a bisection). thanks. |
This was right in Getting a consistent reproduction of this is slightly difficult because the reference might happen to align correctly by accident. In other words, the fact that the example above prints a pointer that is not 2-aligned means that something is certainly wrong. However, if the address were to be 2-aligned that could either be because the bug is fixed or because we happened to get lucky. The consistent way to check this is by looking at
which is correct (the move ensures that the resulting place is aligned) while 1.53.0 contains
Note that there is no move. |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-high E-needs-bisection |
I have run a bisection with cargo-bisect on your
The bisection could not pinpoint a single commit, maybe it sinked into a rollup merge. But if it helps, the regression should be in
@JakobDegen do you see in any of those a possible culprit? (I don't have the context to) |
Not sure how #83605 would have an effect here, it should be a NOP for Where is the logic that moves packed structs to a new place before dropping implemented?
That's odd, I would have expected this to be inside |
@RalfJung the pass is called |
|
@RalfJung I don't understand the suggestion. The example above never calls |
Oh I see, I didn't quite read the example correctly. The problematic drop is the one that happens on field assignment, and we know it's a packed field because of the path we are accessing it with. EDIT: no wait this makes no sense. Now I am confused by your comment. |
No what I just said makes no sense. What happens is that this is a partial drop -- one field has been moved out ( So #83605 is relevant because it changed |
#100064 should fix this. |
fix is_disaligned logic for nested packed structs rust-lang/rust#83605 broke the `is_disaligned` logic by bailing out of the loop in `is_within_packed` early. This PR fixes that problem and adds suitable tests. Fixes rust-lang/rust#99838
fix is_disaligned logic for nested packed structs rust-lang/rust#83605 broke the `is_disaligned` logic by bailing out of the loop in `is_within_packed` early. This PR fixes that problem and adds suitable tests. Fixes rust-lang/rust#99838
I tried this code:
I expected to see this happen: The reference is aligned
Instead, this happened:
Meta
rustc --version --verbose
:@rustbot label I-unsound A-mir
The text was updated successfully, but these errors were encountered: