Fix undefined behavior in Rc/Arc allocation#54922
Fix undefined behavior in Rc/Arc allocation#54922bors merged 1 commit intorust-lang:masterfrom murarth:rc-ub-fix
Conversation
This comment has been minimized.
This comment has been minimized.
|
r? @RalfJung |
|
Could you add a comment saying why we do it this way and not the old way? Other than that, I agree the alignment problem is gone. However, I do not know nearly enough about layouts to say if that's a correct way to compute these things. Assigning to someone who knows more (feel free to pick someone else). r? @eddyb |
|
Ping from triage! This PR requires your review @eddyb. Also this PR was references from rust-lang/unsafe-code-guidelines#35, is it blocked on that issue? |
|
This is not a compiler layout, but I suspect it's correct. |
|
Thanks for the PR and sorry for the delay! This looks good to go to me with @RalfJung's comment |
|
If possible, it'd also be great to have a regression test for this! |
We'll have one in miri. I have no idea how to make one with rustc only. |
Manually calculate allocation layout for `Rc`/`Arc` to avoid undefined behavior
|
I've added a more detailed comment and the tests have passed. |
|
@bors: r+ |
|
📌 Commit d60290f has been approved by |
Fix undefined behavior in Rc/Arc allocation Manually calculate allocation layout for `Rc`/`Arc` to avoid undefined behavior Closes #54908
|
☀️ Test successful - status-appveyor, status-travis |
|
Hm, this RFC made miri fail even if validation is turned off. Still investigating. |
|
The error is that an allocation has size 32 but gets deallocated with size 28. I assume the layout computations done here are incorrect. |
|
Reported as #55747. |
Manually calculate allocation layout for
Rc/Arcto avoid undefined behaviorCloses #54908