aa589d3dc7
Save a created event for zero-size reborrows Currently, we don't save a created event for zero-sized reborrows. Attempting to use something from a zero-sized reborrow is surprisingly common, for example on `minimal-lexical==0.2.1` we previously just emit this: ``` Undefined Behavior: attempting a write access using <187021> at alloc72933[0x0], but that tag does not exist in the borrow stack for this location --> /root/rust/library/core/src/ptr/mod.rs:1287:9 | 1287 | copy_nonoverlapping(&src as *const T, dst, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | attempting a write access using <187021> at alloc72933[0x0], but that tag does not exist in the borrow stack for this location | this error occurs as part of an access at alloc72933[0x0..0x8] | = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information = note: inside `std::ptr::write::<u64>` at /root/rust/library/core/src/ptr/mod.rs:1287:9 note: inside `minimal_lexical::stackvec::StackVec::push_unchecked` at /root/build/src/stackvec.rs:82:13 --> /root/build/src/stackvec.rs:82:13 | 82 | ptr::write(self.as_mut_ptr().add(self.len()), value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... backtrace continues... ``` Which leaves us with the question "where did we make this pointer?" because for every other diagnostic you get a "was created by" note, so I suspect people might be tempted to think there is a Miri bug here. I certainly was. --- This code duplication is so awful, I'm going to take a look at cleaning it up later. The fact that `ptr_get_alloc_id` can fail in this situation makes things annoying. |
||
---|---|---|
.. | ||
alias_through_mutation.rs | ||
alias_through_mutation.stderr | ||
aliasing_mut1.rs | ||
aliasing_mut1.stderr | ||
aliasing_mut2.rs | ||
aliasing_mut2.stderr | ||
aliasing_mut3.rs | ||
aliasing_mut3.stderr | ||
aliasing_mut4.rs | ||
aliasing_mut4.stderr | ||
box_exclusive_violation1.rs | ||
box_exclusive_violation1.stderr | ||
buggy_as_mut_slice.rs | ||
buggy_as_mut_slice.stderr | ||
buggy_split_at_mut.rs | ||
buggy_split_at_mut.stderr | ||
deallocate_against_barrier1.rs | ||
deallocate_against_barrier1.stderr | ||
deallocate_against_barrier2.rs | ||
deallocate_against_barrier2.stderr | ||
illegal_read1.rs | ||
illegal_read1.stderr | ||
illegal_read2.rs | ||
illegal_read2.stderr | ||
illegal_read3.rs | ||
illegal_read3.stderr | ||
illegal_read4.rs | ||
illegal_read4.stderr | ||
illegal_read5.rs | ||
illegal_read5.stderr | ||
illegal_read6.rs | ||
illegal_read6.stderr | ||
illegal_read7.rs | ||
illegal_read7.stderr | ||
illegal_read8.rs | ||
illegal_read8.stderr | ||
illegal_write1.rs | ||
illegal_write1.stderr | ||
illegal_write2.rs | ||
illegal_write2.stderr | ||
illegal_write3.rs | ||
illegal_write3.stderr | ||
illegal_write4.rs | ||
illegal_write4.stderr | ||
illegal_write5.rs | ||
illegal_write5.stderr | ||
illegal_write6.rs | ||
illegal_write6.stderr | ||
interior_mut1.rs | ||
interior_mut1.stderr | ||
interior_mut2.rs | ||
interior_mut2.stderr | ||
invalidate_against_barrier1.rs | ||
invalidate_against_barrier1.stderr | ||
invalidate_against_barrier2.rs | ||
invalidate_against_barrier2.stderr | ||
issue-miri-1050-1.rs | ||
issue-miri-1050-1.stderr | ||
issue-miri-1050-2.rs | ||
issue-miri-1050-2.stderr | ||
load_invalid_mut.rs | ||
load_invalid_mut.stderr | ||
load_invalid_shr.rs | ||
load_invalid_shr.stderr | ||
mut_exclusive_violation1.rs | ||
mut_exclusive_violation1.stderr | ||
mut_exclusive_violation2.rs | ||
mut_exclusive_violation2.stderr | ||
outdated_local.rs | ||
outdated_local.stderr | ||
pass_invalid_mut.rs | ||
pass_invalid_mut.stderr | ||
pass_invalid_shr.rs | ||
pass_invalid_shr.stderr | ||
pointer_smuggling.rs | ||
pointer_smuggling.stderr | ||
raw_tracking.rs | ||
raw_tracking.stderr | ||
return_invalid_mut_option.rs | ||
return_invalid_mut_option.stderr | ||
return_invalid_mut_tuple.rs | ||
return_invalid_mut_tuple.stderr | ||
return_invalid_mut.rs | ||
return_invalid_mut.stderr | ||
return_invalid_shr_option.rs | ||
return_invalid_shr_option.stderr | ||
return_invalid_shr_tuple.rs | ||
return_invalid_shr_tuple.stderr | ||
return_invalid_shr.rs | ||
return_invalid_shr.stderr | ||
shared_rw_borrows_are_weak1.rs | ||
shared_rw_borrows_are_weak1.stderr | ||
shared_rw_borrows_are_weak2.rs | ||
shared_rw_borrows_are_weak2.stderr | ||
shr_frozen_violation1.rs | ||
shr_frozen_violation1.stderr | ||
static_memory_modification.rs | ||
static_memory_modification.stderr | ||
transmute-is-no-escape.rs | ||
transmute-is-no-escape.stderr | ||
unescaped_local.rs | ||
unescaped_local.stderr | ||
unescaped_static.rs | ||
unescaped_static.stderr | ||
zst_slice.rs | ||
zst_slice.stderr |