stack_dst-rs icon indicating copy to clipboard operation
stack_dst-rs copied to clipboard

miri is detecting undefined behavior

Open joseluis opened this issue 1 year ago • 2 comments

Latest version of miri is not happy with that line in the make_fat_ptr function.

cargo +nightly miri test

test retain ... error: Undefined Behavior: constructing invalid value: encountered 0x2598e0[noalloc], but expected a vtable pointer
   --> stack_dst-rs/src/lib.rs:314:14
    |
314 |     let rv = rv.ptr;
    |              ^^^^^^ constructing invalid value: encountered 0x2598e0[noalloc], but expected a vtable pointer
    |
    
   --> stack_dst-rs/src/fifo.rs:224:23
    |
224 |                 &mut *super::make_fat_ptr(data.as_mut_ptr() as *mut (), meta)
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `retain`
   --> tests/fifo.rs:71:5
    |
71  |     stack.retain(|v| v.as_ref().0 > 2);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
   --> tests/fifo.rs:47:12

joseluis avatar Sep 15 '24 15:09 joseluis

This may be related to miri dropping support for simulating vtables, as explained here:

https://github.com/uazu/stakker/blob/5821c30409c19ca9167808b669c928c94bc5f177/src/queue/flat.rs#L14-L17

joseluis avatar Oct 07 '24 09:10 joseluis

Well, that'd explain it

thepowersgang avatar Oct 07 '24 09:10 thepowersgang