Skip to content

Conversation

@RalfJung
Copy link
Member

Updates for rust-lang/rust#53779

Functional changes:

  • Restrict what pointer equality can do, to make sure it agrees with run-time behavior. For now, only comparing within the same allocation, comparing two life pointers (i.e. allocated and in-bounds), and comparing a pointer with NULL are allowed.

@RalfJung
Copy link
Member Author

I had to make the pointer equality a bit smarter: When comparing a really big integer with a pointer that cannot possibly be so big or else the allocation would wrap around the end of the address space, we also say these are inequal. This is needed for Rc (which compares with usize::MAX).

src/operator.rs Outdated
// Compute the highest address at which this allocation could live
let alloc = self.memory.get(ptr.alloc_id)?;
let max_base_addr =
(1u128 << self.pointer_size().bits()) - alloc.bytes.len() as u128;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for alignment > 1 this could be even more permissive, right?

src/operator.rs Outdated
// The integer is too big, this cannot possibly be equal
false
} else {
// TODO: We could also take alignment into account
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you already added a todo, ignore my above comment

@RalfJung
Copy link
Member Author

RalfJung commented Sep 1, 2018

Since you clearly took a look and had no reservations, I assume I can merge once CI is green?

@RalfJung RalfJung merged commit 1553993 into master Sep 1, 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

Successfully merging this pull request may close these issues.

3 participants