Commit Graph

3156 Commits

Author SHA1 Message Date
Ralf Jung
c672c35ad6 format > to_string 2022-09-21 15:25:30 +02:00
Ralf Jung
33284ec099 remove unnecessary to_string 2022-09-21 15:24:06 +02:00
Oli Scherer
4f357956b8 Only support libffi on unix for now 2022-09-21 12:48:47 +00:00
Oli Scherer
369efd0d8e Lint fixes 2022-09-21 09:34:01 +00:00
bors
dfa6f8894e Auto merge of #2552 - RalfJung:env-term, r=oli-obk
remove Windows TERM env var hack and -Zmiri-env-exclude

The hack should not be needed any more since https://github.com/rust-lang/rust/pull/100206. And that also mostly removes the need for `-Zmiri-env-exclude` -- if needed, users can still achieve the same by running `(unset VAR; cargo miri test)`.

I am keeping `-Zmiri-env-forward` since it is still useful, e.g. to have RUST_BACKTRACE=full set in an otherwise deterministic execution.

`@rust-lang/miri` any objections to removing `-Zmiri-env-exclude`?
2022-09-20 07:16:58 +00:00
Ralf Jung
bacf131acc remove Windows TERM env var hack and -Zmiri-env-exclude 2022-09-20 08:51:13 +02:00
Ralf Jung
7687b7e510 rustup, fmt 2022-09-20 08:41:44 +02:00
Ralf Jung
5ca1f85a2d make some names more consistent 2022-09-20 08:37:20 +02:00
Ralf Jung
cc149c7691 put a tcx into the Machine so that we have to pass around fewer things 2022-09-20 08:37:20 +02:00
Ralf Jung
3cb27f584b avoid thread-local var indirection for non-halting diagnostics 2022-09-20 08:37:20 +02:00
Ralf Jung
f0c6f0d1bf rustup 2022-09-19 22:32:36 +02:00
bors
fd05ff5290 Auto merge of #2546 - RalfJung:comments, r=RalfJung
add/fix some comments
2022-09-18 12:07:56 +00:00
Ralf Jung
7fdd924ce4 add/fix some comments 2022-09-18 13:59:04 +02:00
Christian Poveda
c834637626
address review comments 2022-09-13 15:16:41 -05:00
Ralf Jung
613a436cfc
add extra sanity check against depending on system time with isolation enabled 2022-09-13 15:16:41 -05:00
Ralf Jung
bc307b40ba
organize clock arithmetic more like the stdlib 2022-09-13 15:16:41 -05:00
Ralf Jung
f5e2f73178
move clock stuff to separate file 2022-09-13 15:16:40 -05:00
Christian Poveda
ad69e0b36a
hide all enums inside kind types 2022-09-13 15:16:40 -05:00
Christian Poveda
6a37643265
make sleep work with isolation enabled 2022-09-13 15:16:40 -05:00
bors
c7f7bc0ca2 Auto merge of #2541 - lengyijun:patch-1, r=RalfJung
fix typo
2022-09-13 15:43:32 +00:00
bors
aebfbf2a91 fix typo 2022-09-13 15:43:32 +00:00
bors
a00fa96336 Auto merge of #2479 - saethlin:tag-gc, r=oli-obk
Implement a garbage collector for tags

The general approach here is to scan TLS, all locals, and the main memory map for all provenance, accumulating a `HashSet` of all pointer tags which are stored anywhere (we also have a special case for panic payloads). Then we iterate over every borrow stack and remove tags which are not in said `HashSet`, or which could be terminating a SRW block.

Runtime of benchmarks decreases by between 17% and 81%.

GC off:
```
Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/backtraces/Cargo.toml
  Time (mean ± σ):      7.080 s ±  0.249 s    [User: 6.870 s, System: 0.202 s]
  Range (min … max):    6.933 s …  7.521 s    5 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/mse/Cargo.toml
  Time (mean ± σ):      1.875 s ±  0.031 s    [User: 1.630 s, System: 0.245 s]
  Range (min … max):    1.825 s …  1.910 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/serde1/Cargo.toml
  Time (mean ± σ):      2.785 s ±  0.075 s    [User: 2.536 s, System: 0.168 s]
  Range (min … max):    2.698 s …  2.851 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/serde2/Cargo.toml
  Time (mean ± σ):      6.267 s ±  0.066 s    [User: 6.072 s, System: 0.190 s]
  Range (min … max):    6.152 s …  6.314 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/slice-get-unchecked/Cargo.toml
  Time (mean ± σ):      4.733 s ±  0.080 s    [User: 4.177 s, System: 0.513 s]
  Range (min … max):    4.681 s …  4.874 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/unicode/Cargo.toml
  Time (mean ± σ):      3.770 s ±  0.034 s    [User: 3.549 s, System: 0.211 s]
  Range (min … max):    3.724 s …  3.819 s    5 runs
```
GC on:
```
Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/backtraces/Cargo.toml
  Time (mean ± σ):      5.886 s ±  0.054 s    [User: 5.696 s, System: 0.182 s]
  Range (min … max):    5.799 s …  5.937 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/mse/Cargo.toml
  Time (mean ± σ):     936.4 ms ±   7.0 ms    [User: 815.4 ms, System: 119.6 ms]
  Range (min … max):   925.7 ms … 945.0 ms    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/serde1/Cargo.toml
  Time (mean ± σ):      2.126 s ±  0.022 s    [User: 1.979 s, System: 0.146 s]
  Range (min … max):    2.089 s …  2.143 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/serde2/Cargo.toml
  Time (mean ± σ):      4.242 s ±  0.066 s    [User: 4.051 s, System: 0.160 s]
  Range (min … max):    4.196 s …  4.357 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/slice-get-unchecked/Cargo.toml
  Time (mean ± σ):     907.4 ms ±   2.4 ms    [User: 788.6 ms, System: 118.2 ms]
  Range (min … max):   903.5 ms … 909.4 ms    5 runs

Benchmark 1: cargo +miri miri run --manifest-path /home/ben/miri/bench-cargo-miri/unicode/Cargo.toml
  Time (mean ± σ):      1.821 s ±  0.011 s    [User: 1.687 s, System: 0.133 s]
  Range (min … max):    1.802 s …  1.831 s    5 runs
```

But much more importantly for me this drops the peak memory usage of the first 1 minute of running `regex`'s tests from 103  GB to 1.7 GB.

Thanks to `@oli-obk` for suggesting a while ago that this was possible and `@darksonn` for reminding me that we can just search through memory to find Provenance to locate pointers.

Fixes https://github.com/rust-lang/miri/issues/1367
2022-09-13 11:05:55 +00:00
lyj
f6cbba12ce
fix typo 2022-09-13 17:49:41 +08:00
Ben Kimock
f59605ce52 In CI set the GC interval to 1 for Linux only 2022-09-10 23:05:56 -04:00
Ben Kimock
d61d4c6af7 Implement -Zmiri-tag-gc a garbage collector for tags 2022-09-10 23:05:41 -04:00
Oli Scherer
e91db9f03c Rustup 2022-09-10 13:56:05 +00:00
Ben Kimock
ee1c1e6d78 Add support for BCRYPT_RNG_ALG_HANDLE 2022-09-03 12:28:04 -04:00
Martin Nordholts
c011126f1a Fix build with #[unix_sigpipe = "..."] support in rustc 2022-09-03 12:23:05 +02:00
Ralf Jung
2f348abafc Revert "disable extern-so ffi support for now due to licensing situation"
This reverts commit 5f3545e773.
With https://github.com/tov/libffi-rs/pull/58 landed, we no longer depend on abort_on_panic.
2022-09-02 14:39:25 +02:00
Ralf Jung
5f3545e773 disable extern-so ffi support for now due to licensing situation 2022-09-01 22:25:14 +02:00
Ben Kimock
3cfb9915fc Add a protector test that demonstrates the base tag diagnostic 2022-08-31 21:37:44 -04:00
Ralf Jung
d21b601b6e make Miri build again with rustc provenance changes 2022-08-31 18:19:09 +02:00
Ralf Jung
671a4b8b0f make backtrace header a bit more visible 2022-08-31 17:32:39 +02:00
Ralf Jung
4cb26afc0c fix progress report being deduplicated 2022-08-31 15:59:53 +02:00
Ben Kimock
da0d4829bf Use the better FnEntry spans in protector errors 2022-08-29 18:06:30 -04:00
bors
284b59c4dc Auto merge of #2517 - saethlin:zst-field-retagging, r=RalfJung
Skip field retagging on ZSTs, it can take forever

I just tried running the `alloc`'s tests with `miri-test-libstd` with field retagging enabled. The test suite eventually hangs on a few tests which pass around ZSTs that have a lot of fields.

I don't really know how to test this effectively. The test passes, but if you remove this fast-path it effectively just hangs the interpreter. And since it hangs _inside_ a step, there's no hope for doing some kind of timeout within the test.
2022-08-29 11:46:26 +00:00
Ben Kimock
70b960b879 Skip field retagging on ZSTs, it can take forever 2022-08-29 00:31:46 -04:00
bors
fec1c7aa32 Auto merge of #2513 - RalfJung:protected, r=saethlin
slightly improve protector-related error messages

I find the current retag messages confusing, since they sound like the item *was* protected, when it still actively *is* protected (and that is, in fact, the issue).

Example error message:
```
error: Undefined Behavior: not granting access to tag <3095> because incompatible item [Unique for <3099>] is protected by call 943
  --> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:5:25
   |
5  |     let _val = unsafe { *x }; //~ ERROR: protect
   |                         ^^ not granting access to tag <3095> because incompatible item [Unique for <3099>] is protected by call 943
   |
   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows 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
help: <3095> was created by a SharedReadWrite retag at offsets [0x0..0x4]
  --> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:10:16
   |
10 |     let xraw = &mut x as *mut _;
   |                ^^^^^^
help: <3095> cannot be used for memory access because that would remove protected tag <3099>, protected by this function call
  --> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:1:1
   |
1  | / fn inner(x: *mut i32, _y: &mut i32) {
2  | |     // If `x` and `y` alias, retagging is fine with this... but we really
3  | |     // shouldn't be allowed to use `x` at all because `y` was assumed to be
4  | |     // unique for the duration of this call.
5  | |     let _val = unsafe { *x }; //~ ERROR: protect
6  | | }
   | |_^
help: <3099> was derived from <3098>, which in turn was created here
  --> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:12:17
   |
12 |     inner(xraw, xref);
   |                 ^^^^
   = note: backtrace:
   = note: inside `inner` at tests/fail/stacked_borrows/invalidate_against_barrier1.rs:5:25
note: inside `main` at tests/fail/stacked_borrows/invalidate_against_barrier1.rs:12:5
  --> tests/fail/stacked_borrows/invalidate_against_barrier1.rs:12:5
   |
12 |     inner(xraw, xref);
   |     ^^^^^^^^^^^^^^^^^
```

r? `@saethlin`
2022-08-28 16:01:49 +00:00
Ralf Jung
abe890d2ce slightly improve protector-related error messages
also rename some tests that still used outdated "barrier" terminology
2022-08-28 09:27:10 -04:00
bors
88665133b7 Auto merge of #2512 - cbeuw:scfix, r=RalfJung
Strengthen C++20 SC accesses

`@SabrinaJewson` noted in #2301 that Miri could produce behaviours forbidden under C++20 even without SC fences. Due to the added coherence-ordered before relationship which is created from read from and read before, plus the fact that coherence-ordered before between SC operations must be consistent with the Global Total Order S, in C++20 if there's an SC load that reads from any store, then a later SC load cannot read before that store. This PR adds this restriction
2022-08-28 13:20:54 +00:00
Andy Wang
3e97d8e65f
Comment deviations from the paper 2022-08-28 11:05:06 +01:00
Ralf Jung
b4eff16e0c ensure we don't compare provenance 2022-08-27 15:56:00 -04:00
Andy Wang
6dea99ec71
Supress clippy error 2022-08-27 15:24:59 +01:00
Andy Wang
0f9e009987
Fix C++20 SC access unsoundness 2022-08-27 15:24:57 +01:00
Andy Wang
01dffe0575
Remove useless store buffer search logging 2022-08-27 15:24:25 +01:00
Andy Wang
f4ba8b1160
Improve SC comments 2022-08-27 15:24:24 +01:00
Ralf Jung
df19b856ce rustup 2022-08-27 08:57:06 -04:00
Ralf Jung
3a2252b7b3 adjust for earlier init checking in the core engine 2022-08-27 08:51:28 -04:00
Ralf Jung
235036fcb3 nicer errors 2022-08-26 17:43:04 -04:00
Ralf Jung
4e017b54ad fix host/target check for extern-so 2022-08-26 17:38:59 -04:00