bors [Wed, 17 Aug 2022 02:08:35 +0000 (02:08 +0000)]
Auto merge of #2485 - 5225225:memalign, r=RalfJung
Breaking posix_memalign precondition is not UB
The `size==0` test here might be overtesting, but I figured might as well test it and leave a comment saying it is fine to remove it if the implementation changes.
bors [Tue, 16 Aug 2022 11:54:55 +0000 (11:54 +0000)]
Auto merge of #2489 - RalfJung:srw-merging, r=saethlin
add test that we do not merge neighboring SRW
Turns out that interior_mut2 also already tests this, but that also involves `UnsafeCell` so the new test still seems more clear. Basically the new test is the same as the old except that it uses raw pointers rather than `&UnsafeCell`. (When the old test was written, raw pointers were still untagged, so no such test would have been possible.)
I verified that both of these fail when we remove mutable references rather than disabling them.
Here is the patch I used for that:
# Be aware that this file is inside a workspace when used via the
diff --git a/src/lib.rs b/src/lib.rs
index ba337f28..2a3066f4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
`@@` -9,6 +9,7 `@@`
#![feature(is_some_with)]
#![feature(nonzero_ops)]
#![feature(local_key_cell_methods)]
+#![feature(drain_filter)]
// Configure clippy and other lints
#![allow(
clippy::collapsible_else_if,
diff --git a/src/stacked_borrows/stack.rs b/src/stacked_borrows/stack.rs
index 4a9a13d3..37246df7 100644
--- a/src/stacked_borrows/stack.rs
+++ b/src/stacked_borrows/stack.rs
`@@` -351,6 +351,9 `@@` impl<'tcx> Stack {
#[cfg(all(feature = "stack-cache", debug_assertions))]
self.verify_cache_consistency();
+ // HACK -- now just delete all disabled things.
+ self.borrows.drain_filter(|b| matches!(b.perm(), Permission::Disabled));
+
Ok(())
}
```
bors [Fri, 12 Aug 2022 15:26:53 +0000 (15:26 +0000)]
Auto merge of #2482 - RalfJung:raw-eq, r=RalfJung
add test for raw_eq on a pointer
Let's make sure this keeps erroring; I have plans to refactor that part of the interpreter which will fix the error message (but could also lead to us accidentally accepting this which this test is there to avoid).
bors [Wed, 10 Aug 2022 12:03:51 +0000 (12:03 +0000)]
Auto merge of #2461 - RalfJung:frame-in-std, r=RalfJung
add special exception for std_miri_test crate to call std-only functions
These being the unit tests of std, they have their own copy of `std::sys` and `std::thread`, so the existing check says this is not std. The check is correct but we want to allow this so we just hard-code the crate name.
The point of this `frame_in_std` check is to prevent people from directly interacting with shims that aren't really properly implemented, but it doesn't need to be 100% airtight. If someone really wants to call their crate `std_miri_test` in order to access some broken shims... they can keep the pieces.
bors [Mon, 8 Aug 2022 00:38:17 +0000 (00:38 +0000)]
Auto merge of #2471 - RalfJung:term, r=RalfJung
stop excluding TERM env var on Unix
Effectively reverts https://github.com/rust-lang/miri/pull/2018.
Needs https://github.com/rust-lang/rust/pull/100206 to not be terribly slow.
Fixes https://github.com/rust-lang/miri/issues/2292.
bors [Sun, 7 Aug 2022 15:54:32 +0000 (15:54 +0000)]
Auto merge of #2476 - RalfJung:target-dir, r=RalfJung
clarifying comments for target-dir handling
I thought we could simplify this logic, but alas, `cargo metadata --target-dir` is not a thing (even though the effective target-dir *does* affect the metadata).
bors [Sat, 6 Aug 2022 19:30:50 +0000 (19:30 +0000)]
Auto merge of #2472 - RalfJung:backtrace, r=RalfJung
fix RUSTC_BACKTRACE always being set
I kept wondering why Miri programs, whenever isolation is disabled, behave as if RUSTC_BACKTRACE was set. Finally I realized it's because some early rustc setup code sets that env var, and that is then propagated to the interpreted program.
So fix that by taking a copy of the environment before any rustc setup, and use that copy as the basis for what is provided to the interpreted program.
bors [Sat, 6 Aug 2022 00:19:08 +0000 (00:19 +0000)]
Auto merge of #2465 - RalfJung:strerror_r, r=RalfJung
avoid strerror_r failure on unknown errnum
This is an informative function anyway, so as fallback just return a string with the raw errnum. Avoids panics / interpreter aborts in std on unknown errnum in from_raw_os_error.
bors [Wed, 3 Aug 2022 15:56:13 +0000 (15:56 +0000)]
Auto merge of #2460 - LegNeato:sysconf, r=RalfJung
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
```
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
```
Auto merge of #2450 - avrong:cargo-metadata, r=oli-obk
Use cargo_metadata in cargo-miri
Closes #2393
Added `cargo_metadata` to `cargo-miri` and changed metadata from manual parsing to `cargo_metadata` invocations. Thus, removed local `Metadata` struct too.
Ben Kimock [Sat, 23 Jul 2022 17:59:08 +0000 (13:59 -0400)]
Use real exec on cfg(unix) targets
When cargo-miri is executed as a cargo test runner or rustdoc runtool,
external tools expect what they launch as the runner/runtool to be the
process actually running the test. But in the implementation, we launch
the Miri interpreter as a subprocess using std::process::Command. This
tends to confuse other tools (like nextest) and users (like the author).
What we really want is to call POSIX exec so that the cargo-miri process
becomes the interpreter.
So this implements just that; we call execve via a cfg(unix) extension
trait. Windows has no such mechanism, but it also doesn't have POSIX
signals, which is the primary tripping hazard this change fixes.