-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Change {Box,Arc,Rc,Weak}::into_raw
to only work with A = Global
#141219
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
base: master
Are you sure you want to change the base?
Conversation
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.
Also applies to `Vec::into_raw_parts`. The expectation is that you can round-trip these methods with `from_raw`, but this is only true when using the global allocator. With custom allocators you should instead be using `into_raw_with_allocator` and `from_raw_in`. The implementation of `Box::leak` is changed to use `Box::into_raw_with_allocator` and explicitly leak the allocator (which was already the existing behavior). This is because, for `leak` to be safe, the allocator must not free its underlying backing store. The `Allocator` trait only guarantees that allocated memory remains valid until the allocator is dropped.
I don't know why this is failing on Miri... I only moved the methods and didn't change any implementation (except |
This comment has been minimized.
This comment has been minimized.
@RalfJung Do you have any idea why these miri tests would fail? The only relevant change is moving |
Yeah it has to do with this comment. This is part of the general issue that adding allocators to |
Sure, but the implementation of I don't see why changing the bounds on that methods from |
Miri has no choice but use some terrible hacks to work around the poor state that |
I pushed a commit that should hopefully fix CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me pending approval from the rest of libs-api
@rustbot label +A-box +A-allocators +A-MIR +A-miri |
Also applies to
Vec::into_raw_parts
.The expectation is that you can round-trip these methods with
from_raw
, but this is only true when using the global allocator. With custom allocators you should instead be usinginto_raw_with_allocator
andfrom_raw_in
.The implementation of
Box::leak
is changed to useBox::into_raw_with_allocator
and explicitly leak the allocator (which was already the existing behavior). This is because, forleak
to be safe, the allocator must not free its underlying backing store. TheAllocator
trait only guarantees that allocated memory remains valid until the allocator is dropped.