Skip to content
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

Unsound drop of uninitialised variable in Object::set_ivar. #61

Open
quadrupleslap opened this issue Jan 30, 2018 · 2 comments
Open

Unsound drop of uninitialised variable in Object::set_ivar. #61

quadrupleslap opened this issue Jan 30, 2018 · 2 comments

Comments

@quadrupleslap
Copy link

quadrupleslap commented Jan 30, 2018

There needs to be a way to initialize values, probably just calling ptr::write.

@quadrupleslap quadrupleslap changed the title Unsound drop of uninitialised variable in set_ivar. Unsound drop of uninitialised variable in Drop::set_ivar. Jan 30, 2018
@quadrupleslap quadrupleslap changed the title Unsound drop of uninitialised variable in Drop::set_ivar. Unsound drop of uninitialised variable in Object::set_ivar. Jan 30, 2018
@SSheldon
Copy link
Owner

SSheldon commented Feb 4, 2018

I never considered that someone might keep types that implement Drop in ivars! @quadrupleslap can you tell me more about your use case? I'm not sure how you'd plan to drop them (implement dealloc?) and what new APIs that would require.

The easy way to fix the unsoundness would be just adding a : Copy bound, but if you want to store Drop types that still doesn't help you 😛

@quadrupleslap
Copy link
Author

quadrupleslap commented Feb 5, 2018

I was trying to set some boxed values, but it's fine - it's not essential. Adding a Copy requirement sounds like a good idea, but I'm not sure if it's better than just adding Object::init_ivar, and adding a notice to the other *_ivar methods that the value might be uninitialized and that the user should call init_ivar first. The problem with that is that it doesn't automatically free the values, which is technically sound, but not very nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants