You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm implementing custom allocator that stores allocation metadata in first bytes few of the allocated block and offsets pointer before returning it from Allocator::allocate.
It goes in reverse in Allocator::deallocate and reads metadata from before the passed pointer.
It works until I try to use Box::new_in or similar.
When Box is dropped, pointer passed to A::deallocate has different tag than one that returned from A::allocate.
And Miri emits error saying that tag does not encompass first bytes of the block and I can't read them.
Same error happens if pointer from Allocator::allocate is converted to reference and then back to pointer.
That's, I guess, can be expected. But Box should not retag pointer on drop as I understand it.
Or this is something strictly prohibited by Rust.
The text was updated successfully, but these errors were encountered:
This looks like a duplicate of rust-lang/miri#2104. This is a fundamental problem with Stacked Borrows (an instance of #256). Since recently we have the very experimental Tree Borrows mode in Miri that should be able to handle this code better. Could you try running this with '-Zmiri-tree-borrows'?
(The retag happens much earlier than just on drop, it already happens when new_in returns, so I don't think this has much to do with dropping.)
I'm implementing custom allocator that stores allocation metadata in first bytes few of the allocated block and offsets pointer before returning it from
Allocator::allocate
.It goes in reverse in
Allocator::deallocate
and reads metadata from before the passed pointer.It works until I try to use
Box::new_in
or similar.When
Box
is dropped, pointer passed toA::deallocate
has different tag than one that returned fromA::allocate
.And Miri emits error saying that tag does not encompass first bytes of the block and I can't read them.
Here's playground link
Same error happens if pointer from
Allocator::allocate
is converted to reference and then back to pointer.That's, I guess, can be expected. But
Box
should not retag pointer on drop as I understand it.Or this is something strictly prohibited by Rust.
The text was updated successfully, but these errors were encountered: