]> git.lizzy.rs Git - rust.git/log
rust.git
22 months agoAuto merge of #2479 - saethlin:tag-gc, r=oli-obk
bors [Tue, 13 Sep 2022 11:05:55 +0000 (11:05 +0000)]
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

22 months agoAuto merge of #2542 - lengyijun:patch-2, r=oli-obk
bors [Tue, 13 Sep 2022 09:53:04 +0000 (09:53 +0000)]
Auto merge of #2542 - lengyijun:patch-2, r=oli-obk

fix typo

22 months agofix typo
lyj [Tue, 13 Sep 2022 09:49:41 +0000 (17:49 +0800)]
fix typo

22 months agoIn CI set the GC interval to 1 for Linux only
Ben Kimock [Mon, 5 Sep 2022 22:39:32 +0000 (18:39 -0400)]
In CI set the GC interval to 1 for Linux only

22 months agoImplement -Zmiri-tag-gc a garbage collector for tags
Ben Kimock [Thu, 11 Aug 2022 00:50:36 +0000 (20:50 -0400)]
Implement -Zmiri-tag-gc a garbage collector for tags

22 months agoAuto merge of #2539 - oli-obk:rustup, r=oli-obk
bors [Sat, 10 Sep 2022 13:56:56 +0000 (13:56 +0000)]
Auto merge of #2539 - oli-obk:rustup, r=oli-obk

Rustup

for https://github.com/rust-lang/rust/issues/101649

22 months agoRustup
Oli Scherer [Sat, 10 Sep 2022 13:56:05 +0000 (13:56 +0000)]
Rustup

22 months agoAuto merge of #2535 - oli-obk:rustup, r=oli-obk
bors [Wed, 7 Sep 2022 13:27:46 +0000 (13:27 +0000)]
Auto merge of #2535 - oli-obk:rustup, r=oli-obk

Rustup

fix breakage in https://github.com/rust-lang/rust/pull/101522

22 months agoRustup
Oli Scherer [Wed, 7 Sep 2022 13:26:35 +0000 (13:26 +0000)]
Rustup

22 months agoAuto merge of #2534 - saethlin:rustup, r=saethlin
bors [Sat, 3 Sep 2022 22:16:50 +0000 (22:16 +0000)]
Auto merge of #2534 - saethlin:rustup, r=saethlin

rustup: bring in Miri backtrace-rs pruning fix

The pruning logic in `backtrace` has always been broken in Miri. But now there's a fix!

22 months agorustup: bring in Miri backtrace-rs pruning fix
Ben Kimock [Sat, 3 Sep 2022 21:38:42 +0000 (17:38 -0400)]
rustup: bring in Miri backtrace-rs pruning fix

22 months agoAuto merge of #2533 - saethlin:windows-rng, r=ChrisDenton
bors [Sat, 3 Sep 2022 19:32:09 +0000 (19:32 +0000)]
Auto merge of #2533 - saethlin:windows-rng, r=ChrisDenton

Support BCRYPT_RNG_ALG_HANDLE rust-lang/rust#101325

I haven't tested this on a Windows host, brace for CI...

22 months agoAdd support for BCRYPT_RNG_ALG_HANDLE
Ben Kimock [Sat, 3 Sep 2022 16:13:47 +0000 (12:13 -0400)]
Add support for BCRYPT_RNG_ALG_HANDLE

22 months agoAuto merge of #2532 - Enselic:fix-build-with-unix_sigpipe, r=RalfJung
bors [Sat, 3 Sep 2022 11:18:54 +0000 (11:18 +0000)]
Auto merge of #2532 - Enselic:fix-build-with-unix_sigpipe, r=RalfJung

Fix build with `#[unix_sigpipe = "..."]` support in rustc

Closes https://github.com/rust-lang/rust/issues/101352

CC `@RalfJung` `@oli-obk`

22 months agoFix build with `#[unix_sigpipe = "..."]` support in rustc
Martin Nordholts [Sat, 3 Sep 2022 04:44:20 +0000 (06:44 +0200)]
Fix build with `#[unix_sigpipe = "..."]` support in rustc

22 months agoAuto merge of #2530 - oli-obk:rustup, r=RalfJung
bors [Fri, 2 Sep 2022 14:10:46 +0000 (14:10 +0000)]
Auto merge of #2530 - oli-obk:rustup, r=RalfJung

Rustup

Breakage issue: https://github.com/rust-lang/rust/issues/101324

22 months agotweak variable name
Ralf Jung [Fri, 2 Sep 2022 14:10:24 +0000 (16:10 +0200)]
tweak variable name

22 months agoClippy after rustup
Oli Scherer [Fri, 2 Sep 2022 13:55:26 +0000 (13:55 +0000)]
Clippy after rustup

22 months agoRustup
Oli Scherer [Fri, 2 Sep 2022 13:55:18 +0000 (13:55 +0000)]
Rustup

22 months agoAuto merge of #2529 - RalfJung:yesffi, r=RalfJung
bors [Fri, 2 Sep 2022 12:41:03 +0000 (12:41 +0000)]
Auto merge of #2529 - RalfJung:yesffi, r=RalfJung

re-enable FFI support

https://github.com/tov/libffi-rs/pull/58 landed so the license should no longer be an issue. :)

Fixes https://github.com/rust-lang/miri/issues/2526

22 months agoRevert "disable extern-so ffi support for now due to licensing situation"
Ralf Jung [Fri, 2 Sep 2022 12:38:52 +0000 (14:38 +0200)]
Revert "disable extern-so ffi support for now due to licensing situation"

This reverts commit 5f3545e773f930c3345e7166b98bf9d2a76adff6.
With https://github.com/tov/libffi-rs/pull/58 landed, we no longer depend on abort_on_panic.

23 months agoAuto merge of #2527 - RalfJung:noffi, r=RalfJung
bors [Thu, 1 Sep 2022 20:28:06 +0000 (20:28 +0000)]
Auto merge of #2527 - RalfJung:noffi, r=RalfJung

disable extern-so ffi support for now due to licensing situation

libffi depends on abort_on_panic which has a [very unfortunate license situation going on](https://rust-lang.zulipchat.com/#narrow/stream/231349-t-core.2Flicensing). For now, in order to let us update Miri in rustc, I see no way but to disable our FFI support again. Sorry `@emarteca` :(

Cc https://github.com/rust-lang/miri/issues/2526

23 months agodisable extern-so ffi support for now due to licensing situation
Ralf Jung [Thu, 1 Sep 2022 20:25:14 +0000 (22:25 +0200)]
disable extern-so ffi support for now due to licensing situation

23 months agoAuto merge of #2523 - saethlin:protector-test, r=RalfJung
bors [Thu, 1 Sep 2022 13:49:27 +0000 (13:49 +0000)]
Auto merge of #2523 - saethlin:protector-test, r=RalfJung

Add a protector test that demonstrates the base tag diagnostic

Per https://github.com/rust-lang/miri/pull/2519#issuecomment-1232736295, this demonstrates this case for protector diagnostics:
```
help: <3131> was created here, as a base tag for alloc1623
  --> tests/fail/stacked_borrows/invalidate_against_protector3.rs:10:19
   |
10 |         let ptr = std::alloc::alloc(std::alloc::Layout::for_value(&0i32)) as *mut i32;
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
This diagnostic is inspired by what Miri used to do with https://github.com/rust-lang/rust/issues/60076#issuecomment-1214169179

23 months agoAuto merge of #2525 - RalfJung:zulip, r=RalfJung
bors [Thu, 1 Sep 2022 13:22:04 +0000 (13:22 +0000)]
Auto merge of #2525 - RalfJung:zulip, r=RalfJung

Zulip notifications: ping the Miri team

23 months agoZulip notifications: ping the Miri team
Ralf Jung [Thu, 1 Sep 2022 13:20:05 +0000 (15:20 +0200)]
Zulip notifications: ping the Miri team

23 months agoAdd a protector test that demonstrates the base tag diagnostic
Ben Kimock [Wed, 31 Aug 2022 12:45:26 +0000 (08:45 -0400)]
Add a protector test that demonstrates the base tag diagnostic

23 months agoAuto merge of #2516 - RalfJung:read-pointer-as-bytes, r=RalfJung
bors [Wed, 31 Aug 2022 16:25:06 +0000 (16:25 +0000)]
Auto merge of #2516 - RalfJung:read-pointer-as-bytes, r=RalfJung

Adjust for supporting more implicit ptr-to-int transmutation

This is the Miri side of https://github.com/rust-lang/rust/pull/101101.
Fixes https://github.com/rust-lang/miri/issues/2456.

23 months agorustup
Ralf Jung [Wed, 31 Aug 2022 16:19:14 +0000 (18:19 +0200)]
rustup

23 months agomake Miri build again with rustc provenance changes
Ralf Jung [Sat, 27 Aug 2022 19:59:27 +0000 (15:59 -0400)]
make Miri build again with rustc provenance changes

23 months agoAuto merge of #2524 - RalfJung:progress-report, r=RalfJung
bors [Wed, 31 Aug 2022 15:33:17 +0000 (15:33 +0000)]
Auto merge of #2524 - RalfJung:progress-report, r=RalfJung

fix progress report being deduplicated

Fixes https://github.com/rust-lang/miri/issues/2522

23 months agomake shim_arg_size ptr-width-independent
Ralf Jung [Wed, 31 Aug 2022 14:05:40 +0000 (16:05 +0200)]
make shim_arg_size ptr-width-independent

23 months agomake backtrace header a bit more visible
Ralf Jung [Wed, 31 Aug 2022 12:51:05 +0000 (14:51 +0200)]
make backtrace header a bit more visible

23 months agofix progress report being deduplicated
Ralf Jung [Wed, 31 Aug 2022 12:44:36 +0000 (14:44 +0200)]
fix progress report being deduplicated

23 months agoAuto merge of #2521 - oli-obk:bump_ui_test, r=RalfJung
bors [Wed, 31 Aug 2022 11:37:27 +0000 (11:37 +0000)]
Auto merge of #2521 - oli-obk:bump_ui_test, r=RalfJung

Bump UI test dependency

This gives us the new diff renderer as well as the ability to run tests without parallelism if we'd want to.

23 months agoadd comment
Ralf Jung [Wed, 31 Aug 2022 11:36:25 +0000 (13:36 +0200)]
add comment

23 months agoBump ui_test to 0.3.1
Oli Scherer [Wed, 31 Aug 2022 11:06:35 +0000 (11:06 +0000)]
Bump ui_test to 0.3.1

23 months agoBump UI test dependency
Oli Scherer [Wed, 31 Aug 2022 10:27:05 +0000 (10:27 +0000)]
Bump UI test dependency

23 months agoAuto merge of #2519 - saethlin:rustup, r=RalfJung
bors [Wed, 31 Aug 2022 10:06:05 +0000 (10:06 +0000)]
Auto merge of #2519 - saethlin:rustup, r=RalfJung

Use the better FnEntry spans in protector errors

Example error, from `tests/fail/stacked_borrows/invalidate_against_protector1.rs`:
```
error: Undefined Behavior: not granting access to tag <3095> because that would remove [Unique for <3099>] which is protected because it is an argument of call 943
  --> tests/fail/stacked_borrows/invalidate_against_protector1.rs:5:25
   |
5  |     let _val = unsafe { *x }; //~ ERROR: protect
   |                         ^^ not granting access to tag <3095> because that would remove [Unique for <3099>] which is protected because it is an argument of 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_protector1.rs:10:16
   |
10 |     let xraw = &mut x as *mut _;
   |                ^^^^^^
help: <3099> is this argument
  --> tests/fail/stacked_borrows/invalidate_against_protector1.rs:1:23
   |
1  | fn inner(x: *mut i32, _y: &mut i32) {
   |                       ^^
   = note: backtrace:
   = note: inside `inner` at tests/fail/stacked_borrows/invalidate_against_protector1.rs:5:25
note: inside `main` at tests/fail/stacked_borrows/invalidate_against_protector1.rs:12:5
  --> tests/fail/stacked_borrows/invalidate_against_protector1.rs:12:5
   |
12 |     inner(xraw, xref);
   |     ^^^^^^^^^^^^^^^^^
```

Benchmarks report no change, within noise.

23 months agoUse the better FnEntry spans in protector errors
Ben Kimock [Mon, 29 Aug 2022 21:14:45 +0000 (17:14 -0400)]
Use the better FnEntry spans in protector errors

23 months agoAuto merge of #2517 - saethlin:zst-field-retagging, r=RalfJung
bors [Mon, 29 Aug 2022 11:46:26 +0000 (11:46 +0000)]
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.

23 months agoclarify test purpose
Ralf Jung [Mon, 29 Aug 2022 11:46:03 +0000 (07:46 -0400)]
clarify test purpose

23 months agoSkip field retagging on ZSTs, it can take forever
Ben Kimock [Sun, 28 Aug 2022 17:07:33 +0000 (13:07 -0400)]
Skip field retagging on ZSTs, it can take forever

23 months agoAuto merge of #2513 - RalfJung:protected, r=saethlin
bors [Sun, 28 Aug 2022 16:01:49 +0000 (16:01 +0000)]
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`

23 months agoslightly improve protector-related error messages
Ralf Jung [Sat, 27 Aug 2022 15:19:35 +0000 (11:19 -0400)]
slightly improve protector-related error messages

also rename some tests that still used outdated "barrier" terminology

23 months agoAuto merge of #2512 - cbeuw:scfix, r=RalfJung
bors [Sun, 28 Aug 2022 13:20:54 +0000 (13:20 +0000)]
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

23 months agoComment deviations from the paper
Andy Wang [Sun, 28 Aug 2022 10:05:06 +0000 (11:05 +0100)]
Comment deviations from the paper

23 months agoAuto merge of #2515 - RalfJung:build, r=RalfJung
bors [Sat, 27 Aug 2022 20:24:54 +0000 (20:24 +0000)]
Auto merge of #2515 - RalfJung:build, r=RalfJung

dont rerun build script unnecessarily

23 months agodont rerun build script unnecessarily
Ralf Jung [Sat, 27 Aug 2022 20:08:05 +0000 (16:08 -0400)]
dont rerun build script unnecessarily

23 months agoAuto merge of #2514 - RalfJung:dont-compare, r=RalfJung
bors [Sat, 27 Aug 2022 19:56:35 +0000 (19:56 +0000)]
Auto merge of #2514 - RalfJung:dont-compare, r=RalfJung

ensure we don't compare provenance

Comparing provenance is meaningless, since `Wildcard` might be any provenance.

23 months agoensure we don't compare provenance
Ralf Jung [Sat, 27 Aug 2022 19:55:00 +0000 (15:55 -0400)]
ensure we don't compare provenance

23 months agoSupress clippy error
Andy Wang [Sat, 27 Aug 2022 07:19:33 +0000 (08:19 +0100)]
Supress clippy error

23 months agoFix C++20 SC access unsoundness
Andy Wang [Fri, 26 Aug 2022 22:56:15 +0000 (23:56 +0100)]
Fix C++20 SC access unsoundness

23 months agoAdd C++20 SC access test
Andy Wang [Wed, 24 Aug 2022 23:30:03 +0000 (00:30 +0100)]
Add C++20 SC access test

23 months agoRemove useless store buffer search logging
Andy Wang [Wed, 24 Aug 2022 23:08:04 +0000 (00:08 +0100)]
Remove useless store buffer search logging

23 months agoImprove SC comments
Andy Wang [Wed, 24 Aug 2022 23:07:17 +0000 (00:07 +0100)]
Improve SC comments

23 months agoAuto merge of #2455 - RalfJung:scalar-always-init, r=RalfJung
bors [Sat, 27 Aug 2022 13:17:31 +0000 (13:17 +0000)]
Auto merge of #2455 - RalfJung:scalar-always-init, r=RalfJung

adjust for earlier init checking in the core engine

Miri side of https://github.com/rust-lang/rust/pull/100043

23 months agorustup
Ralf Jung [Sat, 27 Aug 2022 12:51:41 +0000 (08:51 -0400)]
rustup

23 months agoadjust for earlier init checking in the core engine
Ralf Jung [Tue, 2 Aug 2022 01:34:28 +0000 (21:34 -0400)]
adjust for earlier init checking in the core engine

23 months agoAuto merge of #2511 - RalfJung:extern-so, r=RalfJung
bors [Fri, 26 Aug 2022 21:44:32 +0000 (21:44 +0000)]
Auto merge of #2511 - RalfJung:extern-so, r=RalfJung

some extern-so cleanup and fixes

23 months agonicer errors
Ralf Jung [Fri, 26 Aug 2022 21:43:04 +0000 (17:43 -0400)]
nicer errors

23 months agorename test to match usual naming conventions
Ralf Jung [Fri, 26 Aug 2022 21:40:26 +0000 (17:40 -0400)]
rename test to match usual naming conventions

what's a "fcts"?

23 months agofix host/target check for extern-so
Ralf Jung [Fri, 26 Aug 2022 21:38:59 +0000 (17:38 -0400)]
fix host/target check for extern-so

23 months agoAuto merge of #2510 - oli-obk:merge_conflict, r=oli-obk
bors [Fri, 26 Aug 2022 14:38:14 +0000 (14:38 +0000)]
Auto merge of #2510 - oli-obk:merge_conflict, r=oli-obk

Fix merge conflict

found in https://github.com/rust-lang/miri/pull/2363#discussion_r956100939

23 months agoFix merge conflict
Oli Scherer [Fri, 26 Aug 2022 14:35:40 +0000 (14:35 +0000)]
Fix merge conflict

23 months agoAuto merge of #2509 - RalfJung:env-data-race, r=RalfJung
bors [Fri, 26 Aug 2022 13:33:40 +0000 (13:33 +0000)]
Auto merge of #2509 - RalfJung:env-data-race, r=RalfJung

fix data race error during env var cleanup

Fixes https://github.com/rust-lang/miri/issues/2508

23 months agofix data race error during env var cleanup
Ralf Jung [Fri, 26 Aug 2022 12:50:25 +0000 (08:50 -0400)]
fix data race error during env var cleanup

23 months agoAuto merge of #2363 - emarteca:int-function-args-returns, r=oli-obk
bors [Fri, 26 Aug 2022 08:51:11 +0000 (08:51 +0000)]
Auto merge of #2363 - emarteca:int-function-args-returns, r=oli-obk

Adding support for external C functions that have integer (or empty) args and/or returns

Starts addressing `@https://github.com/rust-lang/miri/issues/11`

### Implementation
Adding support for calling external C functions that have any number of integer arguments (types of integers: `i8`, `i16`, `i32`, `i64`, `u8`, `u16`, `u32`, `u64`) and an integer return type (or `void`).
As suggested in `@https://github.com/rust-lang/miri/issues/11,` the [`libffi` crate](https://docs.rs/libffi/latest/libffi/index.html) is used to dispatch the calls to external C functions.

#### Modifications
Main modifications are to:
* [helper.rs](https://github.com/emarteca/miri/blob/int-function-args-returns/src/helpers.rs) : adding a function `call_and_add_external_c_fct_to_context` to read the code pointer to the external C function, dispatch the call, and save the return in MIRI internal memory. Handles all conversions between MIRI and C values (using some macros, also defined in this file).
* [foreign_items.rs](https://github.com/emarteca/miri/blob/int-function-args-returns/src/shims/foreign_items.rs) : handles the calling of `call_and_add_external_c_fct_to_context` in [helper.rs](https://github.com/emarteca/miri/blob/int-function-args-returns/src/helpers.rs) when a foreign item is encountered. Also adds some structs to model C representations of arguments, and the signature of the external C call.

### Testing
Adds tests for the following external functions which are now supported:
* [int tests](https://github.com/emarteca/miri/blob/int-function-args-returns/tests/pass/external_C/int_c_tests.rs):
     - adds 2 to a provided int (no type of int specified, so autocasts)
     - takes the sum of its 12 arguments (tests stack spill)
     - adds 3 to a 16 bit int
     - adds an `i16` to an `i64`
     - returns -10 as an unsigned int
* [void tests](https://github.com/emarteca/miri/blob/int-function-args-returns/tests/pass/external_C/print_from_c.rs)
     - void function that prints from C

### Code review
The code in this PR was reviewed by `@maurer` on [another fork](https://github.com/maurer/miri/pull/1) -- thanks!

23 months agoC FFI support for functions with int args and returns
Ellen Arteca [Fri, 26 Aug 2022 00:47:23 +0000 (00:47 +0000)]
C FFI support for functions with int args and returns

23 months agoAuto merge of #2449 - oli-obk:ui_test_subtree_sync, r=RalfJung
bors [Thu, 25 Aug 2022 15:35:16 +0000 (15:35 +0000)]
Auto merge of #2449 - oli-obk:ui_test_subtree_sync, r=RalfJung

Use ui_test from crates.io instead of having it in-tree

I have moved a copy of the `ui_test` crate into [a separate repo](https://github.com/oli-obk/ui_test) to facilitate the further non-miri development of it. I will keep syncing until we have reached a point where we don't touch it anymore for miri. At that point we can remove the in-tree version and do further development out of tree.

23 months agoUse ui_test from crates.io instead of having it in-tree
Oli Scherer [Thu, 25 Aug 2022 10:10:32 +0000 (10:10 +0000)]
Use ui_test from crates.io instead of having it in-tree

23 months agoAuto merge of #2448 - oli-obk:test_crates_on_their_own, r=RalfJung
bors [Thu, 25 Aug 2022 12:21:07 +0000 (12:21 +0000)]
Auto merge of #2448 - oli-obk:test_crates_on_their_own, r=RalfJung

Run `pass` tests without building dependencies first

fixes https://github.com/rust-lang/miri/issues/2442

One thing that I'm wondering is if we should do away with running each folder individually and make `ui_test` support running all tests in parallel (so building deps becomes a thread, and all tests needing deps are blocked on it)

23 months agoRun `pass` tests without building dependencies first
Oli Scherer [Wed, 27 Jul 2022 08:56:24 +0000 (08:56 +0000)]
Run `pass` tests without building dependencies first

23 months agoAuto merge of #2505 - RalfJung:ui-test, r=oli-obk
bors [Tue, 23 Aug 2022 09:43:52 +0000 (09:43 +0000)]
Auto merge of #2505 - RalfJung:ui-test, r=oli-obk

cope with rustc aborting due to a signal

`status.code().unwrap()` will panic when the process is aborted due to a signal.  Let's not do that.

23 months agocope with rustc aborting due to a signal
Ralf Jung [Tue, 23 Aug 2022 01:23:02 +0000 (21:23 -0400)]
cope with rustc aborting due to a signal

23 months agoAuto merge of #2504 - Hiroki6:move-thread-to-concurrency-module, r=RalfJung
bors [Mon, 22 Aug 2022 18:49:07 +0000 (18:49 +0000)]
Auto merge of #2504 - Hiroki6:move-thread-to-concurrency-module, r=RalfJung

move thread.rs into concurrency

Follow-up of https://github.com/rust-lang/miri/pull/2500 and closes https://github.com/rust-lang/miri/issues/2199

I moved the `thread.rs` into the `concurrency` module.

23 months agoreorganize imports a bit
Ralf Jung [Mon, 22 Aug 2022 18:48:47 +0000 (14:48 -0400)]
reorganize imports a bit

23 months agomove thread.rs into concurrency
Hiroki6 [Mon, 22 Aug 2022 17:13:39 +0000 (19:13 +0200)]
move thread.rs into concurrency

23 months agoAuto merge of #2503 - RalfJung:tls-dtor-order, r=RalfJung
bors [Mon, 22 Aug 2022 16:21:11 +0000 (16:21 +0000)]
Auto merge of #2503 - RalfJung:tls-dtor-order, r=RalfJung

notes on TLS dtor order

Fixes https://github.com/rust-lang/miri/issues/2486

23 months agonotes on TLS dtor order
Ralf Jung [Mon, 22 Aug 2022 16:13:42 +0000 (12:13 -0400)]
notes on TLS dtor order

23 months agoAuto merge of #2481 - RalfJung:shim-pattern, r=oli-obk
bors [Mon, 22 Aug 2022 14:44:53 +0000 (14:44 +0000)]
Auto merge of #2481 - RalfJung:shim-pattern, r=oli-obk

document general shim pattern

r? `@oli-obk`

23 months agodocument general shim pattern
Ralf Jung [Fri, 12 Aug 2022 00:40:53 +0000 (20:40 -0400)]
document general shim pattern

23 months agoAuto merge of #2441 - RalfJung:arithmetic, r=oli-obk
bors [Mon, 22 Aug 2022 14:11:46 +0000 (14:11 +0000)]
Auto merge of #2441 - RalfJung:arithmetic, r=oli-obk

pass clippy::integer_arithmetic in our shims

`@oli-obk` [raised some concerns](https://github.com/rust-lang/miri/pull/2422#discussion_r928220546) about this one. I still think it is the right call, since I don't see a good way to enable overflow checks for our official release builds. I'm open to suggestions though!

Fixes https://github.com/rust-lang/miri/issues/1236

23 months agopass clippy::integer_arithmetic in our shims
Ralf Jung [Sat, 23 Jul 2022 13:10:23 +0000 (09:10 -0400)]
pass clippy::integer_arithmetic in our shims

23 months agoAuto merge of #2500 - Hiroki6:make-vector-clock-private, r=RalfJung
bors [Sun, 21 Aug 2022 23:12:41 +0000 (23:12 +0000)]
Auto merge of #2500 - Hiroki6:make-vector-clock-private, r=RalfJung

move vector_clock and sync into concurrency & make vector_clock private

Closes https://github.com/rust-lang/miri/issues/2199

The thread.rs didn't have to be moved to build.
If it makes more sense to move the thread.rs as well, please let me know. I can move it as well.

23 months agorustfmt
Hiroki6 [Sun, 21 Aug 2022 21:43:16 +0000 (23:43 +0200)]
rustfmt

23 months agomove vector_clock and sync into concurrency & make vector_clock private
Hiroki6 [Sun, 21 Aug 2022 21:28:13 +0000 (23:28 +0200)]
move vector_clock and sync into concurrency & make vector_clock private

move thread it back

23 months agoAuto merge of #2495 - RalfJung:ra, r=RalfJung
bors [Sat, 20 Aug 2022 13:30:34 +0000 (13:30 +0000)]
Auto merge of #2495 - RalfJung:ra, r=RalfJung

add ./miri cargo for RA to invoke

RA expects a check command to check *individual workspaces*, whereas `./miri` is designed to check/build/test all parts of Miri. So add a new `./miri cargo` that performs just a single cargo invocation, but with the right env vars so that the build cache can be shared with `./miri check`.

23 months agoadd ./miri cargo for RA to invoke
Ralf Jung [Fri, 19 Aug 2022 12:01:38 +0000 (08:01 -0400)]
add ./miri cargo for RA to invoke

23 months agoAuto merge of #2473 - RalfJung:dyn-upcast-nop, r=RalfJung
bors [Sat, 20 Aug 2022 03:33:42 +0000 (03:33 +0000)]
Auto merge of #2473 - RalfJung:dyn-upcast-nop, r=RalfJung

allow NOP-casts with mismatching vtables

The Miri side of https://github.com/rust-lang/rust/pull/100208.

23 months agorustup
Ralf Jung [Sat, 20 Aug 2022 03:32:58 +0000 (23:32 -0400)]
rustup

23 months agoallow NOP-casts with mismatching vtables
Ralf Jung [Sat, 6 Aug 2022 21:13:31 +0000 (17:13 -0400)]
allow NOP-casts with mismatching vtables

23 months agoAuto merge of #2454 - saethlin:diagnostics-cleanup, r=RalfJung
bors [Thu, 18 Aug 2022 20:37:50 +0000 (20:37 +0000)]
Auto merge of #2454 - saethlin:diagnostics-cleanup, r=RalfJung

Improve information sharing across SB diagnostics

Previous Stacked Borrows diagnostics were missing a lot of information about the state of the interpreter, and it was difficult to add additional state because it was threaded through all the intervening function signatures.

This change factors a lot of the arguments which used to be passed individually to many stacked borrows functions into a single `DiagnosticCx`, which is built in `Stacks::for_each`, and since it wraps a handle to `AllocHistory`, we can now handle more nuanced things like heterogeneous borrow of `!Freeze` types.

23 months agore-bless after rebase
Ralf Jung [Thu, 18 Aug 2022 19:32:45 +0000 (15:32 -0400)]
re-bless after rebase

23 months agosome CurrentSpan cleanup
Ben Kimock [Wed, 17 Aug 2022 00:32:58 +0000 (20:32 -0400)]
some CurrentSpan cleanup

23 months agoClean up diff churn a bit, adjust comments
Ben Kimock [Tue, 16 Aug 2022 02:19:00 +0000 (22:19 -0400)]
Clean up diff churn a bit, adjust comments

23 months agoImprove information sharing across SB diagnostics
Ben Kimock [Sun, 22 May 2022 23:39:09 +0000 (19:39 -0400)]
Improve information sharing across SB diagnostics

Previous Stacked Borrows diagnostics were missing a lot of information
about the state of the interpreter, and it was difficult to add
additional state because it was threaded through all the intervening
function signatures.

This change factors a lot of the arguments which used to be passed
individually to many stacked borrows functions into a single
`DiagnosticCx`, which is built in `Stacks::for_each`, and since it
wraps a handle to `AllocHistory`, we can now handle more nuanced
things like heterogeneous borrow of `!Freeze` types.

23 months agoAuto merge of #2231 - DrMeepster:winfred, r=RalfJung
bors [Thu, 18 Aug 2022 15:26:07 +0000 (15:26 +0000)]
Auto merge of #2231 - DrMeepster:winfred, r=RalfJung

Windows thread support: Part 1

This PR adds support for threads on Windows.

23 months agoadd some missing assert_target_os
Ralf Jung [Thu, 18 Aug 2022 15:25:20 +0000 (11:25 -0400)]
add some missing assert_target_os

23 months agoAuto merge of #2493 - RalfJung:android, r=RalfJung
bors [Thu, 18 Aug 2022 13:13:21 +0000 (13:13 +0000)]
Auto merge of #2493 - RalfJung:android, r=RalfJung

add very basic Android support

This is just enough to print to stdout. I won't push this any further, but having these basics should hopefully make it easier for others to do so.

Also slightly improve threading support on FreeBSD while we are at it.

Partially based on https://github.com/rust-lang/miri/pull/2011.
Fixes https://github.com/rust-lang/miri/issues/2010.