Commit Graph

5424 Commits

Author SHA1 Message Date
bors
44122f9ff2 Auto merge of #1824 - Pointerbender:strings-test, r=RalfJung
added a strings.rs regression test case for potential future UB

This PR adds a regression test for the aliasing rules of a `Unique<T>` pointer.
    At the time of writing this test case, Miri does not treat `Unique<T>`
    pointers as a special case, these are treated like any other raw pointer.
    However, there are existing Github issues which may lead to `Unique<T>`
    becoming a special case through asserting unique ownership over the pointee:
    - https://github.com/rust-lang/unsafe-code-guidelines/issues/258
    - https://github.com/rust-lang/unsafe-code-guidelines/issues/262
    In the new test case, the calls to `String::remove` and `String::insert[_str]` follow
    code paths that would trigger undefined behavior in case `Unique<T>`
    would ever assert semantic ownership over the pointee. Internally,
    these methods call `self.vec.as_ptr()` and `self.vec.as_mut_ptr()` on
    the vector of bytes that are backing the `String`. That `Vec<u8>` holds a
    `Unique<u8>` internally. The second call to `Vec::as_mut_ptr(&mut self)`
    would then invalidate the pointers derived from `Vec::as_ptr(&self)`.
    Note that as long as `Unique<T>` is treated like any other raw pointer,
    this test case should pass. It is merely here as a canary test for
    potential future undefined behavior.
2021-06-03 15:42:41 +00:00
Pointerbender
386863ac53 added a strings.rs regression test case for potential future UB 2021-06-03 17:25:23 +02:00
bors
ef99830880 Auto merge of #1816 - Pointerbender:slices-tests, r=RalfJung
regression tests for pointer invalidation in core library slice methods

A fix for a pointer invalidation bug in `<[T]>::copy_within` has [landed](https://github.com/rust-lang/rust/pull/85610) on the Rust master branch. This PR updates the `rust-version` file to the latest master commit hash and adds extra tests to the Miri test suite to ensure that regressions of this type of bug can be detected for various slice methods with the `-Zmiri-track-raw-pointers` flag.

I took the liberty of adding 2 extra  `#![feature]` attributes at the top of `slices.rs`, since there already was one unstable feature. I hope this is okay 😄

One thing I noticed when running the entire Miri test suite with `MIRIFLAGS="-Zmiri-track-raw-pointers" ./miri test` is that there are currently failing tests on the master branch:

```
failures:
    [ui] run-pass/align.rs
    [ui] run-pass/box.rs
    [ui] run-pass/concurrency/simple.rs
    [ui] run-pass/libc.rs
    [ui] run-pass/ptr_int_casts.rs
    [ui] run-pass/stacked-borrows/int-to-ptr.rs

test result: FAILED. 199 passed; 6 failed; 1 ignored; 0 measured; 0 filtered out; finished in 12.95s
```

These failures were not fixed in this PR and already existed prior to this PR. I haven't investigated these yet, but am interested in helping out if possible!

Thanks!
2021-06-03 08:52:57 +00:00
bors
5dde0fe6de Auto merge of #1822 - hyd-dev:rustup, r=RalfJung
`original_crate_name` -> `crate_name`

`original_crate_name` was removed in rust-lang/rust#85904, and according to that PR, it "had the exact same implementation" as `crate_name`.

cc rust-lang/rust#85946
2021-06-03 08:35:45 +00:00
hyd-dev
647ee17b40
original_crate_name -> crate_name 2021-06-03 10:22:31 +08:00
Pointerbender
e21dae71c8 removed unintentional file change due to whitespace 2021-06-02 15:38:12 +02:00
Pointerbender
c6dbe5cdca use references so that potential aliasing bugs are triggered during regression test 2021-06-02 15:36:18 +02:00
Pointerbender
b8aba11de3 regression tests for pointer invalidation in core library slice methods 2021-06-02 15:36:18 +02:00
bors
453affaaa1 Auto merge of #1820 - Aaron1011:rustup-const-err, r=RalfJung
Rustup for const_err changes
2021-05-31 16:04:22 +00:00
Aaron Hill
73700bc01c
Rustup for const_err changes 2021-05-31 10:50:25 -05:00
bors
178ae8e44c Auto merge of #1791 - Aaron1011:measureme, r=RalfJung
Add `measureme` integration for profiling the interpreted program

This PR uses the `measureme` crate to profile the call stack of the
program being interpreted by Miri. This is accomplished by starting a
measureme 'event' when we enter a function call, and ending the event
when we exit the call. The `measureme` tooling can be used to produce a
call stack from the generated profile data.

Limitations:
* We currently record every single entry/exit. This might generate very
  large profile outputs for programs with a large number of function
  calls. In follow-up work, we might want to explore sampling (e.g. only
  recording every N function calls).
* This does not integrate very well with Miri's concurrency support.
  Each event we record starts when we push a frame, and ends when we pop
  a frame. As a result, the timing recorded for a particular frame will include all of the work Miri does before that frame completes, including executing another thread.

The `measureme` integration is off by default, and must be enabled via
`-Zmiri-measureme=<output_name>`
2021-05-30 15:14:23 +00:00
Ralf Jung
c89a5d62ee
add comment to debug impl 2021-05-30 17:13:49 +02:00
Aaron Hill
0317e5bfd6
Address more review comments 2021-05-30 10:04:57 -05:00
Aaron Hill
20f1b2a969
Run fmt 2021-05-29 17:16:12 -05:00
Aaron Hill
16f469280e
Address review comments 2021-05-29 17:10:54 -05:00
Aaron Hill
2166eaed90
Use active thread id 2021-05-29 17:01:54 -05:00
Aaron Hill
7e9da8d30e
Add measureme integration for profiling the interpreted program
This PR uses the `measureme` crate to profile the call stack of the
program being interpreted by Miri. This is accomplished by starting a
measureme 'event' when we enter a function call, and ending the event
when we exit the call. The `measureme` tooling can be used to produce a
call stack from the generated profile data.

Limitations:
* We currently record every single entry/exit. This might generate very
  large profile outputs for programs with a large number of function
  calls. In follow-up work, we might want to explore sampling (e.g. only
  recording every N function calls).
* This does not integrate very well with Miri's concurrency support.
  Each event we record starts when we push a frame, and ends when we pop
  a frame. As a result, switching between virtual threads will cause
  events from different threads to be interleaved. Additionally, the
  recorded for a particular frame will include all of the work Miri does
  before that frame completes, including executing another thread.

The `measureme` integration is off by default, and must be enabled via
`-Zmiri-measureme=<output_name>`
2021-05-29 17:01:52 -05:00
bors
4fa9363ebb Auto merge of #1812 - hyd-dev:85546, r=RalfJung
Fix toolstate for rust-lang/rust#85546

cc rust-lang/rust#85780
2021-05-28 20:11:11 +00:00
hyd-dev
9b2d42587f
unwind is no longer Option<BasicBlock> 2021-05-28 22:08:51 +08:00
bors
76f5855842 Auto merge of #1817 - hyd-dev:doctest, r=RalfJung
Skip doctests of `proc-macro` crates

Fixes #1813.

Verified that the newly added tests failed without the `cargo-miri` change and pass with normal `cargo test`.
2021-05-27 21:44:16 +00:00
hyd-dev
d1de0843ed
Change preexisting "doc-test" to "doctest" 2021-05-27 19:48:07 +08:00
hyd-dev
43db2aa5a9
Change "Doc-tests" in the comment to "Doctests" 2021-05-27 19:45:10 +08:00
hyd-dev
ffff7ff8a6
Use compile_error! instead of use num_cpus 2021-05-27 19:22:42 +08:00
hyd-dev
773eb1e970
"doc-tests" -> "doctests" 2021-05-27 18:45:21 +08:00
bors
0f03a705a2 Auto merge of #1819 - scottmcm:patch-1, r=RalfJung
Add `copy_within` to the SB trophy case
2021-05-27 07:21:49 +00:00
scottmcm
97b2824ada
Add copy_within to the SB trophy case 2021-05-27 00:14:13 +00:00
hyd-dev
f42a6d1026
Skip doctests of proc-macro crates 2021-05-27 07:03:05 +08:00
bors
62046bf8b4 Auto merge of #1814 - RalfJung:rustup, r=RalfJung
avoid unnecessary RefCell calls

Blocked on https://github.com/rust-lang/rust/pull/85599
2021-05-23 16:08:53 +00:00
Ralf Jung
a03f700fc9 rustup 2021-05-23 18:05:50 +02:00
Ralf Jung
393ce98b32 fix a Stacked Borrows test whose output changed 2021-05-23 18:04:13 +02:00
Ralf Jung
c60efa0c69 allocate backtrace strings mutably 2021-05-23 18:04:13 +02:00
Ralf Jung
9e0e9386a6 better approach to skip ZST reborrows 2021-05-23 18:04:13 +02:00
Ralf Jung
e09c571eec avoid some borrow_mut calls in data_race 2021-05-23 18:04:13 +02:00
Ralf Jung
543777acbd avoid unnecessary RefCell calls in Stacked Borrows 2021-05-23 18:04:13 +02:00
bors
cf7e4b9df6 Auto merge of #1815 - RalfJung:rustup2, r=RalfJung
rustup

Cc https://github.com/rust-lang/rust/issues/85591
2021-05-23 10:40:13 +00:00
Ralf Jung
d77d95d0a8 rustup 2021-05-23 12:39:27 +02:00
bors
10c495643a Auto merge of #1811 - RalfJung:less-rc, r=RalfJung
get rid of some `Rc`

Now that the memory access hooks get references to `MemoryExtra`, we can avoid refcounting for the global state of Stacked Borrows and the data race detector.
2021-05-22 12:56:51 +00:00
Ralf Jung
c73f8b1097 fmt 2021-05-22 14:55:33 +02:00
Ralf Jung
1bbd6e609c get rid of Rc in data_race 2021-05-22 14:47:14 +02:00
Ralf Jung
ca7283d746 get rid of Rc in Stacked Borrows 2021-05-22 13:24:08 +02:00
bors
3a24958128 Auto merge of #1809 - RalfJung:rustup, r=RalfJung
rustup
2021-05-20 17:54:56 +00:00
Ralf Jung
c151af5cf5 rustup 2021-05-20 13:32:18 +02:00
bors
b0e5d5f1ef Auto merge of #1804 - RalfJung:ptrless-allocs, r=RalfJung
update for Memory API changes

The Miri side of https://github.com/rust-lang/rust/pull/85376.
2021-05-19 14:34:39 +00:00
Ralf Jung
aba96b82b4 fix write_os_str_to_wide_str 2021-05-19 16:34:14 +02:00
Ralf Jung
e4a27150cb fmt 2021-05-19 16:10:28 +02:00
Ralf Jung
d1e5eeebdf rustup 2021-05-19 15:58:05 +02:00
Ralf Jung
dd404cc92e avoid importing C functions in alloc_write_race test 2021-05-19 15:27:58 +02:00
Ralf Jung
801a1744cd update for Memory API changes 2021-05-19 15:27:58 +02:00
bors
cda0b07121 Auto merge of #1808 - RalfJung:fmt, r=oli-obk
add (bors-ignored) formatting check job
2021-05-19 12:19:24 +00:00
Ralf Jung
74ae89e6ca over 'default' instead of 'override' (consistent with main build job) 2021-05-19 10:58:29 +02:00