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

Pointer comparison of live non-heap allocations is suspicious #552

Closed
oli-obk opened this issue Nov 27, 2018 · 2 comments
Closed

Pointer comparison of live non-heap allocations is suspicious #552

oli-obk opened this issue Nov 27, 2018 · 2 comments

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Nov 27, 2018

In https://github.com/solson/miri/blob/80a6e739424728d7505587ea6c53c39d6687cb59/src/operator.rs#L151 we compare pointers directly, even if they are from different allocations, as long as both are inbounds of live allocations.

Unfortunately optimizations might bite us:

&42 as *const u32 == &42 as *const u32

can be true or false depending on how these promoteds get deduplicated. Even for explicit local variables

let x = 42;
let y = 42;
&x as *const u32 == &y as *const u32

an optimizer may merge the two variables if they are guaranteed equal (especially if their types are Copy).

So we can essentially only compare live heap allocations, static items and mutable local variables, since these are guaranteed distinct in all models I know.

@RalfJung
Copy link
Member

This is basically #131, right?

@oli-obk
Copy link
Contributor Author

oli-obk commented Nov 27, 2018

Yes

@oli-obk oli-obk closed this as completed Nov 27, 2018
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