-
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 a mock MaybeUninit #299
Comments
I believe this is basically an area that Miri or sanitizer should handle. It would be very difficult to detect the okay assume_init call such as |
It may be difficult if we wanted to detect every possible way of interacting with the MaybeUninit value. But I think this would already be very useful when we can detect issues if users restrict themselves to a subset of the std API (i.e. don't use pointers or transmute). The advantage of loom is that it can explore all possible interleavings, which I don't think miri or sanitizers could offer. What I have in mind boils down to the following:
|
This is not always correct. The type could be |
I updated the table to also include a There are very clear limitations of what we can check, but I think it would work well for data structures like a queue or stack, where you want to insert something once, and then take the value out again exactly once and never twice. |
It would be nice if loom could add a
MaybeUninit
type, which internally keeps track of if it is in an initialized state, and asserts that it is indeed initialized when the user callsassume_init()
.Additionally it could provide a new API to mark the value as uninitalized again, which for
std
would simply be a no-op. This would increase the confidence of users that in all possible interleavings only initialized data is read, and with the option to mark a MaybeUninit as unitialized, we could also check that data is not read after it was "moved out" e.g. byptr::read
The text was updated successfully, but these errors were encountered: