bors [Mon, 30 Aug 2021 15:33:59 +0000 (15:33 +0000)]
Auto merge of #1879 - oli-obk:gitpod, r=RalfJung
Try out gitpod
At https://gitpod.io/#https://github.com/rust-lang/miri one can edit miri in the browser and run it and everything.
I'm experimenting with this here as a low-impact version of trying it out on the whole rustc repo. This .gitpod file should cause the user to land in a shell that can run ./miri test immediately without any additional prep
bors [Tue, 24 Aug 2021 12:39:59 +0000 (12:39 +0000)]
Auto merge of #1877 - hyd-dev:rustup, r=RalfJung
Add `#[allow(unreachable_code)]` to `drop(x)` in `tests/run-pass/generator.rs`
The test [starts to trigger this warning](https://github.com/rust-lang/miri/runs/3408355084?check_suite_focus=true#step:8:264) (I guess it's caused by rust-lang/rust#85556). The warning seems correct, but the unreachable code in that test also seems reasonable.
bors [Mon, 23 Aug 2021 10:55:48 +0000 (10:55 +0000)]
Auto merge of #1875 - niluxv:volatile_set_memory_intrinsic, r=RalfJung
Add support for the `volatile_set_memory` intrinsic
Add support for the unstable `volatile_set_memory` intrinsic
(Runtime behaviour and soundness requirements for `volatile_set_memory` are identical to those of `write_bytes`, so supporting this intrinsic is trivial.)
bors [Sun, 15 Aug 2021 11:41:00 +0000 (11:41 +0000)]
Auto merge of #1871 - hyd-dev:no-mangle-method, r=RalfJung
Update tests for `#[no_mangle]` on associated functions
https://github.com/rust-lang/rust/pull/86492 has landed:
- The code in https://github.com/rust-lang/miri/issues/1837 starts to work (even without `AssocFn::foo();` at line 12) in Miri.
- `pub` is not necessary for `#[no_mangle]` associated functions in `test-cargo-miri/exported-symbol-dep/src/lib.rs` anymore.
bors [Wed, 4 Aug 2021 09:25:18 +0000 (09:25 +0000)]
Auto merge of #1864 - hyd-dev:rustup, r=RalfJung
Update cargo-miri test
The doctest output was [changed](https://github.com/rust-lang/miri/runs/3238758260?check_suite_focus=true#step:8:1263) (probably by https://github.com/rust-lang/cargo/pull/9730). Update `test-cargo-miri/test.default.stdout.ref` to match the new output.
Auto merge of #1863 - hyd-dev:parallel-compiler, r=RalfJung
Use `Lrc` instead of `Rc` in `MiriCompilerCalls::config()`
The `used_crate_source` query defines its return type as [`Lrc<CrateSource>`](https://github.com/rust-lang/rust/blob/1195bea5a7b73e079fa14b37ac7e375fc77d368a/compiler/rustc_middle/src/query/mod.rs#L1418), which would be `Arc` when `parallel-compiler = true`.
I assume this fixes rust-lang/rust#87623. I didn't test that locally -- I'm not interested in `parallel-compiler = true` enough to be willing to recompile rustc with that configuration to test it, but I'm submitting this in case it might be useful for `parallel-compiler = true` users.
Auto merge of #1858 - RalfJung:thread-leaks, r=oli-obk
also ignore 'thread leaks' with -Zmiri-ignore-leaks
This is a step towards https://github.com/rust-lang/miri/issues/1371. The remaining hard part would be supporting checking for memory leaks when there are threads still running. For now we elegantly avoid this problem by using the same flag to control both of these checks. :)
Auto merge of #1838 - atsmtat:fs-isolation, r=RalfJung
Fix use of deprecated `check_no_isolation` in posix fs shims
Update posix fs shims to use new API `reject_in_isolation`, which
allows rejection with error code instead of always forcing abort.
Error code chosen for each op is the most appropriate one from the
list in corresponding syscall's manual.
Updated helper APIs to not use quotes (\`) around input name while
preparing the message. This allows callers to pass multi-word string
like -- "\`read\` from stdin".
Smit Soni [Wed, 16 Jun 2021 00:33:18 +0000 (17:33 -0700)]
Fix use of deprecated `check_no_isolation` in posix fs ops
Update posix fs shims to use new API `reject_in_isolation`, which
allows rejection with error code instead of always forcing abort.
Error code chosen for each op is the most appropriate one from the
list in corresponding syscall's manual.
Updated helper APIs to not use quotes (`) around input name while
preparing the message. This allows callers to pass multi-word string
like -- "`read` from stdin".
This test was removed in rustc in https://github.com/rust-lang/rust/pull/87141.
We added it in https://github.com/rust-lang/miri/pull/1430, and possibly that "interesting case in unsizing" is not covered by tests now -- but I don't remember what that case is.^^ If/when `impl Trait` in bindings comes back, we should copy the new rustc tests to Miri as well.
This is an experiment, I am not yet sure if I like it... but it does prevent rustfmt from putting stuff after the `=>` in a `match` (unless the entire arm fits there), which IMO is a big plus. What do others think?
(I also tried setting `match_arm_blocks` back to its default of `true`, but that adds too many braces for my taste.)
Btw, `@calebcartwright` is the interaction of `match_arm_blocks = false` and `force_multiline_blocks = true` as can be seen here expected? I think I like it, but it it is not at all what I expected from the docs which describe `force_multiline_blocks = true` as "Force multiline closure and match arm bodies to be wrapped in a block" -- but here that is not the effect it has, there are no new blocks being added.
Auto merge of #1842 - hyd-dev:target-dir, r=RalfJung
Use `miri` inside the target directory used by rustc as Miri's target directory
Resolves #1311.
This PR makes Miri use `miri` inside the rustc target directory as its target directory, by letting `cargo-miri` get the rustc target directory by calling `cargo metadata`, append `miri` to it, and pass it with `--target-dir` to Cargo.
Getting the rustc target directory accurately requires calling `cargo metadata` as far as I know, because the `target-dir` can be set in config files in various places that are hard for `cargo-miri` to find.
I also considered https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#custom-named-profiles, but it looks like that requires adding `cargo-features = ["named-profiles"]` to **`Cargo.toml`**, which would be tricky for `cargo-miri`:
```
$ cargo +nightly-2021-06-23 test --config 'profile.miri.inherits="release"' --profile=miri -Z named-profiles -Z unstable-options
error: config profile `miri` is not valid (defined in `--config cli option`)
Caused by:
feature `named-profiles` is required
consider adding `cargo-features = ["named-profiles"]` to the manifest
```
bors [Tue, 15 Jun 2021 10:07:24 +0000 (10:07 +0000)]
Auto merge of #1833 - hyd-dev:82261, r=RalfJung
Filter out items other than non-generic functions and statics in our version of `exported_symbols`
[`#[no_mangle]` on a `use` item](https://docs.rs/brotli-decompressor/2.3.1/src/brotli_decompressor/ffi/mod.rs.html#3-5) can make Miri ICE when compiling a dependency (rust-lang/rust#86261):
```rs
#[no_mangle]
use std::{thread,panic, io, boxed, any, string};
```
<details>
```
error: internal compiler error: compiler/rustc_middle/src/ty/mod.rs:1650:13: item_name: no name for DefPath { data: [DisambiguatedDefPathData { data: Misc, disambiguator: 14 }], krate: crate0 }
thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1007:9
stack backtrace:
0: std::panicking::begin_panic
1: std::panic::panic_any
2: rustc_errors::HandlerInner::bug
3: rustc_errors::Handler::bug
4: rustc_middle::ty::context::tls::with_opt
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::bug_fmt
7: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::item_name
8: rustc_symbol_mangling::symbol_name_provider
9: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::symbol_name>::compute
10: rustc_query_system::query::plumbing::get_query_impl
11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::symbol_name
12: rustc_middle::middle::exported_symbols::ExportedSymbol::symbol_name_for_local_instance
13: rustc_codegen_ssa::back::symbol_export::symbol_name_for_instance_in_crate
14: rustc_codegen_ssa::back::linker::exported_symbols
15: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
16: rustc_codegen_ssa::back::linker::LinkerInfo::new
17: rustc_codegen_ssa::back::write::start_async_codegen
18: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
19: rustc_interface::passes::QueryContext::enter
20: rustc_interface::queries::Queries::ongoing_codegen
21: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
22: rustc_span::with_source_map
23: rustc_interface::interface::create_compiler_and_run
24: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.54.0-nightly (a50d72158 2021-06-08) running on x86_64-unknown-linux-gnu
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [symbol_name] computing the symbol for `{misc#14}`
end of query stack
```
</details>
This might be because in #1776, we override the `exported_symbols` query, and our version of `exported_symbols` can return a `use` item which don't have a name if the `use` item is tagged with `#[no_mangle]`, and then:
- `rustc_codegen_ssa::back::symbol_export::symbol_name_for_instance_in_crate` is called for for every `exported_symbols`: https://github.com/rust-lang/rust/blob/fb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2/compiler/rustc_codegen_ssa/src/back/linker.rs#L1300-L1304
- it calls `rustc_middle::middle::exported_symbols::ExportedSymbol::symbol_name_for_local_instance`: https://github.com/rust-lang/rust/blob/fb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2/compiler/rustc_codegen_ssa/src/back/symbol_export.rs#L412
- which calls `rustc_symbol_mangling::symbol_name_provider`: https://github.com/rust-lang/rust/blob/fb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2/compiler/rustc_middle/src/middle/exported_symbols.rs#L37-L44
- which calls `item_name`: https://github.com/rust-lang/rust/blob/fb3ea63d9b4c3e9bb90d4250b870faaffb9c8fd2/compiler/rustc_symbol_mangling/src/lib.rs#L216, which triggers the ICE
It might also be problematic for https://github.com/rust-lang/miri/blob/d39f0c64b8b369188a73a655716ab56683a6537b/src/shims/foreign_items.rs#L165 which also uses `item_name`, but Miri cannot compile the dependency, so that code can't be reached.
Therefore, this PR makes `exported_symbols` filter out all items that are not functions or statics, so all items returned will have a name, which avoids the ICE (I have tested it in the https://github.com/jorgecarleitao/arrow2 repository).
(This PR also includes a commit that fixes a small (unrelated) bug for `#[no_mangle]` on associated functions -- I found that because I notice `#[no_mangle]` is supported on associated functions and they should not be filtered out in `exported_symbols`.)
Fixes (when the submodule is bumped) rust-lang/rust#86261.
The error looks like this:
```
error: found `malloc` symbol definition that clashes with a built-in shim
--> tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:12:9
|
12 | malloc(0);
| ^^^^^^^^^ found `malloc` symbol definition that clashes with a built-in shim
|
help: the `malloc` symbol is defined here
--> tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:2:1
|
2 | / extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void {
3 | | //~^ HELP the `malloc` symbol is defined here
4 | | unreachable!()
5 | | }
| |_^
= note: inside `main` at tests/compile-fail/function_calls/exported_symbol_shim_clashing.rs:12:9
```
This does not implement "better error messages than we do currently for arg/ABI mismatches" in https://github.com/rust-lang/miri/pull/1776#issuecomment-821343175 -- I failed to remove all `check_arg_count()` and `check_abi()` (they are still used in `src/shims/intrinsics.rs` and `call_dlsym()`) and they don't receive the name of the shim.