-
Notifications
You must be signed in to change notification settings - Fork 379
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
Stacked Borrows around GlobalAlloc
#1909
Comments
Probably related to PR #1885. |
Slightly smaller playground. Interestingly, the casts in |
Interesting. FWIW your example errors even with an empty |
Your |
Ah, I think what happens is something like
Allocators are tricky in that they "generate unique pointers" but then during deallocation (if this is implemented in userspace, not as a language primitive) somehow we have to 'forget' that these pointers are unique and treat them again as the shared raw pointers that they were before the magic act of allocation "blessed" them. I have not yet seen a proposal for how to solve this. Though in this case one could argue the real culprit is the combination of a tagged raw pointer and integer-pointer-roundtrips -- the same problem that makes |
Can you push a special |
Well, then to be safe Edit: I can just repeatedly offset with |
@niluxv LLVM/Rust do not support allocations that do not fit into an isize. There is no situation where the integer roundtrip can help here. @bjorn3 the trouble is that |
The documentation of the standard library tells otherwise (emph mine):
(Note that |
Weird... that is somewhat dubious at best, since LLVM to my knowledge will make the assumption that no allocation is larger than half the address space, and that offsets by more than |
- Switch to rust 2021 edition - Add `MAP_NOCORE` flag to `mmap` calls on freebsd-like systems, causing the allocated memory to not be included in coredumps - Improve `VolatileWriteZeroizer` and `VolatileWrite8Zeroizer` zeroizer implementations to be slightly more performant and avoid int-ptr-casts to be nicer on `miri`, solving the miri failure caused by <rust-lang/miri#1909> for now - Fix several compile warnings
FWIW, this code is accepted now that Miri has better support for int-to-ptr casts. We should probably add it as a test. |
One of my tests recently started to fail under Miri with a stacked borrows violation error. I've now kind of minimised the test case but I don't really understand why it is a stacked borrow violation. For the test to fail, a custom global allocator is necessary. All the allocator does is zeroize memory on drop, and forward calls to the
System
allocator.Playground
Relevant fragment of the error:
Full error log with pointer and allocation tracking (click to expand)
The strange thing is, when the
volatile_write_zeroize_mem
call is moved from thedealloc
intomain
(directly before thedealloc
) the example runs just fine.Playground
The text was updated successfully, but these errors were encountered: