rust-lang / miri

An interpreter for Rust's mid-level intermediate representation
Apache License 2.0
4.14k stars 318 forks source link

Bugfix `MiriAllocBytes` to guarantee different addresses #3625

Closed Strophox closed 1 month ago

Strophox commented 1 month ago

Fix in alloc_bytes.rs following https://github.com/rust-lang/miri/pull/3526

Currently when an allocation of size == 0 is requested we return a std::ptr::without_provenance_mut(align), but this means returned ptrs may overlap, which breaks things.

RalfJung commented 1 month ago

but this means returned ptrs may overlap

"overlap" isn't quite right, since arguably ranges with with size 0 can never overlap.

But two different allocations can end up at the same address, and that's a problem.

RalfJung commented 1 month ago

but this surprisingly failed all tests:

Why did they fail? Setting the size to 1 should work and avoids duplicating logic so please figure out why it did not work.

RalfJung commented 1 month ago

@bors r+

bors commented 1 month ago

:pushpin: Commit 120efdc55ed50bdc551d666ab7aa34cb2970277d has been approved by RalfJung

It is now in the queue for this repository.

bors commented 1 month ago

:hourglass: Testing commit 120efdc55ed50bdc551d666ab7aa34cb2970277d with merge d7ddcaf845690e9896ea75ffda96e9ecfa98629f...

bors commented 1 month ago

:sunny: Test successful - checks-actions Approved by: RalfJung Pushing d7ddcaf845690e9896ea75ffda96e9ecfa98629f to master...