Commit Graph

3156 Commits

Author SHA1 Message Date
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
889c073aa6 really, clippy?!? 2022-08-06 09:03:33 -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
Ralf Jung
e1e1f42f39 make errno table syntactically more similar to rustc library code 2022-08-03 11:51:39 -04:00
Christian Legnitto
9154f8b22c Add additional raw error mappings for the nightly io_error_more feature
Some crates are using nightly and failing when mapping these errors,
for example <https://miri.saethlin.dev/?crate=remove_dir_all&version=0.7.0>:

```
error: unsupported operation: io error NotADirectory cannot be translated into a raw os error
    --> /root/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/fs.rs:1203:19
```
2022-08-03 11:23:15 -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
Ralf Jung
9ffea913b8 clippy 2022-08-01 09:27:56 -04:00
Hiroki6
66f6fa68fa Fix typo in eval.rs 2022-07-31 16:15:11 +02:00
Oli Scherer
cd6b723bb6 Add default impls for FileDescriptor methods 2022-07-25 17:57:56 +00:00
bors
6227e1e3a8 Auto merge of #2422 - RalfJung:integers, r=oli-obk
enable clippy lints against integer casts

Cc https://github.com/rust-lang/miri/issues/1236
2022-07-25 11:46:55 +00: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
cbff63a694 rustup 2022-07-24 17:51: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
bors
62efc6201b Auto merge of #2427 - Nilstrieb:doc-fix, r=saethlin
Fix outdated docs in sb stack cache

Since `Item` is bitpacked now, the full `Item` is stored in the cache.
2022-07-23 23:21:26 +00:00
Nilstrieb
8b643809cc Fix outdated docs in sb stack cache
Since `Item` is bitpacked now, the full `Item` is stored in the cache.
2022-07-24 00:35:02 +02:00
Ralf Jung
b08e51d79a refactor away some 'else { None }' 2022-07-23 12:30:48 -04:00
Ralf Jung
649b216482 add a flag to print a diagnostic when an outdated value is returned from an atomic load 2022-07-23 09:39:02 -04:00
Ralf Jung
7f6034862d pass clippy::cast_possible_truncation 2022-07-23 09:14:13 -04:00
Ralf Jung
b67a6ff099 pass clippy::cast_sign_loss and clippy::cast_possible_wrap 2022-07-23 09:13:38 -04:00
Ralf Jung
3f0fdf290f pass clippy::cast_lossless 2022-07-23 09:13:38 -04:00
Ralf Jung
a6b35412d8 adjust for symbolic vtables 2022-07-22 07:18:34 -04:00
Ralf Jung
7cd1d78a47 only complain about runtime toolchain mismatch when there actually is a runtime toolchain 2022-07-21 09:30:09 -04:00
Ralf Jung
9f99d10689 some stray tag → prov renames 2022-07-20 18:32:03 -04:00
Ralf Jung
e649a9acfb check for extern static size mismatches 2022-07-20 18:32:03 -04:00
Ralf Jung
59f9a918ed handle get_alloc_extra the same throughout Stacked Borrows 2022-07-20 17:57:31 -04:00
Ralf Jung
ff4666f39c rustup 2022-07-20 16:02:06 -04:00
bors
ebda1deb7b Auto merge of #2397 - RalfJung:cleanup, r=RalfJung
only do env var cleanup if all threads have stopped

Hopefully fixes https://github.com/rust-lang/miri/issues/2396
2022-07-20 02:12:09 +00:00
Ralf Jung
5fbf036670 only do env var cleanup if all threads have stopped 2022-07-19 21:44:45 -04:00
Ben Kimock
4268918a50 Clarify implementation a bit 2022-07-19 20:53:48 -04:00
Ben Kimock
db93abe823 Fix bugs where unique_range became invalid
And also expand the cache integrity checks to cover this case, and
generally assert a lot more about the unique_range, then tighten up
sloppy implementation scenarios that this uncovered.
2022-07-19 20:02:20 -04:00
Ralf Jung
5721927afe rustup 2022-07-19 15:44:47 -04:00
bors
e8095d0af4 Auto merge of #2390 - RalfJung:debug, r=RalfJung
fix some debugging papercuts

- detect when Miri got locally installed and is being run with the wrong toolchain
- when an ICE occurs, print a backtrace of where the interpreter was at the time
2022-07-19 18:15:05 +00:00
Ralf Jung
5cf7ed1e04 show where the interpreter was interpreting when an ICE occurs 2022-07-19 14:14:20 -04:00
Ralf Jung
9dba78a76b show a better error when running Miri with the wrong sysroot 2022-07-19 14:14:20 -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
6ab64620a6 refactor atomic intrinsic handling to actually parse the intrinsic name 2022-07-18 08:55:50 -04:00
Ralf Jung
ad3010c449 make atomic intrinsic impl details private 2022-07-18 08:22:27 -04:00
Ralf Jung
c850ffe01a add support for new RMW orders 2022-07-18 08:20:06 -04:00
Ralf Jung
1174cda4f1 remove ret param from foreign_item hierarchy 2022-07-18 08:05:46 -04:00
Ralf Jung
53ead1b8c9 move simd intrinsics to their own file 2022-07-18 08:03:58 -04:00
Ralf Jung
52a6ac96b0 move atomic intrinsics to their own file 2022-07-18 07:55:11 -04:00
Ralf Jung
896f558f2b with isolation we want to be fully deterministic 2022-07-17 21:50: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
2f84cb34c1 Pass through isatty if the host is also unix 2022-07-17 16:53:14 -04:00
Ralf Jung
39866f817a remove a fastpath that does not seem to actually help 2022-07-17 10:35:19 -04:00
Ralf Jung
68510600a3 use PlaceTy visitor 2022-07-17 10:19:29 -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
86911fd8f6 Auto merge of #2368 - RalfJung:debug, r=oli-obk
Make "./miri {build,run,test}" use debug assertions but "./miri install" not

This makes `./miri run`/`./miri test` use the full set of debug assertions (including the rather expensive ones that check consistency of the Stacked Borrows cache), but `./miri install` installs a Miri *without* those debug assertions.

That's the same behavior as cargo, and helps catch Miri bugs with the test suite while making installed Miri usable for larger runs.
2022-07-15 15:54:47 +00:00
Ralf Jung
98c401977b rustup 2022-07-15 08:09:43 -04:00
Ralf Jung
d6cbe5d014 ensure that RangeMap panics on OOB 2022-07-14 15:09:20 -04:00
Ralf Jung
421f92bee6 make some debug assertions in RangeObjectMap be full assertions 2022-07-14 13:23:35 -04:00
Ralf Jung
5d5999ab13 make cache consistency checks into regular debug assertions 2022-07-14 13:00:35 -04:00
Ralf Jung
eaa7f10cb1 rustup 2022-07-14 09:54:20 -04:00
bors
af2c50fb89 Auto merge of #2328 - RalfJung:perf, r=RalfJung
move checking ptr tracking on item pop into cold helper function

Before:
```
Benchmark 1: cargo miri run --manifest-path bench-cargo-miri/serde1/Cargo.toml
  Time (mean ± σ):      6.729 s ±  0.050 s    [User: 6.608 s, System: 0.124 s]
  Range (min … max):    6.665 s …  6.799 s    5 runs

Benchmark 2: cargo miri run --manifest-path bench-cargo-miri/unicode/Cargo.toml
  Time (mean ± σ):     20.923 s ±  0.271 s    [User: 20.386 s, System: 0.537 s]
  Range (min … max):   20.580 s … 21.165 s    5 runs
```
After:
```
Benchmark 1: cargo miri run --manifest-path bench-cargo-miri/serde1/Cargo.toml
  Time (mean ± σ):      6.562 s ±  0.023 s    [User: 6.430 s, System: 0.135 s]
  Range (min … max):    6.544 s …  6.594 s    5 runs

Benchmark 2: cargo miri run --manifest-path bench-cargo-miri/unicode/Cargo.toml
  Time (mean ± σ):     20.375 s ±  0.228 s    [User: 19.964 s, System: 0.413 s]
  Range (min … max):   20.201 s … 20.736 s    5 runs
```
Nothing major, but we'll take it I guess. 🤷

Fixes https://github.com/rust-lang/miri/issues/2132
2022-07-14 00:34:00 +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
83b9172774 move stacked_borrows.rs together with the other files of its module 2022-07-13 19:37:41 -04:00
Ralf Jung
3bd0e8a2ca move checking ptr tracking on item pop into cold helper function 2022-07-13 18:07:33 -04: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
49a6c230cb remove deprecated options 2022-07-11 21:28:54 -04:00
Ralf Jung
c9b207eba6 extend a comment in readlink 2022-07-09 12:49:37 -04:00
Ralf Jung
23d1f1a5a3 rustup 2022-07-07 20:12:30 -04:00
Ralf Jung
6b3986f44d remove a dead optimization 2022-07-07 07:42:31 -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
d5f1c26380 rustup; ptr atomics 2022-07-06 21:38:52 -04:00
Ralf Jung
501a6b4687 rustup 2022-07-06 14:06:15 -04:00
Ralf Jung
907a003f14 tweak format strings 2022-07-06 09:47:48 -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
bors
35399c6a5d Auto merge of #2323 - RalfJung:box-is-special, r=RalfJung
handle Box with allocators

This is the Miri side of https://github.com/rust-lang/rust/pull/98847.

Thanks `@DrMeepster` for doing most of the work of getting this test case to pass in Miri. :)
2022-07-05 12:35:03 +00:00
Ralf Jung
2931e0fd63 handle Box with allocators 2022-07-05 08:34:41 -04:00
Ralf Jung
a07398d441 we don't need HexRange any more 2022-07-05 07:38:42 -04:00
Oli Scherer
afb937ab25 Bump rust version 2022-07-05 10:17:43 +00:00
Ralf Jung
22aa7f98c5 call_function: make the unit-return-type case more convenient 2022-07-04 13:46:11 -04:00
Ralf Jung
a4e7e1e6b5 fix retagging of vtable ptrs 2022-07-03 11:56:29 -04:00
bors
cfad9d12f3 Auto merge of #1935 - saethlin:optimize-sb, r=RalfJung
Optimizing Stacked Borrows (part 1?): Cache locations of Tags in a Borrow Stack

Before this PR, a profile of Miri under almost any workload points quite squarely at these regions of code as being incredibly hot (each being ~40% of cycles):

dadcbebfbd/src/stacked_borrows.rs (L259-L269)

dadcbebfbd/src/stacked_borrows.rs (L362-L369)

This code is one of at least three reasons that stacked borrows analysis is super-linear: These are both linear in the number of borrows in the stack and they are positioned along the most commonly-taken paths.

I'm addressing the first loop (which is in `Stack::find_granting`) by adding a very very simple sort of LRU cache implemented on a `VecDeque`, which maps recently-looked-up tags to their position in the stack. For `Untagged` access we fall back to the same sort of linear search. But as far as I can tell there are never enough `Untagged` items to be significant.

I'm addressing the second loop by keeping track of the region of stack where there could be items granting `Permission::Unique`. This optimization is incredibly effective because `Read` access tends to dominate and many trips through this code path now skip the loop entirely.

These optimizations result in pretty enormous improvements:
Without raw pointer tagging, `mse` 34.5s -> 2.4s, `serde1` 5.6s -> 3.6s
With raw pointer tagging, `mse` 35.3s -> 2.4s, `serde1` 5.7s -> 3.6s

And there is hardly any impact on memory usage:
Memory usage on `mse` 844 MB -> 848 MB, `serde1` 184 MB -> 184 MB (jitter on these is a few MB).
2022-07-03 14:39:22 +00:00
Ben Kimock
b004a03bdb Typo 2022-07-02 20:45:27 -04:00
Ben Kimock
f3b479d556 Explain cache behavior a bit better, clean up diff 2022-07-02 19:44:55 -04:00
Ralf Jung
d9c441c5ab put call to stacked borrows end_call in a more sensible place 2022-07-02 18:38:07 -04:00
Ben Kimock
7cdbf98f57 Explain the behavior of the cache upon clear 2022-07-02 13:22:22 -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
5ba2c1e6be posix_fadvise is not Linux-specific 2022-07-02 09:45:00 -04:00
Ralf Jung
98d20490f4 move some POSIX file shims from linux to unix module 2022-07-02 09:45:00 -04:00
InfRandomness
5ec25359ff
Add environ extern implementation to freebsd
Signed-off-by: InfRandomness <infrandomness@gmail.com>
2022-07-02 12:42:14 +02:00
bors
602a3dcefd Auto merge of #2304 - LegNeato:shim-fstat64-mac, r=oli-obk
Support (stat/fstat/lstat)64 on macos

"In order to accommodate advanced capabilities of newer file systems,
     the struct stat, struct statfs, and struct dirent data structures
     were updated in Mac OSX 10.5."

"TRANSITIONAL DESCRIPTION (NOW DEPRECATED)
     The fstat64, lstat64 and stat64 routines are equivalent to their
     corresponding non-64-suffixed routine, when 64-bit inodes are in
     effect.  They were added before there was support for the symbol
     variants, and so are now deprecated.  Instead of using these, set
     the _DARWIN_USE_64_BIT_INODE macro before including header files to
     force 64-bit inode support. The stat64 structure used by these deprecated routines is the same
     as the stat structure when 64-bit inodes are in effect (see above)."

"HISTORY
     An lstat() function call appeared in 4.2BSD.  The stat64(),
     fstat64(), and lstat64() system calls first appeared in Mac OS X
     10.5 (Leopard) and are now deprecated in favor of the corresponding
     symbol variants.  The fstatat() system call appeared in OS X 10.10"
2022-07-02 07:31:16 +00:00
Christian Legnitto
a1473ea8f5 Support (stat/fstat/lstat)64 on macos
"In order to accommodate advanced capabilities of newer file systems,
     the struct stat, struct statfs, and struct dirent data structures
     were updated in Mac OSX 10.5."

"TRANSITIONAL DESCRIPTION (NOW DEPRECATED)
     The fstat64, lstat64 and stat64 routines are equivalent to their
     corresponding non-64-suffixed routine, when 64-bit inodes are in
     effect.  They were added before there was support for the symbol
     variants, and so are now deprecated.  Instead of using these, set
     the _DARWIN_USE_64_BIT_INODE macro before including header files to
     force 64-bit inode support.

     The stat64 structure used by these deprecated routines is the same
     as the stat structure when 64-bit inodes are in effect (see above)."

"HISTORY
     An lstat() function call appeared in 4.2BSD.  The stat64(),
     fstat64(), and lstat64() system calls first appeared in Mac OS X
     10.5 (Leopard) and are now deprecated in favor of the corresponding
     symbol variants.  The fstatat() system call appeared in OS X 10.10"
2022-07-01 20:10:17 -06:00
Ben Kimock
17acc3f71c Document implementation a bit, add some fast paths 2022-07-01 20:15:34 -04:00
Ralf Jung
d09db1660b fix and slightly improve data race reports 2022-07-01 20:13:44 -04:00
Ben Kimock
3bbcafe3b5 Cache lookups into the borrow stack
This adds a very simple LRU-like cache which stores the locations of
often-used tags. While the implementation is very simple, the cache hit
rate is incredible at ~99.9% on most programs, and often the element at
position 0 in the cache has a hit rate of 90%. So the sub-optimality of
this cache basicaly vanishes into the noise in a profile.

Additionally, we keep a range which denotes where there might be an item
granting Unique permission in the stack, so that when we invalidate
Uniques we do not need to scan much of the stack, and often scan nothing
at all.
2022-07-01 17:51:16 -04:00
Ralf Jung
dfdedae840 avoid copying thread manager state in data race detector 2022-07-01 17:07:29 -04:00
Ralf Jung
f238513efa rename some data_race types for more clarity 2022-07-01 16:21:48 -04:00
bors
c1a37b87aa Auto merge of #2298 - InfRandomness:shim-error, r=RalfJung
Add `__error` to freebsd shims

Signed-off-by: InfRandomness <infrandomness@gmail.com>
2022-07-01 17:41:10 +00:00
InfRandomness
dca2bb68b3
Add __error to freebsd shims
Signed-off-by: InfRandomness <infrandomness@gmail.com>
2022-07-01 18:42:33 +02:00
Ralf Jung
12d04ac4c4 make clippy happy 2022-07-01 12:25:35 -04:00
Ralf Jung
af39709a9c rustup 2022-07-01 10:14:31 -04:00
Ralf Jung
7f3fbbdee7 allocation tracking: also print size, alignment, kind of the allocation 2022-06-30 22:24:23 -04:00
Ralf Jung
aef78d3a9f make -Zmiri-env-forward take precedence over -Zmiri-env-exclude 2022-06-30 11:14:30 -04:00
Ralf Jung
6a204e2dec use Rust SnakeCase 2022-06-29 22:17:46 -04:00
bors
5974e7d4a9 Auto merge of #2287 - RalfJung:field-retagging, r=RalfJung
stacked borrows: add option for recursive field retagging
2022-06-29 23:04:07 +00:00
Ralf Jung
c4e86e103e add option for recursive field retagging 2022-06-29 18:22:30 -04:00
Christian Legnitto
73a1a27a45 Support gettimeofday on more than macos
This appears to be in linux and in openbsd as well:

* https://github.com/torvalds/linux/blob/master/lib/vdso/gettimeofday.c
* https://github.com/openbsd/src/blob/master/sys/sys/time.h#L439

Co-authored-by: Ralf Jung <post@ralfj.de>
2022-06-29 17:48:04 -04:00
Ralf Jung
839c120b40 fmt 2022-06-29 10:09:18 -04:00
Ralf Jung
f389d46b04 also prune caller_location frames when backtrace=off 2022-06-29 09:33:12 -04:00
Ralf Jung
28dea673be rustup 2022-06-29 08:33:06 -04:00
Ralf Jung
8bd4bbe3e4 tweak int2ptr diagnostics 2022-06-28 08:52:22 -04:00
bors
aaaed51ab8 Auto merge of #2279 - RalfJung:adjacent-allocs, r=RalfJung
Allow non-ZST allocations to be adjacent

Also `cargo update` in test-cargo-miri... no need to make a separate PR for that right?...
2022-06-28 02:52:23 +00:00
Ralf Jung
c16b380d6b finally we can actually have adjacent allocations :) 2022-06-27 22:52:02 -04:00
Ralf Jung
098704e10f make use of get_alloc_info 2022-06-27 21:22:46 -04:00
bors
7fafbde038 Auto merge of #2275 - RalfJung:permissive-provenance-for-all, r=RalfJung
Enable permissive provenance by default

This completes the plan laid out in https://github.com/rust-lang/miri/issues/2133:
- We use permissive provenance with wildcard pointers by default.
- We print a warning on int2ptr casts. `-Zmiri-permissive-provenance` suppresses the warning; `-Zmiri-strict-provenance` turns it into a hard error.
- Raw pointer tagging is now always enabled, so we remove the `-Zmiri-tag-raw-pointers` flag and the code for untagged pointers. (Passing the flag still works, for compatibility -- but we just ignore it, with a warning.)

We also fix an intptrcast issue:
- Only live allocations are considered when computing the AllocId from an address.

So, finally, Miri has a good story for ptr2int2ptr roundtrips *and* no weird false negatives when doing raw pointer stuff with Stacked Borrows. :-) 🎉   Thanks a lot to everyone who helped with this, in particular `@carbotaniuman` who convinced me this is even possible.

Fixes https://github.com/rust-lang/miri/issues/2133
Fixes https://github.com/rust-lang/miri/issues/1866
Fixes https://github.com/rust-lang/miri/issues/1993
2022-06-28 01:20:40 +00:00
Ralf Jung
c1eddbc7fe show int2ptr warning once for each span (but don't duplicate the long help) 2022-06-27 20:50:45 -04:00
Ralf Jung
67e89b53e2 fix warning text 2022-06-27 20:04:46 -04:00
Ralf Jung
5719897fb0
improve old comment 2022-06-27 13:38:32 -04:00
Ralf Jung
d9e7a3ae82 typo
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-06-27 09:08:56 -04:00
Ralf Jung
b479f092a8 avoid unnecessary indirection in miri-track-raw-pointers warning 2022-06-26 23:14:16 -04:00
Ralf Jung
1a5dfbeb7a fmt 2022-06-26 22:36:45 -04:00
Ralf Jung
5c16713056 remove support for untagged pointers
good riddance!
2022-06-26 22:19:56 -04:00
Ralf Jung
294ef15adb more int2ptr cast tests, and fix casting of addresses inside dead allocations 2022-06-26 22:19:56 -04:00
Ralf Jung
13d425daeb make permissive provenance and raw-ptr tagging the default 2022-06-26 21:14:42 -04:00
infrandomness
aa072d72cc Cargo fmt 2022-06-27 01:39:25 +02:00
infrandomness
84a02787d8 Address code review
- Merge pthread_attr_getstack shim to unix/foreign_items.rs
2022-06-27 01:39:24 +02:00
infrandomness
93c61f3905 Add pthread_attr_get_np shim 2022-06-27 01:39:24 +02:00
infrandomness
f2cbd3e2bc Add pthread_attr_getstack shim 2022-06-27 01:39:24 +02:00
infrandomness
e89b4d6df2 Fix panicking ui_tests framework 2022-06-27 01:39:24 +02:00
infrandomness
97a512070a Fix pending reviews 2022-06-27 01:39:24 +02:00
infrandomness
9130034337 Initial freebsd work 2022-06-27 01:39:24 +02:00
Ralf Jung
34be937d5f add -Zmiri-report-progress to regularly print a stacktrace of what we are executing 2022-06-26 14:31:57 -04:00
bors
1589ba3bbc Auto merge of #2264 - RalfJung:not-a-fixme, r=RalfJung
remove a FIXME that is not actually a bug
2022-06-25 15:54:31 +00:00
Ralf Jung
f66c64bed2 remove a FIXME that is not actually a bug 2022-06-25 11:52:29 -04:00
Ralf Jung
58c79c5b6f tweaks and feedback 2022-06-24 22:02:17 -04:00
Ralf Jung
4fbb284a99 implement 'delimited' expose tracking so we still detect some UB 2022-06-24 20:05:56 -04:00
Ralf Jung
8d6fdaa024 make the tests pass
(and some formatting)
2022-06-24 18:03:02 -04:00
Ralf Jung
c0f7118342 reorganize exposure code a bit 2022-06-24 16:45:22 -04:00
carbotaniuman
d1e7de117c Try fix stuff 2022-06-24 16:10:23 -04:00
carbotaniuman
c7feb014b0 Maybe this wil work 2022-06-24 16:10:23 -04:00
carbotaniuman
57ce47b728 Handle wildcard pointers in SB 2022-06-24 16:10:23 -04:00
bors
655eed35b7 Auto merge of #2248 - RalfJung:arc-drop-fix, r=RalfJung
do not protect SRW items

This is the Miri version of https://github.com/rust-lang/rust/pull/98017.
2022-06-22 21:39:41 +00:00
Ralf Jung
f992099820 fix ICE when const refers to extern static 2022-06-21 21:03:40 -07:00
Ralf Jung
8d1b2ca3ec check that tag_alloc_base_pointer is not called on the wrong things 2022-06-21 21:03:40 -07:00
Ralf Jung
1b214a0d12 do not protect SRW items 2022-06-21 09:32:58 -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