Commit Graph

5453 Commits

Author SHA1 Message Date
Ralf Jung
a38f02c44c isolated operations return EPERM; tweak isolation hint 2021-06-09 18:24:59 +02:00
bors
31c1afac5d Auto merge of #1797 - atsmtat:env-isolation, r=RalfJung
fix: avoid stopping machine upon running env operations in isolation

get and set current dir operations used to halt the machine by
throwing an exception in isolation mode. This change updates them to
return a dummy `NotFound` error instead, and keep the machine running.

I started with a custom error using `ErrorKind::Other`, but since it
can't be mapped to a raw OS error, I dropped it. `NotFound` kind of make
sense for get operations, but not much for set operations. But that's
the only error supported for windows currently.
2021-06-09 15:30:50 +00:00
Smit Soni
ba64f485c8 Fix parameter of io error helper function
`set_last_error_from_io_error` works with only the error kind, and
discards the payload. Fix its signature to make it explicit.
2021-06-09 06:28:35 -07:00
Smit Soni
892f706ce5 Add a support to execute isolated op without halting
In user interface, added a new flag `-Zmiri-isolation-error` which
takes one of the four values -- hide, warn, warn-nobacktrace, and
abort. This option can be used to configure Miri to either abort or
return an error code upon executing isolated op. If not aborted, Miri
prints a warning, whose verbosity can be configured using this flag.

In implementation, added a new enum `IsolatedOp` to capture all the
settings related to ops requiring communication with the
host. Old `communicate` flag in both miri configs and machine
stats is replaced with a new helper function `communicate()` which
checks `isolated_op` internally.

Added a new helper function `reject_in_isolation` which can be called
by shims to reject ops according to the reject_with settings. Use miri
specific diagnostics function `report_msg` to print backtrace in the
warning. Update it to take an enum value instead of a bool, indicating
the level of diagnostics.

Updated shims related to current dir to use the new APIs. Added a new
test for current dir ops in isolation without halting machine.
2021-06-09 05:50:52 -07:00
bors
f73db5ce6b Auto merge of #1827 - l4l:patch-1, r=RalfJung
Specify miri toolchain for CI example

In particular current example doesn't work if you have a rust-toolchain file in the project.
2021-06-09 08:00:57 +00:00
Kitsu
c6bcb4d3c0 Specify miri toolchain for CI example 2021-06-09 10:48:43 +03:00
bors
c8713c2f9f Auto merge of #1828 - hyd-dev:rustup, r=RalfJung
Update `Box<Any>` to `Box<dyn Any>` in `catch_panic.stderr`

https://github.com/rust-lang-ci/rust/runs/2771244703#step:25:9487
cc rust-lang/rust#86133 rust-lang/rust#86074
2021-06-08 15:15:05 +00:00
hyd-dev
23c0495ebd
Update Box<Any> to Box<dyn Any> in catch_panic.stderr 2021-06-08 22:18:27 +08:00
bors
81ee877f71 Auto merge of #1826 - hyd-dev:rustup, r=RalfJung
Update `cargo-miri` tests

The test output has been changed recently (likely by rust-lang/rust#84863) and caused a test failure: https://github.com/rust-lang/miri/runs/2761591139#step:8:1228
2021-06-07 09:50:44 +00:00
hyd-dev
9549faa81c
Update cargo-miri tests 2021-06-07 16:53:31 +08:00
bors
28fbf81c40 Auto merge of #1823 - hyd-dev:extern-crate-std, r=RalfJung
Detect `std` by checking if the crate defines `#[lang = "start"]` rather than string comparison

I also considered to compare the crate name with `sym::std`, but it's easy to name any crate `std` by using `--crate-name std`, so I don't think that is robust enough.

Note that this only checks the crate, it does not check whether the call is in `sys::unix` or `sys::windows`, unlike the previous implementation, but I think it's already robust enough.

Fixes #1821.
2021-06-06 08:34:12 +00:00
Ralf Jung
0ece55d748
expand comment 2021-06-06 10:33:46 +02:00
hyd-dev
d7aff96053
Remove 2 tests 2021-06-06 11:22:25 +08:00
hyd-dev
3871c493b2
in_std -> frame_in_std 2021-06-06 11:21:20 +08:00
hyd-dev
545101040d
Don't unwrap() in in_std() 2021-06-06 11:12:13 +08:00
hyd-dev
879000b133
Detect std by checking if the crate defines #[lang = "start"] rather than string comparison 2021-06-06 11:12:05 +08:00
bors
28717a0e90 Auto merge of #1776 - hyd-dev:1170, r=RalfJung
Implement calls to exported symbols (#1170)

Closes #1170.
2021-06-03 15:59:56 +00:00
Ralf Jung
57e4f1d285
fix typo 2021-06-03 17:47:34 +02:00
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
ba3b11fa42
Remove some tests 2021-06-03 14:16:58 +08:00
hyd-dev
e4e6c25f67
Remove FIXME in tests/compile-fail/panic/bad_unwind.rs 2021-06-03 13:39:33 +08: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
hyd-dev
a952787163
Improve tests 2021-05-31 11:57:16 +08:00
hyd-dev
160bc68cae
Move the test to src/main.rs 2021-05-31 11:57:16 +08:00
hyd-dev
45832d4031
Remove duplicated "foreign function" 2021-05-31 11:57:15 +08:00
hyd-dev
e026ad584d
Use unwrap_or_else() 2021-05-31 11:57:15 +08:00
hyd-dev
b054a19f94
We don't need to check SymbolExportLevel 2021-05-31 11:57:14 +08:00
hyd-dev
382295cd47
Move check_abi() into EvalContextExt 2021-05-31 11:15:31 +08:00
hyd-dev
ddc2ee9db6
Move -Zmiri-disable-abi-check in README 2021-05-31 11:15:31 +08:00
hyd-dev
41f33a64f8
Implement calls to exported symbols 2021-05-31 11:15:29 +08:00
hyd-dev
71f4140550
Add -Zmiri-disable-abi-check 2021-05-31 11:14:23 +08: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