rust/tests/compile-fail/stacked_borrows
bors aa589d3dc7 Auto merge of #2145 - saethlin:zero-size-creation, r=RalfJung
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.
2022-05-30 23:43:51 +00:00
..
alias_through_mutation.rs
alias_through_mutation.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
aliasing_mut1.rs
aliasing_mut1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
aliasing_mut2.rs
aliasing_mut2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
aliasing_mut3.rs
aliasing_mut3.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
aliasing_mut4.rs
aliasing_mut4.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
box_exclusive_violation1.rs
box_exclusive_violation1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
buggy_as_mut_slice.rs
buggy_as_mut_slice.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
buggy_split_at_mut.rs
buggy_split_at_mut.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
deallocate_against_barrier1.rs
deallocate_against_barrier1.stderr normalize away some more line numbers 2022-05-30 19:21:22 -04:00
deallocate_against_barrier2.rs
deallocate_against_barrier2.stderr normalize away some more line numbers 2022-05-30 19:21:22 -04:00
illegal_read1.rs
illegal_read1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_read2.rs
illegal_read2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_read3.rs enable number validity checking and ptr::invalid checking by default 2022-05-25 16:17:41 +02:00
illegal_read3.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_read4.rs
illegal_read4.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_read5.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_read5.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_read6.rs
illegal_read6.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_read7.rs
illegal_read7.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_read8.rs
illegal_read8.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_write1.rs
illegal_write1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_write2.rs
illegal_write2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_write3.rs Print more in SB error diagnostics 2022-03-16 20:12:04 -04:00
illegal_write3.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_write4.rs
illegal_write4.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_write5.rs
illegal_write5.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
illegal_write6.rs
illegal_write6.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
interior_mut1.rs
interior_mut1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
interior_mut2.rs
interior_mut2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
invalidate_against_barrier1.rs
invalidate_against_barrier1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
invalidate_against_barrier2.rs
invalidate_against_barrier2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
issue-miri-1050-1.rs adjust Miri to Pointer type overhaul 2021-07-16 10:10:12 +02:00
issue-miri-1050-1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
issue-miri-1050-2.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
issue-miri-1050-2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
load_invalid_mut.rs make sure we find some things without validation or stacked borrows, respectively 2020-04-14 10:23:47 +02:00
load_invalid_mut.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
load_invalid_shr.rs make sure we find some things without validation or stacked borrows, respectively 2020-04-14 10:23:47 +02:00
load_invalid_shr.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
mut_exclusive_violation1.rs
mut_exclusive_violation1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
mut_exclusive_violation2.rs
mut_exclusive_violation2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
outdated_local.rs
outdated_local.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
pass_invalid_mut.rs
pass_invalid_mut.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
pass_invalid_shr.rs
pass_invalid_shr.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
pointer_smuggling.rs
pointer_smuggling.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
raw_tracking.rs Print more in SB error diagnostics 2022-03-16 20:12:04 -04:00
raw_tracking.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
return_invalid_mut_option.rs
return_invalid_mut_option.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
return_invalid_mut_tuple.rs
return_invalid_mut_tuple.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
return_invalid_mut.rs
return_invalid_mut.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
return_invalid_shr_option.rs
return_invalid_shr_option.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
return_invalid_shr_tuple.rs
return_invalid_shr_tuple.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
return_invalid_shr.rs
return_invalid_shr.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
shared_rw_borrows_are_weak1.rs
shared_rw_borrows_are_weak1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
shared_rw_borrows_are_weak2.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
shared_rw_borrows_are_weak2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
shr_frozen_violation1.rs Print more in SB error diagnostics 2022-03-16 20:12:04 -04:00
shr_frozen_violation1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
static_memory_modification.rs Update all tests 2022-05-25 18:26:33 +00:00
static_memory_modification.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
transmute-is-no-escape.rs
transmute-is-no-escape.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
unescaped_local.rs
unescaped_local.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
unescaped_static.rs
unescaped_static.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
zst_slice.rs add -Zmiri-strict-provenance 2022-04-01 14:10:24 -04:00
zst_slice.stderr Save a created event for zero-size reborrows 2022-05-29 16:45:26 -04:00