Commit Graph

1744 Commits

Author SHA1 Message Date
David Tolnay
274085cebd
Manual adjustments 2022-06-21 23:52:24 -07:00
David Tolnay
05893d9026
Bless stderr files after rustfmt 2022-06-21 23:21:37 -07:00
David Tolnay
639f660dde
Manual adjustments 2022-06-21 23:21:12 -07:00
David Tolnay
ba23d37b70
Format tests with rustfmt (288-299 of 299) 2022-06-21 22:58:00 -07:00
David Tolnay
7d09004aee
Format tests with rustfmt (276-287 of 299) 2022-06-21 22:57:47 -07:00
bors
7a1b08e46e Auto merge of #2251 - dtolnay-contrib:rustfmt4, r=RalfJung
Format tests with rustfmt (201-224 of 300)

Extracted from #2097. Last of the easy cases which do not involve moving around a comment.
2022-06-22 04:27:04 +00:00
Ralf Jung
f992099820 fix ICE when const refers to extern static 2022-06-21 21:03:40 -07:00
David Tolnay
f1044d2f77
Bless stderr files after rustfmt 2022-06-21 11:46:10 -07:00
David Tolnay
7326da7ce3
Manual adjustments 2022-06-21 11:46:09 -07:00
David Tolnay
6827ac2f37
Format tests with rustfmt (225-275 of 300) 2022-06-21 11:46:09 -07:00
David Tolnay
7d40530c52
Bless stderr files after rustfmt 2022-06-21 11:32:15 -07:00
David Tolnay
b3a689e008
Manual adjustments 2022-06-21 11:32:14 -07:00
David Tolnay
5490e775df
Format tests with rustfmt (201-224 of 300) 2022-06-21 11:32:06 -07:00
Ralf Jung
1b214a0d12 do not protect SRW items 2022-06-21 09:32:58 -07:00
Ralf Jung
b5bc4e1b0c add tests that fail due to SRW protectors
also do more iterations of weak mem consistency, since now that is no longer the slowest test ;)
2022-06-21 09:32:58 -07:00
Ralf Jung
3348869f42 move nopreempt sync tests to their own file 2022-06-21 09:30:19 -07:00
bors
cbb649adfe Auto merge of #2249 - dtolnay-contrib:rustfmt3, r=oli-obk
Format tests with rustfmt (151-200 of 300)

Extracted from #2097.

This PR is still only doing the easy cases with no comments involved.

In the next PRs after this, I'll start grouping by common comment patterns, e.g. all the cases resembling https://github.com/rust-lang/miri/pull/2097#discussion_r862436672 together in one PR.
2022-06-21 07:39:16 +00:00
bors
332f2894ed Auto merge of #2246 - dtolnay-contrib:rustfmt1, r=oli-obk
Format tests with rustfmt (51-100 of 300)

Extracted from #2097.

Like #2244, this is intended to be "easy" cases which don't involve comments in the vicinity.
2022-06-21 06:57:41 +00:00
David Tolnay
1c66163871
Bless stderr files after rustfmt 2022-06-20 23:50:49 -07:00
David Tolnay
30376ba709
Manual adjustments 2022-06-20 23:50:45 -07:00
David Tolnay
069f5b6615
Format tests with rustfmt (151-200 of 300) 2022-06-20 23:50:40 -07:00
David Tolnay
8efc049a9f
Manual adjustments 2022-06-20 21:36:11 -07:00
bors
bdf2a8a78c Auto merge of #2247 - dtolnay-contrib:rustfmt2, r=RalfJung
Format tests with rustfmt (101-150 of 300)

Extracted from #2097.

Like https://github.com/rust-lang/miri/pull/2244, these are "easy" cases that do not involve moving around comments.
2022-06-21 04:12:42 +00:00
David Tolnay
6b8c371f06
Manual adjustments 2022-06-20 16:09:49 -07:00
David Tolnay
df8d8b655b
Format tests with rustfmt (101-150 of 300) 2022-06-20 16:09:45 -07:00
David Tolnay
fafeccaef7
Bless stdout files after rustfmt 2022-06-20 15:39:50 -07:00
David Tolnay
619813500b
Format tests with rustfmt (51-100 of 300) 2022-06-20 15:39:46 -07:00
David Tolnay
fed5ea8b10
Manual adjustments 2022-06-20 09:00:49 -07:00
David Tolnay
ee132c8d07
Bless stderr files after rustfmt 2022-06-20 02:23:53 -07:00
David Tolnay
66e8751afc
Format tests and benches with rustfmt (1-50 of 300) 2022-06-20 02:23:53 -07:00
David Tolnay
817adda794
Add rustfmt::skip to some files
Five of the files being skipped here are because rustfmt is buggy (see
the error messages below). The others have clearly preferable manual
formatting.

    error[internal]: left behind trailing whitespace
      --> tests/fail/validity/transmute_through_ptr.rs:18:18:1
       |
    18 |
       | ^^^^
       |

    warning: rustfmt has failed to format. See previous 1 errors.

    error[internal]: left behind trailing whitespace
      --> tests/fail/stacked_borrows/illegal_read2.rs:10:10:1
       |
    10 |
       | ^^^^
       |

    warning: rustfmt has failed to format. See previous 1 errors.

    error[internal]: left behind trailing whitespace
      --> tests/fail/stacked_borrows/illegal_read5.rs:15:15:1
       |
    15 |
       | ^^^^
       |

    warning: rustfmt has failed to format. See previous 1 errors.

    error[internal]: left behind trailing whitespace
      --> tests/fail/stacked_borrows/illegal_read1.rs:10:10:1
       |
    10 |
       | ^^^^
       |

    warning: rustfmt has failed to format. See previous 1 errors.

    error[internal]: left behind trailing whitespace
     --> tests/fail/erroneous_const2.rs:9:9:1
      |
    9 |
      | ^^^^
      |

    warning: rustfmt has failed to format. See previous 1 errors.
2022-06-19 17:21:57 -07:00
bors
c4dd3f4ef9 Auto merge of #2228 - cbeuw:futex-fix, r=RalfJung
Prevent futex_wait from actually waiting if a concurrent waker was executed before us

Fixes #2223

Two SC fences were placed in `futex_wake` (after the caller has changed `addr`), and in `futex_wait` (before we read `addr`). This guarantees that `futex_wait` sees the value written to `addr` before the last `futex_wake` call, should one exists, and avoid going into sleep with no one else to wake us up.
ada7b72a87/src/concurrency/weak_memory.rs (L324-L326)

Earlier I proposed to use `fetch_add(0)` to read the latest value in MO, though this isn't the proper way to do it and breaks aliasing: syscall caller may pass in a `*const` from a `&` and Miri complains about write to a `SharedReadOnly` location, causing this test to fail.
ada7b72a87/tests/pass/concurrency/linux-futex.rs (L56-L68)
2022-06-18 15:10:56 +00:00
Ralf Jung
d194e9823c rustup 2022-06-16 11:18:09 -07:00
Andy Wang
56a4c132b6
Reduce the number of iterations 2022-06-13 18:24:19 +01:00
Ralf Jung
8ebdad0615 organize more files into folders, and run the weak-mem consistency test as the very first since it is so slow 2022-06-13 09:08:14 -07:00
bors
9642534a33 Auto merge of #2179 - RalfJung:rustc, r=oli-obk
test ui output also in rustc test suite

`@oli-obk` when I just tried this locally (`./x.py test src/tools/miri --stage 0`), it worked fine. What differences had you seen before?
2022-06-13 13:13:29 +00:00
bors
2bbb70f584 Auto merge of #2203 - RalfJung:deprecate, r=oli-obk
deprecate -Zmiri-allow-uninit-numbers and -Zmiri-allow-ptr-int-transmute

Cc https://github.com/rust-lang/miri/issues/2187 https://github.com/rust-lang/miri/issues/2188
2022-06-13 10:23:42 +00:00
Ralf Jung
6ed05d976e bless 2022-06-11 22:34:01 -07:00
Ralf Jung
069d8fdb71 test for Stacked Borrows error during vtable validation 2022-06-11 17:42:23 -07:00
Andy Wang
b6bcbf76fd
Prevent futex_wait from reading outdated value 2022-06-11 20:45:45 +01:00
InfRandomness
3e03054ef0 Add getpid shim 2022-06-11 11:28:50 +02:00
Ralf Jung
2b35dd514e linux-futex test: ensure we join all threads 2022-06-07 17:03:11 -04:00
Ralf Jung
61f5680da0 add stdlib test for TLS dtor order 2022-06-07 07:58:21 -04:00
Ralf Jung
11a8b3a00b bless tests 2022-06-06 20:17:39 -04:00
Ralf Jung
bf372a8fbc remove warning about thread support being experimental 2022-06-06 20:16:02 -04:00
Ralf Jung
b64c9a0a83 make scheduler preemptive, with configurable preemption rate 2022-06-06 20:16:02 -04:00
Ralf Jung
89edc355e8 bless Windows 2022-06-06 19:48:21 -04:00
Ralf Jung
14913e993b deprecate -Zmiri-allow-uninit-numbers and -Zmiri-allow-ptr-int-transmute 2022-06-06 16:07:30 -04:00
Andy Wang
1b32d14255
Make racy imperfectly overlapping atomic access unsupported instead of UB
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-06-06 19:16:02 +01:00
Andy Wang
1379036713
Simplify known C++20 inconsistency test 2022-06-06 19:16:01 +01:00
Andy Wang
65f39bd5cf
Move tests to new directories 2022-06-06 19:16:01 +01:00
Andy Wang
6d0c76ea1b
Specify only perfectly overlapping accesses can race 2022-06-06 19:16:01 +01:00
Andy Wang
8215702d5a
Refer to GitHub issue on overwritten init value 2022-06-06 19:16:00 +01:00
Andy Wang
4a07f78dad
Forbade all racing mixed size atomic accesses 2022-06-06 19:16:00 +01:00
Andy Wang
a7c832b04a
Wording improvements
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-06-06 19:15:59 +01:00
Andy Wang
6a73dedb36
Update experimental threading warning 2022-06-06 19:15:59 +01:00
Andy Wang
bfa56454e9
Split extra_cpp tests into sound and unsafe 2022-06-06 19:15:58 +01:00
Andy Wang
613d60db0b
Allow non-racy mixed size accesses 2022-06-06 19:15:58 +01:00
Andy Wang
7dcb19ead4
Add rust-only operation tests 2022-06-06 19:15:57 +01:00
Andy Wang
dafd813c16
Move transmute into a separate function 2022-06-06 19:15:57 +01:00
Andy Wang
5ddd4eff03
Spelling, punctuation and grammar
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-06-06 19:15:56 +01:00
Andy Wang
31c01415cb
Replace yield_now() with spin loop hint 2022-06-06 19:15:55 +01:00
Andy Wang
e2002b4c65
Amend experimental thread support warnings 2022-06-06 19:15:55 +01:00
Andy Wang
92145373c3
Put the initialisation value into the store buffer 2022-06-06 19:15:55 +01:00
Andy Wang
6b54c92377
Throw UB on imperfectly overlapping access 2022-06-06 19:15:54 +01:00
Andy Wang
13e3465346
Reduce the number of runs in consistency tests 2022-06-06 19:15:25 +01:00
Andy Wang
7d874db213
Add tests showing weak memory behaviours 2022-06-06 19:15:25 +01:00
Andy Wang
f729f28925
Move cpp20_rwc_syncs into compile-fail 2022-06-06 19:15:23 +01:00
Andy Wang
32627d5abb
Disable weak memory emulation on scheduler-dependent data race tests 2022-06-06 19:15:23 +01:00
Andy Wang
a71b10381e
Add imperfectly overlapping test 2022-06-06 19:15:22 +01:00
Andy Wang
cf266584b7
Comment out and provide context to C++20 test 2022-06-06 19:15:21 +01:00
Andy Wang
e7698f4f07
Implement weak memory emulation 2022-06-06 19:15:20 +01:00
Andy Wang
16315b1540
Add test cases 2022-06-06 19:15:20 +01:00
Ralf Jung
84edb76e26 make output bitwidth-independent 2022-06-06 12:35:48 -04:00
Ralf Jung
7f5cfa54d9 port some tests away from flags we want to remove 2022-06-06 11:44:36 -04:00
Ralf Jung
34d4928dce addr no longer exposes :) 2022-06-06 11:43:25 -04:00
Ralf Jung
63625b0397 adjust for better provenance control 2022-06-06 11:43:25 -04:00
bors
2eae474673 Auto merge of #2197 - RalfJung:round-robin, r=RalfJung
make Miri's scheduler proper round-robin

When thread N blocks or yields, we activate thread N+1 next, rather than always activating thread 0. This should guarantee that as long as all threads regularly yield, each thread eventually takes a step again.

Fixes the "multiple loops that yield playing ping-pong" part of https://github.com/rust-lang/miri/issues/1388.
`@cbeuw` I hope this doesn't screw up the scheduler-dependent tests you are adding in your PR.
2022-06-05 18:37:07 +00:00
Ralf Jung
34b359be1e more spin-loop-tests 2022-06-05 14:36:49 -04:00
Ralf Jung
47745380cd make Miri's scheduler proper round-robin 2022-06-05 14:22:00 -04:00
bors
0fbe710012 Auto merge of #2194 - RalfJung:race, r=RalfJung
add interesting data race test

This interesting testcase came up in https://github.com/rust-lang/miri/issues/2192.
2022-06-05 16:38:53 +00:00
Ralf Jung
b2832008e2 add interesting data race test 2022-06-05 12:38:34 -04:00
Ralf Jung
4a852126b9 do not use int2ptr casts in strict provenance tests 2022-06-05 11:47:39 -04:00
Ralf Jung
2b9c45f96f delete stale stderr files 2022-06-03 08:10:09 -04:00
Ralf Jung
bc5da2b5a7 test ui output also in rustc test suite 2022-06-02 21:09:10 -04:00
DrMeepster
0b7a148ad9 add test for backtrace with global allocator 2022-06-01 17:32:01 -07:00
Ralf Jung
3d634c975c rename test suite directories 2022-06-01 10:53:38 -04:00
Oli Scherer
4b100a1b58 Check that diagnostics happen in the line that they are annotated for 2022-06-01 11:47:54 +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
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
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
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
80bf204848 don't configure the same regex twice 2022-05-30 12:30:58 +02:00
Ralf Jung
e37dfa6d91 ui_test: support multiple filters 2022-05-30 10:27:51 +02:00
Ben Kimock
9a1475dbe2 Save a created event for zero-size reborrows 2022-05-29 16:45:26 -04:00
Oli Scherer
1b7e278922 Reintroduce path filters 2022-05-27 11:43:14 +00:00