Skip to content

Miri subtree update #121232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9eb94e8
moving out sched_getaffinity interception from linux'shim, FreeBSD su…
devnexen Jan 29, 2024
3d26a41
Switch over to rustc's `tracing` crate instead of using our own `log`…
oli-obk Jul 3, 2023
a6f1dba
Implement the `mmap64` foreign item.
sunfishcode Jan 30, 2024
e47bb90
add num_cpus test
devnexen Jan 30, 2024
63524ee
Preparing for merge from rustc
Jan 31, 2024
38b8bd3
Merge from rustc
Jan 31, 2024
24fece2
fmt
Jan 31, 2024
562d529
Auto merge of #3286 - rust-lang:rustup-2024-01-31, r=saethlin
bors Jan 31, 2024
fae29fd
Auto merge of #3283 - devnexen:fbsd_affinity, r=oli-obk
bors Jan 31, 2024
0602b13
Auto merge of #2956 - oli-obk:atty, r=RalfJung
bors Feb 3, 2024
5587a37
Stop recommending cargo clean in README
tv42 Feb 4, 2024
f45a5b1
Auto merge of #3290 - tv42:master, r=saethlin
bors Feb 4, 2024
eaa2da5
Preparing for merge from rustc
Feb 6, 2024
08e7741
Merge from rustc
Feb 6, 2024
35551d0
Auto merge of #3291 - rust-lang:rustup-2024-02-06, r=saethlin
bors Feb 6, 2024
cab1cc4
Preparing for merge from rustc
Feb 8, 2024
c232e94
Merge from rustc
Feb 8, 2024
964a576
fmt
Feb 8, 2024
a5077d9
Auto merge of #3292 - rust-lang:rustup-2024-02-08, r=saethlin
bors Feb 8, 2024
d4b8ed0
Preparing for merge from rustc
Feb 10, 2024
3e97b41
Merge from rustc
Feb 10, 2024
45d5d4b
fmt
Feb 10, 2024
5a3a2d5
Auto merge of #3293 - rust-lang:rustup-2024-02-10, r=saethlin
bors Feb 10, 2024
aa40634
Factor out the redundancy between `test_mmap` and `test_mmap64`.
sunfishcode Feb 10, 2024
0913e22
Preparing for merge from rustc
Feb 11, 2024
31b6625
Merge from rustc
Feb 11, 2024
48bb2bf
fmt
Feb 11, 2024
a40a100
Auto merge of #3294 - rust-lang:rustup-2024-02-11, r=saethlin
bors Feb 11, 2024
438f43c
Make the `mmap64` implementation Linux-specific.
sunfishcode Feb 11, 2024
064ad45
Move `mmap64`'s implementation under "File related shims".
sunfishcode Feb 11, 2024
e2b42a5
Auto merge of #3285 - sunfishcode:sunfishcode/mmap64, r=RalfJung
bors Feb 11, 2024
b38d871
add tests for imported_main
RalfJung Feb 11, 2024
cad872a
Auto merge of #3295 - RalfJung:imported_main, r=RalfJung
bors Feb 11, 2024
ca7a4b5
Preparing for merge from rustc
RalfJung Feb 12, 2024
c41d5b1
Merge from rustc
RalfJung Feb 12, 2024
fe4d327
comment tweaks
RalfJung Feb 12, 2024
781190f
also test pthread_mutex/rwlock directly
RalfJung Feb 12, 2024
d2e446d
Auto merge of #3296 - RalfJung:rustup, r=RalfJung
bors Feb 12, 2024
760e8d2
Preparing for merge from rustc
Feb 13, 2024
893615f
Merge from rustc
Feb 13, 2024
43e9411
Prevent rustfmt from messing up experimental syntax
oli-obk Feb 13, 2024
41555ab
Auto merge of #3298 - rust-lang:rustup-2024-02-13, r=oli-obk
bors Feb 13, 2024
6539a64
Preparing for merge from rustc
RalfJung Feb 14, 2024
7a086ac
Merge from rustc
RalfJung Feb 14, 2024
17693eb
remove no-longer needed rustfmt::skip
RalfJung Feb 14, 2024
6c117f6
Auto merge of #3300 - RalfJung:rustup, r=RalfJung
bors Feb 14, 2024
089eb6b
Preparing for merge from rustc
Feb 16, 2024
f1abde7
Merge from rustc
Feb 16, 2024
840ca09
fmt
Feb 16, 2024
c335b4e
Auto merge of #3301 - rust-lang:rustup-2024-02-16, r=saethlin
bors Feb 16, 2024
524c16d
Implement x86 AVX intrinsics
eduardosm Nov 26, 2023
d2a4ef3
Auto merge of #3192 - eduardosm:x86-avx-intrinsics, r=RalfJung
bors Feb 16, 2024
63240d7
Preparing for merge from rustc
Feb 17, 2024
d523cab
Merge from rustc
Feb 17, 2024
bbfce91
Auto merge of #3303 - rust-lang:rustup-2024-02-17, r=saethlin
bors Feb 17, 2024
fd5a84b
update lockfile
RalfJung Feb 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2524,14 +2524,12 @@ dependencies = [
"aes",
"colored",
"ctrlc",
"env_logger 0.10.2",
"getrandom",
"jemalloc-sys",
"lazy_static",
"libc",
"libffi",
"libloading",
"log",
"measureme",
"rand",
"regex",
Expand Down
11 changes: 10 additions & 1 deletion src/tools/miri/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ custom target file, you might have to set `MIRI_NO_STD=1`.
base directory, e.g. `./miri test fail` will run all compile-fail tests). These filters are passed
to `cargo test`, so for multiple filers you need to use `./miri test -- FILTER1 FILTER2`.

#### Fine grained logging

You can get a trace of which MIR statements are being executed by setting the
`MIRI_LOG` environment variable. For example:

Expand All @@ -94,9 +96,16 @@ stacked borrows implementation:
MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows ./miri run tests/pass/vec.rs
```

In addition, you can set `MIRI_BACKTRACE=1` to get a backtrace of where an
Note that you will only get `info`, `warn` or `error` messages if you use a prebuilt compiler.
In order to get `debug` and `trace` level messages, you need to build miri with a locally built
compiler that has `debug=true` set in `config.toml`.

#### Debugging error messages

You can set `MIRI_BACKTRACE=1` to get a backtrace of where an
evaluation error was originally raised.


### UI testing

We use ui-testing in Miri, meaning we generate `.stderr` and `.stdout` files for the output
Expand Down
56 changes: 0 additions & 56 deletions src/tools/miri/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,6 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"

[[package]]
name = "env_logger"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"
dependencies = [
"humantime",
"is-terminal",
"log",
"regex",
"termcolor",
]

[[package]]
name = "errno"
version = "0.3.8"
Expand Down Expand Up @@ -339,18 +326,6 @@ version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"

[[package]]
name = "hermit-abi"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"

[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"

[[package]]
name = "indenter"
version = "0.3.3"
Expand Down Expand Up @@ -388,17 +363,6 @@ dependencies = [
"cfg-if",
]

[[package]]
name = "is-terminal"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455"
dependencies = [
"hermit-abi",
"rustix",
"windows-sys 0.52.0",
]

[[package]]
name = "itoa"
version = "1.0.10"
Expand Down Expand Up @@ -529,14 +493,12 @@ dependencies = [
"aes",
"colored",
"ctrlc",
"env_logger",
"getrandom",
"jemalloc-sys",
"lazy_static",
"libc",
"libffi",
"libloading",
"log",
"measureme",
"rand",
"regex",
Expand Down Expand Up @@ -875,15 +837,6 @@ dependencies = [
"windows-sys 0.52.0",
]

[[package]]
name = "termcolor"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
dependencies = [
"winapi-util",
]

[[package]]
name = "thiserror"
version = "1.0.56"
Expand Down Expand Up @@ -1034,15 +987,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"

[[package]]
name = "winapi-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]

[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ doctest = false # and no doc tests

[dependencies]
getrandom = { version = "0.2", features = ["std"] }
env_logger = "0.10"
log = "0.4"
rand = "0.8"
smallvec = "1.7"
aes = { version = "0.8.3", features = ["hazmat"] }
Expand Down
7 changes: 2 additions & 5 deletions src/tools/miri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,8 @@ assume the right toolchain is pinned via `rustup override set nightly` or

Now you can run your project in Miri:

1. Run `cargo clean` to eliminate any cached dependencies. Miri needs your
dependencies to be compiled the right way, that would not happen if they have
previously already been compiled.
2. To run all tests in your project through Miri, use `cargo miri test`.
3. If you have a binary project, you can run it through Miri using `cargo miri run`.
- To run all tests in your project through Miri, use `cargo miri test`.
- If you have a binary project, you can run it through Miri using `cargo miri run`.

The first time you run Miri, it will perform some extra setup and install some
dependencies. It will ask you for confirmation before installing anything.
Expand Down
5 changes: 3 additions & 2 deletions src/tools/miri/ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ case $HOST_TARGET in
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
# Some targets are only partially supported.
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align
MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus
MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthread-threadname libc-getentropy libc-getrandom libc-misc libc-fs atomic env align num_cpus

MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm
MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dd2559e08e1530806740931037d6bb83ef956161
4316d0c6252cb1f833e582dfa68adb98efd5ddfb
12 changes: 4 additions & 8 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
clippy::useless_format,
clippy::field_reassign_with_default,
rustc::diagnostic_outside_of_impl,
rustc::untranslatable_diagnostic,
rustc::untranslatable_diagnostic
)]

extern crate rustc_data_structures;
Expand All @@ -16,14 +16,14 @@ extern crate rustc_log;
extern crate rustc_metadata;
extern crate rustc_middle;
extern crate rustc_session;
#[macro_use]
extern crate tracing;

use std::env::{self, VarError};
use std::num::NonZero;
use std::path::PathBuf;
use std::str::FromStr;

use log::debug;

use rustc_data_structures::sync::Lrc;
use rustc_driver::Compilation;
use rustc_hir::{self as hir, Node};
Expand Down Expand Up @@ -200,7 +200,7 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {
// CTFE-related. Otherwise, we use it verbatim for `RUSTC_LOG`.
// This way, if you set `MIRI_LOG=trace`, you get only the right parts of
// rustc traced, but you can also do `MIRI_LOG=miri=trace,rustc_const_eval::interpret=debug`.
if log::Level::from_str(&var).is_ok() {
if tracing::Level::from_str(&var).is_ok() {
cfg.filter = Ok(format!(
"rustc_middle::mir::interpret={var},rustc_const_eval::interpret={var}"
));
Expand All @@ -218,10 +218,6 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {
}

fn init_early_loggers(early_dcx: &EarlyDiagCtxt) {
// Note that our `extern crate log` is *not* the same as rustc's; as a result, we have to
// initialize them both, and we always initialize `miri`'s first.
let env = env_logger::Env::new().filter("MIRI_LOG").write_style("MIRI_LOG_STYLE");
env_logger::init_from_env(env);
// Now for rustc. We only initialize `rustc` if the env var is set (so the user asked for it).
// If it is not set, we avoid initializing now so that we can initialize later with our custom
// settings, and *not* log anything for what happens before `miri` gets started.
Expand Down
1 change: 0 additions & 1 deletion src/tools/miri/src/borrow_tracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::cell::RefCell;
use std::fmt;
use std::num::NonZero;

use log::trace;
use smallvec::SmallVec;

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use std::cmp;
use std::fmt::Write;
use std::mem;

use log::trace;

use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir::{Mutability, RetagKind};
use rustc_middle::ty::{self, layout::HasParamEnv, Ty};
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl<'tcx> Stack {
let upper = unique_range.end;
for item in &mut self.borrows[lower..upper] {
if item.perm() == Permission::Unique {
log::trace!("access: disabling item {:?}", item);
trace!("access: disabling item {:?}", item);
visitor(*item)?;
item.set_permission(Permission::Disabled);
// Also update all copies of this item in the cache.
Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use log::trace;

use rustc_target::abi::{Abi, Size};

use crate::borrow_tracker::{AccessKind, GlobalState, GlobalStateInner, ProtectorKind};
Expand Down
20 changes: 10 additions & 10 deletions src/tools/miri/src/concurrency/data_race.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ impl MemoryCellClocks {
index: VectorIdx,
access_size: Size,
) -> Result<(), DataRace> {
log::trace!("Atomic read with vectors: {:#?} :: {:#?}", self, thread_clocks);
trace!("Atomic read with vectors: {:#?} :: {:#?}", self, thread_clocks);
let atomic = self.atomic_access(thread_clocks, access_size)?;
atomic.read_vector.set_at_index(&thread_clocks.clock, index);
// Make sure the last non-atomic write and all non-atomic reads were before this access.
Expand All @@ -485,7 +485,7 @@ impl MemoryCellClocks {
index: VectorIdx,
access_size: Size,
) -> Result<(), DataRace> {
log::trace!("Atomic write with vectors: {:#?} :: {:#?}", self, thread_clocks);
trace!("Atomic write with vectors: {:#?} :: {:#?}", self, thread_clocks);
let atomic = self.atomic_access(thread_clocks, access_size)?;
atomic.write_vector.set_at_index(&thread_clocks.clock, index);
// Make sure the last non-atomic write and all non-atomic reads were before this access.
Expand All @@ -504,7 +504,7 @@ impl MemoryCellClocks {
index: VectorIdx,
current_span: Span,
) -> Result<(), DataRace> {
log::trace!("Unsynchronized read with vectors: {:#?} :: {:#?}", self, thread_clocks);
trace!("Unsynchronized read with vectors: {:#?} :: {:#?}", self, thread_clocks);
if !current_span.is_dummy() {
thread_clocks.clock[index].span = current_span;
}
Expand Down Expand Up @@ -533,7 +533,7 @@ impl MemoryCellClocks {
write_type: NaWriteType,
current_span: Span,
) -> Result<(), DataRace> {
log::trace!("Unsynchronized write with vectors: {:#?} :: {:#?}", self, thread_clocks);
trace!("Unsynchronized write with vectors: {:#?} :: {:#?}", self, thread_clocks);
if !current_span.is_dummy() {
thread_clocks.clock[index].span = current_span;
}
Expand Down Expand Up @@ -743,7 +743,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
&this.machine.threads,
current_span,
|index, mut clocks| {
log::trace!("Atomic fence on {:?} with ordering {:?}", index, atomic);
trace!("Atomic fence on {:?} with ordering {:?}", index, atomic);

// Apply data-race detection for the current fences
// this treats AcqRel and SeqCst as the same as an acquire
Expand Down Expand Up @@ -841,7 +841,7 @@ impl VClockAlloc {
// Find an index, if one exists where the value
// in `l` is greater than the value in `r`.
fn find_gt_index(l: &VClock, r: &VClock) -> Option<VectorIdx> {
log::trace!("Find index where not {:?} <= {:?}", l, r);
trace!("Find index where not {:?} <= {:?}", l, r);
let l_slice = l.as_slice();
let r_slice = r.as_slice();
l_slice
Expand Down Expand Up @@ -1270,7 +1270,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
// Load and log the atomic operation.
// Note that atomic loads are possible even from read-only allocations, so `get_alloc_extra_mut` is not an option.
let alloc_meta = this.get_alloc_extra(alloc_id)?.data_race.as_ref().unwrap();
log::trace!(
trace!(
"Atomic op({}) with ordering {:?} on {:?} (size={})",
access.description(),
&atomic,
Expand Down Expand Up @@ -1311,11 +1311,11 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
)?;

// Log changes to atomic memory.
if log::log_enabled!(log::Level::Trace) {
if tracing::enabled!(tracing::Level::TRACE) {
for (_offset, mem_clocks) in
alloc_meta.alloc_ranges.borrow().iter(base_offset, size)
{
log::trace!(
trace!(
"Updated atomic memory({:?}, size={}) to {:#?}",
place.ptr(),
size.bytes(),
Expand Down Expand Up @@ -1530,7 +1530,7 @@ impl GlobalState {
vector_info.push(thread)
};

log::trace!("Creating thread = {:?} with vector index = {:?}", thread, created_index);
trace!("Creating thread = {:?} with vector index = {:?}", thread, created_index);

// Mark the chosen vector index as in use by the thread.
thread_info[thread].vector_index = Some(created_index);
Expand Down
Loading