-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
ignore() is potentially unsafe #24
Comments
I changed the comment as I’m not entirely sure if it’s indeed unsafe or if miri is wrong here. |
That doesn't sound at all like what miri is saying. The miri message "encountered a dangling reference", which is about It does sound like miri is being overzealous here given that this is both zero sized and never dereferenced (either of which independently could be sufficient for this to be well defined). It seems fine though to change it to a |
Indeed. It turns out that this is permitted. I will open an issue against miri. //EDIT: I filed the issue here: rust-lang/miri#1972 |
References must not be dangling even if they are never used, and even zero-sized accesses are subject to some restrictions:
We sadly have to require this due to the rules LLVM imposes on |
I believe that the implementation of
ignore
in miniserde is unsafe. It casts a global static into a mutable reference which means there will be multiple references alive at once. At the same time it’s a zero sized type which can give out multiple addresses so I’m not sure how this works. I made a minimal repo example and miri complains:Produces this:
The text was updated successfully, but these errors were encountered: