-
Notifications
You must be signed in to change notification settings - Fork 359
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
Support for custom allocator in miri #1207
Comments
Yeah, right now your custom allocator will just not be called. (You can make it
Possible, definitely. The I could mentor you on this if you want, except I am not sure how one would figure out if there is a |
Nice! I'll try and get a PR up for this then. One thing I'm unclear on though is the following:
Surely, at some point though, we will need to dispatch to Miri's implementation? In the example I showed in this issue, my custom allocator dispatches the
Appreciate this, but I think I'll be okay for now. I have some minor experience with rustc but will probably ping you if I get stuck :) |
The Basically, Miri currently separately shims the So, |
Ah, I understand now.
Yeah, agreed.
No problem. I'll add one. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@jacob-hughes do you still plan to work on this? Let me know if you need any help. :) |
Hi Ralf. Unfortunately the events over the last few weeks have made be a bit unproductive. I hope to have something in the next few days. |
add support for `#[global_allocator]` This PR adds support for custom global allocators. Unfortunately, the code given in #1207 still causes errors when used with box. I believe this is because Box is special-cased in miri and stacked borrows.
This has been implemented by #1885. |
If I understand correctly, Miri replaces the allocator, even when the
#[global_allocator]
attribute is used to specify a custom allocator. Unfortunately, this can lead to Miri thinking that a program invokes UB when it does not.In the following example, I implement a custom allocator where
alloc
reserves the first machine word in each block in order to store a header, it then returns a pointer to the next address. Since Miri replaces this with its own allocator, dereferencing a pointer to the header's offset will be out-of-bounds.Running this under miri causes an evaluation error upon the first misuse of
header_ptr
:Playground link
Is this kind of support possible? Alternatively, perhaps if suppression support landed this may be an ideal use-case. [issue #788]
The text was updated successfully, but these errors were encountered: