-
Notifications
You must be signed in to change notification settings - Fork 111
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
Add Box type #141
base: master
Are you sure you want to change the base?
Add Box type #141
Conversation
Ping. Do you think this type belongs in Loom already has Or, since Loom exposes the raw allocation API, do you think any program/library that uses Loom should always just use the |
Do you want |
There are a bunch of stuff that this |
I see that I have reviewed this PR before, but I have no memory of doing so. Regardless, I would be happy to see a |
Adds a loom version of
std::boxed::Box
. To make it possible/easier to write loom tests that detect memory leaks if the library under test usually usesBox
.However, box is magical, so a normal crate can't replicate its API to 100%. A normal box can be dereferenced so the box is consumed and the value moved back to the stack. Normal crates can't implement this, so I added a
Box::into_value(self) -> T
method instead.As you can see, there is one test that is marked with
#[ignore]
. It's a test that checks if loom correctly catches a memory leak. And it does, but it causes an illegal instruction and the process dies. So#[should_panic]
is not enough to capture the panic here sadly. Not sure if it's possible to work around this currently? I guess loom first has to not cause illegal instructions when it detects a memory leak.