]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #1846 - RalfJung:license, r=RalfJung
bors [Tue, 6 Jul 2021 11:58:42 +0000 (11:58 +0000)]
Auto merge of #1846 - RalfJung:license, r=RalfJung

sync license files with rustc repo

`@Mark-Simulacrum` pointed out that our license files are slightly different from those in rustc. This syncs them.

The question is... is this a thing we can just do?^^

2 years agoAuto merge of #1847 - RalfJung:more-tags, r=RalfJung
bors [Tue, 6 Jul 2021 08:14:03 +0000 (08:14 +0000)]
Auto merge of #1847 - RalfJung:more-tags, r=RalfJung

also treat CallerLocation and Machine memory as properly tagged

Only heap allocations need an exception.

2 years agofmt
Ralf Jung [Tue, 6 Jul 2021 08:13:30 +0000 (10:13 +0200)]
fmt

2 years agoexported_symbols_cache: ensure we do not overwrite anything
Ralf Jung [Tue, 6 Jul 2021 08:09:53 +0000 (10:09 +0200)]
exported_symbols_cache: ensure we do not overwrite anything

2 years agoalso treat CallerLocation and Machine memory as properly tagged
Ralf Jung [Tue, 6 Jul 2021 08:07:48 +0000 (10:07 +0200)]
also treat CallerLocation and Machine memory as properly tagged

2 years agoexplicitly list memory kinds for stacked borrows
Ralf Jung [Tue, 6 Jul 2021 08:04:16 +0000 (10:04 +0200)]
explicitly list memory kinds for stacked borrows

2 years agosync license files with rustc repo
Ralf Jung [Mon, 5 Jul 2021 17:34:08 +0000 (19:34 +0200)]
sync license files with rustc repo

2 years agoAuto merge of #1845 - Smittyvb:fix-after-mir-alloc-oom, r=RalfJung
bors [Sun, 4 Jul 2021 20:35:34 +0000 (20:35 +0000)]
Auto merge of #1845 - Smittyvb:fix-after-mir-alloc-oom, r=RalfJung

Make work with latest rustc

Cc https://github.com/rust-lang/rust/issues/86863, which was caused by PR https://github.com/rust-lang/rust/pull/86255.

2 years agoMake work after mir-alloc-oom
Smitty [Sun, 4 Jul 2021 13:59:55 +0000 (09:59 -0400)]
Make work after mir-alloc-oom

2 years agoAuto merge of #1842 - hyd-dev:target-dir, r=RalfJung
bors [Sat, 3 Jul 2021 07:34:41 +0000 (07:34 +0000)]
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
```

2 years agoAuto merge of #1844 - hyd-dev:rustup, r=RalfJung
bors [Fri, 2 Jul 2021 08:49:49 +0000 (08:49 +0000)]
Auto merge of #1844 - hyd-dev:rustup, r=RalfJung

Update for `TyCtxt::crates()` change

cc rust-lang/rust#86792

2 years agoImport `std::process::self`
hyd-dev [Fri, 2 Jul 2021 08:22:59 +0000 (16:22 +0800)]
Import `std::process::self`

2 years agoAdd a comment in `.github/workflows/ci.yml`
hyd-dev [Fri, 2 Jul 2021 08:20:55 +0000 (16:20 +0800)]
Add a comment in `.github/workflows/ci.yml`

2 years agoUpdate for `TyCtxt::crates()` change
hyd-dev [Fri, 2 Jul 2021 08:08:27 +0000 (16:08 +0800)]
Update for `TyCtxt::crates()` change

2 years agoAuto merge of #1843 - RalfJung:rustup, r=RalfJung
bors [Tue, 29 Jun 2021 18:48:08 +0000 (18:48 +0000)]
Auto merge of #1843 - RalfJung:rustup, r=RalfJung

rustup

Cc https://github.com/rust-lang/rust/issues/86723

2 years agorustup
Ralf Jung [Tue, 29 Jun 2021 18:47:28 +0000 (20:47 +0200)]
rustup

3 years agoImprove doc comment
hyd-dev [Sun, 27 Jun 2021 15:09:10 +0000 (23:09 +0800)]
Improve doc comment

3 years agoFix `.expect()` message
hyd-dev [Sun, 27 Jun 2021 15:08:38 +0000 (23:08 +0800)]
Fix `.expect()` message

3 years ago`drop(cmd.arg(arg))` -> `cmd.arg(arg);`
hyd-dev [Sun, 27 Jun 2021 15:07:15 +0000 (23:07 +0800)]
`drop(cmd.arg(arg))` -> `cmd.arg(arg);`

3 years agoUse `rustup-toolchain-install-master` to install Cargo
hyd-dev [Sat, 26 Jun 2021 12:43:31 +0000 (20:43 +0800)]
Use `rustup-toolchain-install-master` to install Cargo

3 years agoShow error if `--target-dir` is provided more than once
hyd-dev [Sat, 26 Jun 2021 14:36:05 +0000 (22:36 +0800)]
Show error if `--target-dir` is provided more than once

3 years agoFix typo
hyd-dev [Sat, 26 Jun 2021 14:22:40 +0000 (22:22 +0800)]
Fix typo

3 years ago`ArgFlagValueWithOtherArgsIter` -> `ArgSplitFlagValue`
hyd-dev [Sat, 26 Jun 2021 13:49:56 +0000 (21:49 +0800)]
`ArgFlagValueWithOtherArgsIter` -> `ArgSplitFlagValue`

3 years agoAdd some comments in `test-cargo-miri/run-tests.py`
hyd-dev [Sat, 26 Jun 2021 13:45:38 +0000 (21:45 +0800)]
Add some comments in `test-cargo-miri/run-tests.py`

3 years agolong closure -> function
hyd-dev [Sat, 26 Jun 2021 13:24:01 +0000 (21:24 +0800)]
long closure -> function

3 years agoUse `miri` inside the target directory used by rustc as Miri's target directory
hyd-dev [Wed, 23 Jun 2021 18:35:08 +0000 (02:35 +0800)]
Use `miri` inside the target directory used by rustc as Miri's target directory

3 years agoAuto merge of #1841 - RalfJung:debug, r=RalfJung
bors [Sun, 20 Jun 2021 17:47:42 +0000 (17:47 +0000)]
Auto merge of #1841 - RalfJung:debug, r=RalfJung

use exhaustive struct match for manual Debug impl

3 years agouse exhaustive struct match for manual Debug impl
Ralf Jung [Sun, 20 Jun 2021 17:33:05 +0000 (19:33 +0200)]
use exhaustive struct match for manual Debug impl

3 years agoAuto merge of #1840 - hyd-dev:rustup, r=RalfJung
bors [Sun, 20 Jun 2021 09:54:48 +0000 (09:54 +0000)]
Auto merge of #1840 - hyd-dev:rustup, r=RalfJung

Update backtraces

(rust-lang/rust#86034 changed them.)

cc rust-lang/rust#86474

3 years agoUpdate backtraces
hyd-dev [Sun, 20 Jun 2021 07:12:11 +0000 (15:12 +0800)]
Update backtraces

3 years agoAuto merge of #1839 - RalfJung:rustup, r=RalfJung
bors [Thu, 17 Jun 2021 18:53:16 +0000 (18:53 +0000)]
Auto merge of #1839 - RalfJung:rustup, r=RalfJung

rustup

Cc https://github.com/rust-lang/rust/issues/86409

3 years agorustup
Ralf Jung [Thu, 17 Jun 2021 18:52:35 +0000 (20:52 +0200)]
rustup

3 years agoAuto merge of #1833 - hyd-dev:82261, r=RalfJung
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: compiler flags: -C embed-bitcode=no -C debuginfo=1 --crate-type lib

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.

3 years agoAuto merge of #1832 - hyd-dev:1776-follow-up, r=RalfJung
bors [Tue, 15 Jun 2021 09:53:05 +0000 (09:53 +0000)]
Auto merge of #1832 - hyd-dev:1776-follow-up, r=RalfJung

Report an error if a `#[no_mangle]`/`#[export_name = ...]` function has the same symbol name as a built-in shim

Implements https://github.com/rust-lang/miri/pull/1776#issuecomment-821322605.

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.

3 years agoAuto merge of #1836 - hyd-dev:rustup, r=RalfJung
bors [Tue, 15 Jun 2021 09:38:44 +0000 (09:38 +0000)]
Auto merge of #1836 - hyd-dev:rustup, r=RalfJung

Rustup

cc https://github.com/rust-lang/rust/issues/86316

(I beat `@lqd` to this!)

3 years agoRustup
hyd-dev [Tue, 15 Jun 2021 08:11:49 +0000 (16:11 +0800)]
Rustup

3 years agoRename all `link_name_sym` to `link_name` and remove the only remaining `let link_nam...
hyd-dev [Mon, 14 Jun 2021 17:24:09 +0000 (01:24 +0800)]
Rename all `link_name_sym` to `link_name` and remove the only remaining `let link_name = link_name_sym.as_str()`

3 years agoRemove `strip_linker_suffix`
hyd-dev [Mon, 14 Jun 2021 17:16:38 +0000 (01:16 +0800)]
Remove `strip_linker_suffix`

3 years agoOnly pass `Symbol` to `emulate_foreign_item_by_name`
hyd-dev [Mon, 14 Jun 2021 16:43:15 +0000 (00:43 +0800)]
Only pass `Symbol` to `emulate_foreign_item_by_name`

3 years agoAdd whitespace
hyd-dev [Mon, 14 Jun 2021 15:38:15 +0000 (23:38 +0800)]
Add whitespace

3 years agoCheck argument count for `CreateThread`
hyd-dev [Mon, 14 Jun 2021 15:01:06 +0000 (23:01 +0800)]
Check argument count for `CreateThread`

3 years agoAdd some comments about `check_shim`
hyd-dev [Mon, 14 Jun 2021 14:53:17 +0000 (22:53 +0800)]
Add some comments about `check_shim`

3 years agoDon't report UB for `#[no_mangle]` on associated functions
hyd-dev [Mon, 14 Jun 2021 12:56:03 +0000 (20:56 +0800)]
Don't report UB for `#[no_mangle]` on associated functions

3 years agoDo not return `DefId` that doesn't have exported symbol in `exported_symbols`
hyd-dev [Sun, 13 Jun 2021 15:30:08 +0000 (23:30 +0800)]
Do not return `DefId` that doesn't have exported symbol in `exported_symbols`

3 years ago`let`-bind `exp_abi` of `"exit" | "ExitProcess"`
hyd-dev [Fri, 11 Jun 2021 07:53:01 +0000 (15:53 +0800)]
`let`-bind `exp_abi` of `"exit" | "ExitProcess"`

3 years agoUse `check_shim()` for `abort`
hyd-dev [Fri, 11 Jun 2021 07:47:12 +0000 (15:47 +0800)]
Use `check_shim()` for `abort`

3 years agoAuto merge of #1831 - hyd-dev:emulate-by-name-result, r=RalfJung
bors [Fri, 11 Jun 2021 07:32:23 +0000 (07:32 +0000)]
Auto merge of #1831 - hyd-dev:emulate-by-name-result, r=RalfJung

Fix the wrong `EmulateByNameResult::NotSupported` in `syscall` shim

Without the change, the newly added test will fail with:
```diff
-thread 'main' panicked at 'unsupported Miri functionality: can't execute syscall with ID 0', $DIR/unsupported_syscall.rs:10:9
+thread 'main' panicked at 'unsupported Miri functionality: can't call foreign function: syscall', $DIR/unsupported_syscall.rs:10:9
 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
cc https://github.com/rust-lang/miri/pull/1818#discussion_r648868937

3 years agoImplement cache for not found symbols
hyd-dev [Tue, 8 Jun 2021 12:36:57 +0000 (20:36 +0800)]
Implement cache for not found symbols

3 years agoDisallow `#[no_mangle]`/`#[export_name = ...]` functions that have the same symbol...
hyd-dev [Sun, 6 Jun 2021 07:25:16 +0000 (15:25 +0800)]
Disallow `#[no_mangle]`/`#[export_name = ...]` functions that have the same symbol name as built-in shims

3 years agoRemove erroneous `exit()` and `ExitProcess()` in `tests/run-pass/function_calls/expor...
hyd-dev [Tue, 8 Jun 2021 12:36:21 +0000 (20:36 +0800)]
Remove erroneous `exit()` and `ExitProcess()` in `tests/run-pass/function_calls/exported_symbol.rs`

3 years agoFix the wrong `EmulateByNameResult::NotSupported` in `syscall` shim
hyd-dev [Fri, 11 Jun 2021 03:13:16 +0000 (11:13 +0800)]
Fix the wrong `EmulateByNameResult::NotSupported` in `syscall` shim

3 years agoAuto merge of #1830 - RalfJung:readme, r=RalfJung
bors [Wed, 9 Jun 2021 19:12:17 +0000 (19:12 +0000)]
Auto merge of #1830 - RalfJung:readme, r=RalfJung

tweak isolation-error message in README

3 years agotweak isolation-error message in README
Ralf Jung [Wed, 9 Jun 2021 19:09:17 +0000 (21:09 +0200)]
tweak isolation-error message in README

3 years agoAuto merge of #1818 - landaire:feature/panic-on-unsupported-syscalls, r=RalfJung
bors [Wed, 9 Jun 2021 18:09:06 +0000 (18:09 +0000)]
Auto merge of #1818 - landaire:feature/panic-on-unsupported-syscalls, r=RalfJung

Add support for panicking in the emulated application when unsupported functionality is encountered

This PR fixes #1807 and allows an optional flag to be specified to panic when an unsupported syscall is encountered. In essence, instead of bubbling up an error in the context of the Miri application Miri will panic within the context of the *emulated* application. This feature is desired to allow CI pipelines to determine if a Miri failure is unsupported functionality or actual UB. Please read [this comment](https://github.com/rust-lang/miri/issues/1807#issuecomment-845425076) for the rationale behind this change.

Note: this change does not cover all cases where unsupported functionality errors may be raised. If you search the repo for `throw_unsup_format!` there are many cases that I think are less likely to occur and may still be problematic for some folks.

TODO:

- [x] README documentation on this new flag
- [x] Add tests

3 years agoAuto merge of #1829 - RalfJung:isolation, r=RalfJung
bors [Wed, 9 Jun 2021 16:38:43 +0000 (16:38 +0000)]
Auto merge of #1829 - RalfJung:isolation, r=RalfJung

isolated operations return EPERM; tweak isolation hint

Follow-up to https://github.com/rust-lang/miri/pull/1797

3 years agoisolated operations return EPERM; tweak isolation hint
Ralf Jung [Wed, 9 Jun 2021 16:21:23 +0000 (18:21 +0200)]
isolated operations return EPERM; tweak isolation hint

3 years agoAuto merge of #1797 - atsmtat:env-isolation, r=RalfJung
bors [Wed, 9 Jun 2021 15:30:50 +0000 (15:30 +0000)]
Auto merge of #1797 - atsmtat:env-isolation, r=RalfJung

fix: avoid stopping machine upon running env operations in isolation

get and set current dir operations used to halt the machine by
throwing an exception in isolation mode. This change updates them to
return a dummy `NotFound` error instead, and keep the machine running.

I started with a custom error using `ErrorKind::Other`, but since it
can't be mapped to a raw OS error, I dropped it. `NotFound` kind of make
sense for get operations, but not much for set operations. But that's
the only error supported for windows currently.

3 years agoFix parameter of io error helper function
Smit Soni [Wed, 9 Jun 2021 13:28:35 +0000 (06:28 -0700)]
Fix parameter of io error helper function

`set_last_error_from_io_error` works with only the error kind, and
discards the payload. Fix its signature to make it explicit.

3 years agoAdd a support to execute isolated op without halting
Smit Soni [Fri, 14 May 2021 06:40:07 +0000 (23:40 -0700)]
Add a support to execute isolated op without halting

In user interface, added a new flag `-Zmiri-isolation-error` which
takes one of the four values -- hide, warn, warn-nobacktrace, and
abort. This option can be used to configure Miri to either abort or
return an error code upon executing isolated op. If not aborted, Miri
prints a warning, whose verbosity can be configured using this flag.

In implementation, added a new enum `IsolatedOp` to capture all the
settings related to ops requiring communication with the
host. Old `communicate` flag in both miri configs and machine
stats is replaced with a new helper function `communicate()` which
checks `isolated_op` internally.

Added a new helper function `reject_in_isolation` which can be called
by shims to reject ops according to the reject_with settings. Use miri
specific diagnostics function `report_msg` to print backtrace in the
warning. Update it to take an enum value instead of a bool, indicating
the level of diagnostics.

Updated shims related to current dir to use the new APIs. Added a new
test for current dir ops in isolation without halting machine.

3 years agoAuto merge of #1827 - l4l:patch-1, r=RalfJung
bors [Wed, 9 Jun 2021 08:00:57 +0000 (08:00 +0000)]
Auto merge of #1827 - l4l:patch-1, r=RalfJung

Specify miri toolchain for CI example

In particular current example doesn't work if you have a rust-toolchain file in the project.

3 years agoSpecify miri toolchain for CI example
Kitsu [Wed, 9 Jun 2021 07:48:43 +0000 (10:48 +0300)]
Specify miri toolchain for CI example

3 years agoAuto merge of #1828 - hyd-dev:rustup, r=RalfJung
bors [Tue, 8 Jun 2021 15:15:05 +0000 (15:15 +0000)]
Auto merge of #1828 - hyd-dev:rustup, r=RalfJung

Update `Box<Any>` to `Box<dyn Any>` in `catch_panic.stderr`

https://github.com/rust-lang-ci/rust/runs/2771244703#step:25:9487
cc rust-lang/rust#86133 rust-lang/rust#86074

3 years agoUpdate `Box<Any>` to `Box<dyn Any>` in `catch_panic.stderr`
hyd-dev [Tue, 8 Jun 2021 14:17:23 +0000 (22:17 +0800)]
Update `Box<Any>` to `Box<dyn Any>` in `catch_panic.stderr`

3 years agoAdd support for panicking in the emulated application when unsupported syscalls are...
Lander Brandt [Wed, 26 May 2021 23:29:01 +0000 (16:29 -0700)]
Add support for panicking in the emulated application when unsupported syscalls are encountered

3 years agoAuto merge of #1826 - hyd-dev:rustup, r=RalfJung
bors [Mon, 7 Jun 2021 09:50:44 +0000 (09:50 +0000)]
Auto merge of #1826 - hyd-dev:rustup, r=RalfJung

Update `cargo-miri` tests

The test output has been changed recently (likely by rust-lang/rust#84863) and caused a test failure: https://github.com/rust-lang/miri/runs/2761591139#step:8:1228

3 years agoUpdate `cargo-miri` tests
hyd-dev [Mon, 7 Jun 2021 08:49:00 +0000 (16:49 +0800)]
Update `cargo-miri` tests

3 years agoAuto merge of #1823 - hyd-dev:extern-crate-std, r=RalfJung
bors [Sun, 6 Jun 2021 08:34:12 +0000 (08:34 +0000)]
Auto merge of #1823 - hyd-dev:extern-crate-std, r=RalfJung

Detect `std` by checking if the crate defines `#[lang = "start"]` rather than string comparison

I also considered to compare the crate name with `sym::std`, but it's easy to name any crate `std` by using `--crate-name std`, so I don't think that is robust enough.

Note that this only checks the crate, it does not check whether the call is in `sys::unix` or `sys::windows`, unlike the previous implementation, but I think it's already robust enough.

Fixes #1821.

3 years agoexpand comment
Ralf Jung [Sun, 6 Jun 2021 08:33:46 +0000 (10:33 +0200)]
expand comment

3 years agoRemove 2 tests
hyd-dev [Sun, 6 Jun 2021 03:22:25 +0000 (11:22 +0800)]
Remove 2 tests

3 years ago`in_std` -> `frame_in_std`
hyd-dev [Sun, 6 Jun 2021 03:21:20 +0000 (11:21 +0800)]
`in_std` -> `frame_in_std`

3 years agoDon't `unwrap()` in `in_std()`
hyd-dev [Thu, 3 Jun 2021 13:26:11 +0000 (21:26 +0800)]
Don't `unwrap()` in `in_std()`

3 years agoDetect `std` by checking if the crate defines `#[lang = "start"]` rather than string...
hyd-dev [Thu, 3 Jun 2021 09:58:24 +0000 (17:58 +0800)]
Detect `std` by checking if the crate defines `#[lang = "start"]` rather than string comparison

3 years agoAuto merge of #1776 - hyd-dev:1170, r=RalfJung
bors [Thu, 3 Jun 2021 15:59:56 +0000 (15:59 +0000)]
Auto merge of #1776 - hyd-dev:1170, r=RalfJung

Implement calls to exported symbols (#1170)

Closes #1170.

3 years agofix typo
Ralf Jung [Thu, 3 Jun 2021 15:47:34 +0000 (17:47 +0200)]
fix typo

3 years agoAuto merge of #1824 - Pointerbender:strings-test, r=RalfJung
bors [Thu, 3 Jun 2021 15:42:41 +0000 (15:42 +0000)]
Auto merge of #1824 - Pointerbender:strings-test, r=RalfJung

added a strings.rs regression test case for potential future UB

This PR adds a regression test for the aliasing rules of a `Unique<T>` pointer.
    At the time of writing this test case, Miri does not treat `Unique<T>`
    pointers as a special case, these are treated like any other raw pointer.
    However, there are existing Github issues which may lead to `Unique<T>`
    becoming a special case through asserting unique ownership over the pointee:
    - https://github.com/rust-lang/unsafe-code-guidelines/issues/258
    - https://github.com/rust-lang/unsafe-code-guidelines/issues/262
    In the new test case, the calls to `String::remove` and `String::insert[_str]` follow
    code paths that would trigger undefined behavior in case `Unique<T>`
    would ever assert semantic ownership over the pointee. Internally,
    these methods call `self.vec.as_ptr()` and `self.vec.as_mut_ptr()` on
    the vector of bytes that are backing the `String`. That `Vec<u8>` holds a
    `Unique<u8>` internally. The second call to `Vec::as_mut_ptr(&mut self)`
    would then invalidate the pointers derived from `Vec::as_ptr(&self)`.
    Note that as long as `Unique<T>` is treated like any other raw pointer,
    this test case should pass. It is merely here as a canary test for
    potential future undefined behavior.

3 years agoadded a strings.rs regression test case for potential future UB
Pointerbender [Thu, 3 Jun 2021 15:24:10 +0000 (17:24 +0200)]
added a strings.rs regression test case for potential future UB

3 years agoAuto merge of #1816 - Pointerbender:slices-tests, r=RalfJung
bors [Thu, 3 Jun 2021 08:52:57 +0000 (08:52 +0000)]
Auto merge of #1816 - Pointerbender:slices-tests, r=RalfJung

regression tests for pointer invalidation in core library slice methods

A fix for a pointer invalidation bug in `<[T]>::copy_within` has [landed](https://github.com/rust-lang/rust/pull/85610) on the Rust master branch. This PR updates the `rust-version` file to the latest master commit hash and adds extra tests to the Miri test suite to ensure that regressions of this type of bug can be detected for various slice methods with the `-Zmiri-track-raw-pointers` flag.

I took the liberty of adding 2 extra  `#![feature]` attributes at the top of `slices.rs`, since there already was one unstable feature. I hope this is okay :smile:

One thing I noticed when running the entire Miri test suite with `MIRIFLAGS="-Zmiri-track-raw-pointers" ./miri test` is that there are currently failing tests on the master branch:

```
failures:
    [ui] run-pass/align.rs
    [ui] run-pass/box.rs
    [ui] run-pass/concurrency/simple.rs
    [ui] run-pass/libc.rs
    [ui] run-pass/ptr_int_casts.rs
    [ui] run-pass/stacked-borrows/int-to-ptr.rs

test result: FAILED. 199 passed; 6 failed; 1 ignored; 0 measured; 0 filtered out; finished in 12.95s
```

These failures were not fixed in this PR and already existed prior to this PR. I haven't investigated these yet, but am interested in helping out if possible!

Thanks!

3 years agoAuto merge of #1822 - hyd-dev:rustup, r=RalfJung
bors [Thu, 3 Jun 2021 08:35:45 +0000 (08:35 +0000)]
Auto merge of #1822 - hyd-dev:rustup, r=RalfJung

`original_crate_name` -> `crate_name`

`original_crate_name` was removed in rust-lang/rust#85904, and according to that PR, it "had the exact same implementation" as `crate_name`.

cc rust-lang/rust#85946

3 years agoRemove some tests
hyd-dev [Thu, 3 Jun 2021 06:16:58 +0000 (14:16 +0800)]
Remove some tests

3 years agoRemove FIXME in `tests/compile-fail/panic/bad_unwind.rs`
hyd-dev [Thu, 3 Jun 2021 05:39:33 +0000 (13:39 +0800)]
Remove FIXME in `tests/compile-fail/panic/bad_unwind.rs`

3 years ago`original_crate_name` -> `crate_name`
hyd-dev [Thu, 3 Jun 2021 02:22:31 +0000 (10:22 +0800)]
`original_crate_name` -> `crate_name`

3 years agoremoved unintentional file change due to whitespace
Pointerbender [Wed, 2 Jun 2021 13:38:12 +0000 (15:38 +0200)]
removed unintentional file change due to whitespace

3 years agouse references so that potential aliasing bugs are triggered during regression test
Pointerbender [Wed, 2 Jun 2021 13:31:50 +0000 (15:31 +0200)]
use references so that potential aliasing bugs are triggered during regression test

3 years agoregression tests for pointer invalidation in core library slice methods
Pointerbender [Wed, 26 May 2021 19:30:43 +0000 (21:30 +0200)]
regression tests for pointer invalidation in core library slice methods

3 years agoAuto merge of #1820 - Aaron1011:rustup-const-err, r=RalfJung
bors [Mon, 31 May 2021 16:04:22 +0000 (16:04 +0000)]
Auto merge of #1820 - Aaron1011:rustup-const-err, r=RalfJung

Rustup for const_err changes

3 years agoRustup for const_err changes
Aaron Hill [Mon, 31 May 2021 15:50:25 +0000 (10:50 -0500)]
Rustup for const_err changes

3 years agoImprove tests
hyd-dev [Mon, 31 May 2021 03:05:04 +0000 (11:05 +0800)]
Improve tests

3 years agoMove the test to `src/main.rs`
hyd-dev [Sun, 30 May 2021 23:59:51 +0000 (07:59 +0800)]
Move the test to `src/main.rs`

3 years agoRemove duplicated "foreign function"
hyd-dev [Sun, 30 May 2021 13:06:40 +0000 (21:06 +0800)]
Remove duplicated "foreign function"

3 years agoUse `unwrap_or_else()`
hyd-dev [Sun, 30 May 2021 13:01:40 +0000 (21:01 +0800)]
Use `unwrap_or_else()`

3 years agoWe don't need to check `SymbolExportLevel`
hyd-dev [Sun, 30 May 2021 12:49:44 +0000 (20:49 +0800)]
We don't need to check `SymbolExportLevel`

3 years agoMove `check_abi()` into `EvalContextExt`
hyd-dev [Sun, 30 May 2021 12:38:52 +0000 (20:38 +0800)]
Move `check_abi()` into `EvalContextExt`

3 years agoMove `-Zmiri-disable-abi-check` in README
hyd-dev [Sun, 30 May 2021 12:30:00 +0000 (20:30 +0800)]
Move `-Zmiri-disable-abi-check` in README

3 years agoImplement calls to exported symbols
hyd-dev [Thu, 15 Apr 2021 21:19:23 +0000 (05:19 +0800)]
Implement calls to exported symbols

3 years agoAdd `-Zmiri-disable-abi-check`
hyd-dev [Sat, 29 May 2021 17:36:06 +0000 (01:36 +0800)]
Add `-Zmiri-disable-abi-check`

3 years agoAuto merge of #1791 - Aaron1011:measureme, r=RalfJung
bors [Sun, 30 May 2021 15:14:23 +0000 (15:14 +0000)]
Auto merge of #1791 - Aaron1011:measureme, r=RalfJung

Add `measureme` integration for profiling the interpreted program

This PR uses the `measureme` crate to profile the call stack of the
program being interpreted by Miri. This is accomplished by starting a
measureme 'event' when we enter a function call, and ending the event
when we exit the call. The `measureme` tooling can be used to produce a
call stack from the generated profile data.

Limitations:
* We currently record every single entry/exit. This might generate very
  large profile outputs for programs with a large number of function
  calls. In follow-up work, we might want to explore sampling (e.g. only
  recording every N function calls).
* This does not integrate very well with Miri's concurrency support.
  Each event we record starts when we push a frame, and ends when we pop
  a frame. As a result, the timing recorded for a particular frame will include all of the work Miri does before that frame completes, including executing another thread.

The `measureme` integration is off by default, and must be enabled via
`-Zmiri-measureme=<output_name>`

3 years agoadd comment to debug impl
Ralf Jung [Sun, 30 May 2021 15:13:49 +0000 (17:13 +0200)]
add comment to debug impl

3 years agoAddress more review comments
Aaron Hill [Sun, 30 May 2021 15:04:57 +0000 (10:04 -0500)]
Address more review comments

3 years agoRun fmt
Aaron Hill [Sat, 29 May 2021 22:16:12 +0000 (17:16 -0500)]
Run fmt

3 years agoAddress review comments
Aaron Hill [Sat, 29 May 2021 22:09:46 +0000 (17:09 -0500)]
Address review comments