Commit Graph

6215 Commits

Author SHA1 Message Date
Ralf Jung
61265f5f19 fmt 2022-06-01 06:42:11 -04:00
Ralf Jung
1571571e38 also avoid rebuilding cached RTIM 2022-06-01 06:31:08 -04:00
Ralf Jung
81d661f134 bump xargo version, and tweak xargo caching 2022-06-01 06:28:27 -04:00
bors
47771d6b78 Auto merge of #2173 - RalfJung:rustlib, r=oli-obk
different strategy for normalizing Rust stdlib path

`-Zremap-cwd-prefix` has some [unintended side-effects](https://github.com/rust-lang/miri/issues/2172), so we could use regexp-based normalization instead. Unfortunately, this will fail if the user's home directory contains a space.

Fixes https://github.com/rust-lang/miri/issues/2172
2022-06-01 07:22:31 +00:00
Ralf Jung
8997db2ec9 paper over platform differences 2022-05-31 19:00:14 -04:00
Ralf Jung
9a448744a2 different strategy for normalizing Rust stdlib path 2022-05-31 18:37:32 -04:00
bors
1c11fc64b1 Auto merge of #2171 - RalfJung:less-dup, r=RalfJung
reduce some code duplication

`@saethlin` this is what I meant. I had to fiddle a bit to make the lifetimes work, but now it passes rustc. :)
2022-05-31 14:37:52 +00:00
Ralf Jung
62c48b2998 fix some lifetime names 2022-05-31 08:45:01 -04:00
Ralf Jung
eb6d4cdac0 reduce some code duplication 2022-05-31 08:43:17 -04:00
bors
360186b114 Auto merge of #2166 - RalfJung:tests, r=oli-obk
ui_test tweaks

- support multiple filters
- make `./miri check` also cover ui_test
- Run opt-level=4 tests again, but only the "run" tests

r? `@oli-obk`
2022-05-31 05:11:43 +00:00
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
bors
10cb09c907 Auto merge of #2169 - RalfJung:rustup, r=RalfJung
Rustup

Cc https://github.com/rust-lang/rust/issues/97563
2022-05-30 23:22:06 +00:00
Ralf Jung
7fb5110160 normalize away some more line numbers 2022-05-30 19:21:22 -04:00
Ralf Jung
d455421edc rustup 2022-05-30 19:19:39 -04:00
bors
9d418a3f03 Auto merge of #2168 - RalfJung:power, r=RalfJung
use is_power_of_two where appropriate
2022-05-30 22:01:53 +00:00
Ralf Jung
a8e457fad1 use is_power_of_two where appropriate 2022-05-30 17:47:16 -04:00
bors
57d8206093 Auto merge of #2165 - saethlin:more-clocks, r=RalfJung
Add support for _COARSE clocks

Original idea does not work, so I'm just going to try expanding support to include the `_COARSE` clocks.

The original motivation for this PR is that the test suite for the crate [`minstant`](https://crates.io/crates/minstant) reports UB, because it tries to use a clock type Miri didn't support, but never checked for an error code and so just used the uninit `libc::timespec`. So, that's technically a bug in `minstant`, but outside of Miri you'd have to be using an incredibly old Linux to ever see an `EINVAL` so the more helpful thing for Miri to do is behave like a newer Linux.

So now we don't detect UB in `minstant`, but we have a test failure:
```
failures:

---- src/instant.rs - instant::Instant::as_unix_nanos (line 150) stdout ----
Test executable failed (exit status: 101).

stderr:
thread 'main' panicked at 'assertion failed: (instant.as_unix_nanos(&anchor) as i64 - expected as i64).abs() < 1_000_000', src/instant.rs:11:1
```
I'm having trouble getting my head around the code in `minstant` that's involved in this test, but as far as I can tell from the man pages, these `_COARSE` clocks meet the requirements.

Closes https://github.com/rust-lang/miri/issues/1983 at least as best as I can.
2022-05-30 21:41:41 +00:00
Ben Kimock
ba9391334e Add support for _COARSE clocks, spruce up comments 2022-05-30 11:26:10 -04:00
Ralf Jung
962957f11f make it possible to test more of ui_test 2022-05-30 12:56:34 +02:00
Ralf Jung
4d80880854 fmt 2022-05-30 12:32:49 +02:00
Ralf Jung
80bf204848 don't configure the same regex twice 2022-05-30 12:30:58 +02:00
Ralf Jung
b9d79a25ba also 'check' the test suite 2022-05-30 12:30:54 +02:00
Ralf Jung
86e53f41b0 print reason for ignoring 2022-05-30 10:33:48 +02:00
Ralf Jung
4e91c2e368 ui_test: printing more consistent with compiletest
distinguish "ignored" from "filtered out"
2022-05-30 10:33:33 +02:00
Ralf Jung
8694e656be test mir-opt-level=4 again on run tests 2022-05-30 10:28:07 +02:00
Ralf Jung
e37dfa6d91 ui_test: support multiple filters 2022-05-30 10:27:51 +02:00
bors
065ff89e33 Auto merge of #2158 - rust-lang:gesundheit, r=RalfJung
Avoid error patterns matching themselves

fixes #2156
fixes https://github.com/rust-lang/miri/issues/2155

this will be obsolete the moment I extract that data from json diagnostics instead of just regexing the stderr.
2022-05-30 07:52:48 +00:00
Oli Scherer
3832227734 Forward CARGO_BUILD_FLAGS to ui_test test suite 2022-05-30 07:26:47 +00:00
Ben Kimock
9a1475dbe2 Save a created event for zero-size reborrows 2022-05-29 16:45:26 -04:00
bors
5c3e4b6556 Auto merge of #2162 - RalfJung:rustup, r=RalfJung
rustup

Cc https://github.com/rust-lang/rust/issues/97486
2022-05-29 12:07:14 +00:00
Ralf Jung
7cd5fc3de3 rustup 2022-05-29 14:06:35 +02:00
bors
e45f2f0d5f Auto merge of #2161 - RalfJung:rustup, r=RalfJung
rustup

Locally tests pass but rustc CI says they fail, let's see what happens...

Also clarify docs of cmpxchg_weak_failure_rate (Cc https://github.com/rust-lang/miri/issues/2160).
2022-05-29 06:34:31 +00:00
Ralf Jung
424841817a disable optimized tests for now 2022-05-29 08:34:10 +02:00
Ralf Jung
1226147414 rustup 2022-05-28 18:08:13 +02:00
Oli Scherer
740574206b Commit our ui test crate's cargo lockfile 2022-05-27 14:24:38 +00:00
Oli Scherer
1b7e278922 Reintroduce path filters 2022-05-27 11:43:14 +00:00
Oli Scherer
10e06be15a Don't export private things 2022-05-27 11:36:18 +00:00
Oli Scherer
6b18cf0e20 Self-descriptive verbosity 2022-05-25 18:26:33 +00:00
Oli Scherer
a51ae9fb2c Use unit tests to keep private things private 2022-05-25 18:26:33 +00:00
Oli Scherer
25b7a12625 Properly name a test 2022-05-25 18:26:33 +00:00
Oli Scherer
d466eb8f66 Explain Comments::parse arguments 2022-05-25 18:26:33 +00:00
Oli Scherer
e4d6c00aa2 Run tests for ui_test together with miri test 2022-05-25 18:26:33 +00:00
Oli Scherer
8acfbc3b33 Update all tests 2022-05-25 18:26:33 +00:00
Oli Scherer
b64a1c46c6 Make the file path of the failure more visible to be able to click it faster 2022-05-25 18:26:33 +00:00
Oli Scherer
21795f3ce4 Fix annotations matching themselves 2022-05-25 18:26:33 +00:00
Oli Scherer
23bbe2bce7 Reproduce #2156 2022-05-25 18:26:33 +00:00
bors
e7c2ab6d5b Auto merge of #2157 - RalfJung:tests, r=oli-obk
tweak new test suite output

- Make the entire "## Running ui tests ..." green, including the target.
- Fix double-space in `testname.rs  .. ok`.
- Make the final summary a bit more like compiletest-rs, in particular the newlines around it
- Use the term "ignored" consistently, rather than "skipped"

r? `@oli-obk`
2022-05-25 17:39:53 +00:00
Ralf Jung
a6b5b0e4ff tweak new test suite output 2022-05-25 18:27:20 +02:00
bors
5832dd1c0c Auto merge of #2151 - RalfJung:numbers, r=oli-obk
enable number validity checking and ptr::invalid checking by default

This removes the `-Zmiri-check-number-validity` flag, enabling its effects by default. (We don't error when the flag is passed, for backwards compatibility.) We also enable by default that transmuting an integer to a pointer now creates a pointer with `None` provenance, which is invalid to dereference (and, in the case of a function pointer, invalid to call). I did this together since it is all related to ptr2int/int2ptr transmutation.

Two new flags are added to optionally take back these stricter checks:
- `-Zmiri-allow-uninit-numbers` makes Miri accept uninit data in integers and floats
- `-Zmiri-allow-ptr-int-transmute` makes Miri accept pointers (provenance data) in integers and floats, *and* makes Miri treat int2ptr transmutes as equivalent to a cast.

The flag names make sense IMO, but they are somewhat inconsistent with our existing flags since we usually call things `-Zmiri-disable-$CHECK` rather than `-Zmiri-allow-$THING`. But `-Zmiri-disable-uninit-number-check` sounds silly?

(Whenever I say "transmute" this includes union and pointer based type punning.)
Cc `@saethlin` I hope this won't break everything?^^ I think the most risky part is the int2ptr transmute aspect, in particular around function pointers where no `as` casts are possible. The correct pattern is to first cast to a raw ptr and then transmute that to a fn ptr. We should probably document this better, in the `transmute` documentation and maybe in the documentation for the `fn()` type. I should run this PR against the std test suite before we land it.
r? `@oli-obk`

- [x] Ensure stdlib docs recommend "usize -> raw ptr -> fn ptr" for int-to-fnptr casts: https://github.com/rust-lang/rust/pull/97321
- [x] Run the stdlib test suite
2022-05-25 14:35:06 +00:00
Ralf Jung
8c42ef1dee enable number validity checking and ptr::invalid checking by default 2022-05-25 16:17:41 +02:00