-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Reading dropped object's memory succeeds #62135
Comments
This just looks like UB, what did you expect to happen here? |
|
This might be intentional since the struct will likely be used for FFI, but could also be a bug. |
Thank you for pointing that out.
Would you recommend to keep the issue open if that is the case? |
(Please Cc me for Miri bugs.) The reason it does not work in Miri is that arithmetic on integers obtained from pointers is not fully supported yet. Hence you cannot print pointer values with Miri. However, we are very close to getting there! This is tracked at rust-lang/miri#224. |
I don't think there is a Mri bug to track here. These days Miri can run the example, and it works and no UB is found. Whether use-after-drop should be UB is being discussed at rust-lang/unsafe-code-guidelines#188. What remains is the fact that unused fields do not produce a warning with |
Consider the following (https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=3937a5d7f026fb9905f3a2ba3f7e2faf)
When reading from
p
, the original contents of the structure are read. Running this snippet inmiri
results in an error. What is interesting is the cause of the error:Another curious bit is that changing the attributes of the structure S to the following produces a warning.
#[repr(packed)]
The text was updated successfully, but these errors were encountered: