Commit Graph

1888 Commits

Author SHA1 Message Date
Ralf Jung
d2ba40e9e1 make tests pass again 2022-08-06 15:29:43 -04:00
Ralf Jung
79d147edb7 make home_dir work on macOS 2022-08-06 14:38:17 -04:00
Ralf Jung
437d241412 move tests covering the env:: module into their own directory 2022-08-06 14:37:46 -04:00
Ralf Jung
61be3bae40 support current_exe on macOS, and fix write_os_str length logic 2022-08-06 12:40:34 -04:00
bors
f633537f3e Auto merge of #2469 - RalfJung:math, r=RalfJung
implement some missing float functions

With this we support the entire float API surface of the standard library. :)

Also fixes https://github.com/rust-lang/miri/issues/2468 by using host floats to implement FMA.
2022-08-06 15:01:44 +00:00
Ralf Jung
b1316eca92 support and test some more math functions 2022-08-06 11:01:19 -04:00
Ralf Jung
5a4ac1ebf0 work around apfloat bug in FMA by using host floats instead 2022-08-06 11:01:19 -04:00
Ralf Jung
d61e55a1d4 add support for env::home_dir
and a bit of cleanup
2022-08-06 08:29:00 -04:00
bors
42087647d6 Auto merge of #2466 - RalfJung:longsleep, r=RalfJung
fix an ICE in nanosleep()
2022-08-06 00:52:42 +00:00
Ralf Jung
d7875ea530 fix an ICE in nanosleep() 2022-08-05 20:44:54 -04:00
Ralf Jung
6d14a5e2a7 avoid strerror_r failure on unknown errnum 2022-08-05 20:18:37 -04:00
Christian Legnitto
b29e7b8e4e Add mkstemp shim for unix
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-08-02 19:56:05 -04:00
Ralf Jung
8356f4cc23 output realpath as a path, and remove a bogus test 2022-08-02 18:08:43 -04:00
Christian Legnitto
b43bede938 Add shim for realpath on unix 2022-08-02 17:27:11 -04:00
bors
530abacbf7 Auto merge of #2447 - RalfJung:rustup, r=RalfJung
rustup
2022-07-27 00:39:00 +00:00
Ralf Jung
dd3b8e8b1b rustup 2022-07-26 20:38:25 -04:00
bors
a62f954eeb Auto merge of #2444 - oli-obk:file_descriptor_defaults, r=RalfJung
Add default impls for `FileDescriptor` methods

I felt like it was just noisy to have to write the "can't do this here" defaults
2022-07-26 23:35:05 +00:00
Ralf Jung
5875c0d220 add test for dyn call issue 2022-07-25 22:41:12 -04:00
Oli Scherer
cd6b723bb6 Add default impls for FileDescriptor methods 2022-07-25 17:57:56 +00:00
Ralf Jung
39d8c4de35 rustup 2022-07-25 10:38:22 -04:00
Ralf Jung
b514667c36 adjust for more backtrace pruning 2022-07-25 10:24:19 -04:00
bors
3d237be15c Auto merge of #2436 - RalfJung:lib-crates, r=oli-obk
fix build.rs invoking RUSTC to do check builds

This makes the Miri driver, when invokved via the RUSTC env var from inside a build script, behave almost entirely like rustc. I had to redo how we propagate sysroot information for this (which is actually back to how we used to do sysroot propagation many years ago).

Fixes https://github.com/rust-lang/miri/issues/2431
2022-07-25 10:39:02 +00:00
Ralf Jung
8f3b594d1e more tests for ptr_offset_from_unsinged 2022-07-24 15:23:39 -04:00
Ralf Jung
d905901d65 make miri a better RUSTC by default inside cargo-miri
this requires a change in sysroot handling: miri driver now requires
MIRI_SYSROOT to be set when it is in 'target' mode, rather than relying on
`--sysroot` always being present.
2022-07-24 13:30:32 -04:00
Ralf Jung
3ee56989c7 get rid of some uses of core_intrinsics 2022-07-24 09:26:11 -04:00
Ralf Jung
c33fc24566 rustup 2022-07-24 08:37:29 -04:00
Ralf Jung
00b382d1a5 add num_cpus crate test 2022-07-22 20:54:10 -04:00
bors
963f08b702 Auto merge of #2418 - RalfJung:track, r=RalfJung
add more track_caller tests

Suggested by `@eddyb`
2022-07-22 14:43:42 +00:00
Ralf Jung
1787c731ab add more track_caller tests 2022-07-22 10:43:28 -04:00
Ralf Jung
45eeaa362b rustup 2022-07-22 09:35:53 -04:00
Ralf Jung
e8b3d56565 test bitmasks smaller than a byte 2022-07-22 08:35:59 -04:00
Ralf Jung
16b15ec9c9 rustup 2022-07-22 07:54:36 -04:00
Ralf Jung
bd441b1eb9 test for some bad use of vtables 2022-07-22 07:54:36 -04:00
Ralf Jung
a6b35412d8 adjust for symbolic vtables 2022-07-22 07:18:34 -04:00
Ralf Jung
e3018b8a97 normalize stronger 2022-07-21 15:36:39 -04:00
Ralf Jung
b1b368c30e test page_size via test dependency support
and move crate tests to their own folders
2022-07-21 09:04:35 -04:00
Oli Scherer
68041b42fc Print one character per test instead of one line 2022-07-21 07:35:49 +00:00
Ralf Jung
e649a9acfb check for extern static size mismatches 2022-07-20 18:32:03 -04:00
Oli Scherer
ab6fb9d2aa Allow tests to have dependencies 2022-07-20 15:54:35 +00:00
Ralf Jung
e0514508b4 fix test file name 2022-07-20 11:27:04 -04:00
bors
ddde70c121 Auto merge of #2394 - saethlin:unique-range-ice, r=RalfJung
Fix bugs where unique_range became invalid

And also expand the cache integrity checks to cover this case.

I'm going to run this over all the ICEs I've gotten out of Miri recently, could be a bit.

Fixes https://github.com/rust-lang/miri/issues/2389
2022-07-20 01:39:40 +00:00
Ben Kimock
4268918a50 Clarify implementation a bit 2022-07-19 20:53:48 -04:00
Ben Kimock
3e93045c87 Add a minimal reproducer of the ICE
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-07-19 20:23:30 -04:00
Ralf Jung
4d220c31a4 add some dyn upcasting tests 2022-07-19 19:40:01 -04:00
bors
8757d866ab Auto merge of #2350 - RalfJung:remove-deprecated, r=oli-obk
remove deprecated options

These have been deprecated a month ago and nobody said they need them. Is that enough time? We can also let this PR sit a little.

Cc https://github.com/rust-lang/miri/issues/2187 https://github.com/rust-lang/miri/issues/2188
(keeping them open to track removing their supporting infrastructure in the core interpreter)
2022-07-19 12:29:29 +00:00
Ralf Jung
1d5cfb565c rustup 2022-07-19 08:03:39 -04:00
Ralf Jung
c850ffe01a add support for new RMW orders 2022-07-18 08:20:06 -04:00
bors
5a4d71faad Auto merge of #2379 - RalfJung:ui-test-target-filter, r=oli-obk
ui_test: more robust syntax for target filtering

Implicit fallbacks are always fragile and prone to typos, so let's be explicit.
2022-07-18 07:26:49 +00:00
Ralf Jung
e30dd07139 libc test: also call isatty on an actual file 2022-07-17 22:31:38 -04:00
Ralf Jung
1c85975768 ui_test: more robust syntax for target filtering 2022-07-17 21:54:10 -04:00
bors
8ec3425a8a Auto merge of #2349 - saethlin:isatty, r=RalfJung
Improve isatty support

Per https://github.com/rust-lang/miri/issues/2292#issuecomment-1171858283, this is an attempt at

> do something more clever with Miri's `isatty` shim

Since Unix -> Unix is very simple, I'm starting with a patch that just does that. Happy to augment/rewrite this based on feedback.

The linked file in libtest specifically only supports stdout. If we're doing this to support terminal applications, I think it would be strange to support one but not all 3 of the standard streams.

The `atty` crate contains a bunch of extra logic that libtest does not contain, in order to support MSYS terminals: db8d55f88e so I think if we're going to do Windows support, we should probably access all that logic somehow. I think it's pretty clear that the implementation is not going to change, so I think if we want to, pasting the contents of the `atty` crate into Miri is on the table, instead of taking a dependency.
2022-07-18 01:37:38 +00:00
Ben Kimock
eefdeacdb1 Test that isatty doesn't crash 2022-07-17 21:13:59 -04:00
Ralf Jung
e8ab64e424 make unused flags work like they used to 2022-07-17 08:18:55 -04:00
Ralf Jung
9782b7b039 rustup 2022-07-16 23:40:36 -04:00
bors
e0672589d3 Auto merge of #2370 - RalfJung:weak-mem-test, r=RalfJung
add another weak mem consistency test

`@cbeuw` your code seems to do this correctly? :D
2022-07-14 12:23:47 +00:00
Ralf Jung
b8a0c49e51 test that we can see this weak behavior 2022-07-14 08:23:31 -04:00
Ralf Jung
07c3e42bd7 replace a macro by a function 2022-07-14 08:17:18 -04:00
Ralf Jung
820f322b86 add work-around for #2164 2022-07-14 08:07:59 -04:00
Ralf Jung
11f2b83464 fix a missing thread join 2022-07-14 07:59:22 -04:00
Ralf Jung
bd69a92b4b rustup 2022-07-13 22:35:45 -04:00
Ralf Jung
a272ca2cf7 add another weak mem consistency test 2022-07-13 21:50:19 -04:00
bors
e16705de25 Auto merge of #2369 - RalfJung:reborrow, r=RalfJung
reborrow error: clarify that we are reborrowing *from* that tag

`@saethlin` I found the current message not entirely clear, so what do you think about this?
2022-07-14 00:04:40 +00:00
Ralf Jung
cc42cb1b21 reborrow error: clarify that we are reborrowing *from* that tag 2022-07-13 19:40:53 -04:00
Ralf Jung
757e88c901 use ui_test regex capabilities 2022-07-13 18:59:33 -04:00
Oli Scherer
837bf84271 Error patterns can be regexes 2022-07-13 14:36:03 +00:00
bors
db5a2b9747 Auto merge of #2315 - saethlin:shrink-item, r=saethlin
Optimizing Stacked Borrows (part 2): Shrink Item

This moves protectors out of `Item`, storing them both in a global `HashSet` which contains all currently-protected tags as well as a `Vec<SbTag>` on each `Frame` so that when we return from a function we know which tags to remove from the protected set.

This also bit-packs the 64-bit tag and the 2-bit permission together when they are stored in memory. This means we theoretically run out of tags sooner, but I doubt that limit will ever be hit.

Together these optimizations reduce the memory footprint of Miri when executing programs which stress Stacked Borrows by ~66%. For example, running a test with isolation off which only panics currently peaks at ~19 GB, with this PR it peaks at ~6.2 GB.

To-do
- [x] Enforce the 62-bit limit
- [x] Decide if there is a better order to pack the tag and permission in
- [x] Wait for `UnsafeCell` to become infectious, or express offsets + tags in the global protector set

Benchmarks before:
```
Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/backtraces/Cargo.toml
  Time (mean ± σ):      8.948 s ±  0.253 s    [User: 8.752 s, System: 0.158 s]
  Range (min … max):    8.619 s …  9.279 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/mse/Cargo.toml
  Time (mean ± σ):      2.129 s ±  0.037 s    [User: 1.849 s, System: 0.248 s]
  Range (min … max):    2.086 s …  2.176 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/serde1/Cargo.toml
  Time (mean ± σ):      3.334 s ±  0.017 s    [User: 3.211 s, System: 0.103 s]
  Range (min … max):    3.315 s …  3.352 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/serde2/Cargo.toml
  Time (mean ± σ):      3.316 s ±  0.038 s    [User: 3.207 s, System: 0.095 s]
  Range (min … max):    3.282 s …  3.375 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/unicode/Cargo.toml
  Time (mean ± σ):      6.391 s ±  0.323 s    [User: 5.928 s, System: 0.412 s]
  Range (min … max):    6.090 s …  6.917 s    5 runs
 ```
 After:
 ```
Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/backtraces/Cargo.toml
  Time (mean ± σ):      6.955 s ±  0.051 s    [User: 6.807 s, System: 0.132 s]
  Range (min … max):    6.900 s …  7.038 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/mse/Cargo.toml
  Time (mean ± σ):      1.784 s ±  0.012 s    [User: 1.627 s, System: 0.156 s]
  Range (min … max):    1.772 s …  1.797 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/serde1/Cargo.toml
  Time (mean ± σ):      2.505 s ±  0.095 s    [User: 2.311 s, System: 0.096 s]
  Range (min … max):    2.405 s …  2.603 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/serde2/Cargo.toml
  Time (mean ± σ):      2.449 s ±  0.031 s    [User: 2.306 s, System: 0.100 s]
  Range (min … max):    2.395 s …  2.467 s    5 runs

Benchmark 1: cargo +miri miri run --manifest-path bench-cargo-miri/unicode/Cargo.toml
  Time (mean ± σ):      3.667 s ±  0.110 s    [User: 3.498 s, System: 0.140 s]
  Range (min … max):    3.564 s …  3.814 s    5 runs
 ```
 The decrease in system time is probably due to spending less time in the page fault handler.
2022-07-13 01:44:01 +00:00
Ben Kimock
4eff60ad6e Rearrange and document the new implementation
stacked_borrow now has an item module, and its own FrameExtra. These
serve to protect the implementation of Item (which is a bunch of
bit-packing tricks) from the primary logic of Stacked Borrows, and the
FrameExtra we have separates Stacked Borrows more cleanly from the
interpreter itself.

The new strategy for checking protectors also makes some subtle
performance tradeoffs, so they are now documented in Stack::item_popped
because that function primarily benefits from them, and it also touches
every aspect of them.

Also separating the actual CallId that is protecting a Tag from the Tag
makes it inconvienent to reproduce exactly the same protector errors, so
this also takes the opportunity to use some slightly cleaner English in
those errors. We need to make some change, might as well make it good.
2022-07-12 21:03:54 -04:00
Ben Kimock
afa1dddcf9 Store protectors outside Item, pack Tag and Perm
Previously, Item was a struct of a NonZeroU64, an Option which was
usually unset or irrelevant, and a 4-variant enum. So collectively, the
size of an Item was 24 bytes, but only 8 bytes were used for the most
part.

So this takes advantage of the fact that it is probably impossible to
exhaust the total space of SbTags, and steals 3 bits from it to pack the
whole struct into a single u64. This bit-packing means that we reduce
peak memory usage when Miri goes memory-bound by ~3x. We also get CPU
performance improvements of varying size, because not only are we simply
accessing less memory, we can now compare a Vec<Item> using a memcmp
because it does not have any padding.
2022-07-12 21:01:33 -04:00
Ralf Jung
cd3535d256 test that we also find bad uses of mem::uninitialized 2022-07-12 09:55:28 -04:00
Ralf Jung
49a6c230cb remove deprecated options 2022-07-11 21:28:54 -04:00
Oli Scherer
1ca8d60734 Fix annotation filtering with revisions 2022-07-11 17:19:10 +00:00
Oli Scherer
a64f9e7250 Remove error annotations stderr
they still showed up in multiline messages
2022-07-11 11:50:33 +00:00
Oli Scherer
f3496cbe4b require level and colon in //~ style comments 2022-07-11 11:48:56 +00:00
Ralf Jung
444ba75ac5 make more tests deterministic 2022-07-10 20:21:19 -04:00
Ralf Jung
45abee46be make a test deterministic 2022-07-10 20:15:35 -04:00
Oli Scherer
6e106617f1 Port all tests 2022-07-08 16:08:32 +00:00
Oli Scherer
54b6b03410 Actually use eyre and get rid of the ad-hoc macros emulating error handling 2022-07-08 15:55:37 +00:00
Oli Scherer
570032b0dd Introduce a proper error handling framework 2022-07-08 15:55:37 +00:00
Oli Scherer
389915e09b Replace all //error-pattern comments with strict syntax and fix other comments in the same files 2022-07-08 15:55:37 +00:00
Ralf Jung
23d1f1a5a3 rustup 2022-07-07 20:12:30 -04:00
Ralf Jung
b6602f5d11 rustup 2022-07-06 22:55:12 -04:00
Ralf Jung
5fed3ebc26 adjust code for copy_op changes 2022-07-06 21:40:31 -04:00
Ralf Jung
e9176c747e test for better error location on stack pop 2022-07-06 21:40:31 -04:00
Ralf Jung
e5df0cc770 adjust tests for removal of unsized_locals 2022-07-06 21:40:31 -04:00
Ralf Jung
d5f1c26380 rustup; ptr atomics 2022-07-06 21:38:52 -04:00
Ralf Jung
907a003f14 tweak format strings 2022-07-06 09:47:48 -04:00
bors
36d8f5cbfc Auto merge of #2336 - RalfJung:wide-ptr-compare, r=RalfJung
fix comparing wide raw pointers

Fixes https://github.com/rust-lang/rust/issues/96169

However I am not sure if these are the correct semantics. I'll wait for confirmation in that issue.
2022-07-06 12:16:25 +00:00
Ralf Jung
de2915bba7 rustup 2022-07-05 22:29:38 -04:00
Ralf Jung
6c8ad4abc9 fix comparing wide raw pointers 2022-07-05 21:21:02 -04:00
Ralf Jung
f3f4bafa1b rustup 2022-07-05 18:16:20 -04:00
Ralf Jung
2931e0fd63 handle Box with allocators 2022-07-05 08:34:41 -04:00
Ralf Jung
a4e7e1e6b5 fix retagging of vtable ptrs 2022-07-03 11:56:29 -04:00
Ralf Jung
5f7bc9739b move arc_drop test to miri-test-libstd
and make weak memory consistency test a bit faster again
2022-07-03 08:13:58 -04:00
Ralf Jung
b4520e4591 test fs::read_link surface function 2022-07-02 13:32:04 -04:00
Ralf Jung
98254f67af pointer tag tracking: on creation, log the offsets it is created for 2022-07-02 11:33:29 -04:00
bors
428245072e Auto merge of #2306 - RalfJung:unix, r=RalfJung
make some things available for all Unixes
2022-07-02 13:45:27 +00:00
Ralf Jung
ae51998191 male libc.rs at least build on FreeBSD 2022-07-02 09:45:00 -04:00
bors
c17e68d9be Auto merge of #2300 - InfRandomness:freebsd-environ-extern-impl, r=RalfJung
Extend `environ` linux extern implementation to freebsd

This fixes the `env` test on freebsd, and enables the CI test

Signed-off-by: InfRandomness <infrandomness@gmail.com>
2022-07-02 12:57:14 +00:00
bors
24c5eaf8bc Auto merge of #2305 - RalfJung:rustup, r=RalfJung
rustup
2022-07-02 12:38:40 +00:00
Ralf Jung
c0cbb662d2 rustup 2022-07-02 08:38:07 -04:00