Commit Graph

2843 Commits

Author SHA1 Message Date
Ralf Jung
a534bbbf8a portable SIMD: add rem intrinsic; test div and rem intrinsic UB 2021-11-25 17:13:33 -05:00
Ralf Jung
b816cb94e7 implement SIMD sub, mul, div; also test i32 binops 2021-11-20 22:30:49 -05:00
Ralf Jung
0766da6fbe implement simd_add 2021-11-20 22:30:49 -05:00
Ralf Jung
d8bee92aee rename track-raw-pointers flag to tag-raw-pointers 2021-11-13 15:48:27 -05:00
Noah Lev
e6a9b2ce68 Update Miri for detecting uninitialized numbers
This commit adds a `-Zmiri-check-number-initialization` flag to check
that integers and floats are initialized.

This commit also changes some shims to write at type `MaybeUninit<...>`
in order to prevent spurious errors from the uninit check.
2021-11-10 11:36:42 -08:00
bjorn3
9944a2daf3 rustup 2021-10-26 13:42:03 +02:00
bors
adc26a3062 Auto merge of #1885 - DrMeepster:global_allocator, r=RalfJung
add support for `#[global_allocator]`

This PR adds support for custom global allocators. Unfortunately, the code given in #1207 still causes errors when used with box. I believe this is because Box is special-cased in miri and stacked borrows.
2021-09-30 01:37:38 +00:00
DrMeepster
e6a27a68fa implement #[global_allocator] 2021-09-28 20:32:53 -07:00
Ralf Jung
5f825ae895 rustup 2021-09-27 15:59:18 -04:00
Ralf Jung
405de0217d some more Windows argument passing tests 2021-09-24 10:33:32 -04:00
Chris Denton
cfd1316e60
Apply review changes 2021-09-22 20:46:20 +01:00
Chris Denton
f6cedbc744
Correct Windows argument handling
Previously the command line string would have been incorrectly constructed if argv[0] contained a doublequote (`"`) or ended in a trailing backslash (`\`). This is a very rare edge case because, by convention, argv[0] is the path to the application and Windows file names cannot contain doublequotes.

Fixes #1881
2021-09-18 18:41:55 +01:00
hyd-dev
9c62b6454e
rustc_mir -> rustc_const_eval 2021-09-09 17:36:39 +08:00
bors
1cc822e6af Auto merge of #1884 - DrMeepster:start, r=RalfJung
add support for `#[start]`

This PR adds support for the `#[start]` attribute and fixes #1825.

It also renames `eval_main` to `eval_entry` to reflect that it can evaluate any entry function.
2021-09-08 19:43:41 +00:00
hyd-dev
3fedc7b249
rustc_target::abi::LayoutOf -> rustc_middle::ty::layout::LayoutOf 2021-09-06 23:05:48 +08:00
DrMeepster
1ec28f78f3 remove commented out code 2021-09-02 15:45:52 -07:00
DrMeepster
84b058ac47 add support for #[start] 2021-09-02 15:41:10 -07:00
Ralf Jung
35b64447f3 rustup 2021-08-30 10:35:34 -04:00
bors
94ae910131 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.)
2021-08-23 10:55:48 +00:00
Frank Steffahn
c79f6dd5a0 Fix a typo “an”→“a” 2021-08-22 18:07:01 +02:00
niluxv
32c2df87be Add support for the volatile_set_memory intrinsic
Runtime behaviour and soundness requirements are identical to `write_bytes`.
2021-08-22 17:48:31 +02:00
Frank Steffahn
a0d4372ff9 Fix typos “a”→“an” 2021-08-22 16:42:23 +02:00
Ralf Jung
257e9cef66 docify some comments 2021-08-02 17:58:55 +02:00
Ralf Jung
5338a16018 adjust for ERR_ON_PARTIAL_PTR_OVERWRITE 2021-08-02 17:58:55 +02:00
hyd-dev
a789b49e4c
Use Lrc instead of Rc in MiriCompilerCalls::config() 2021-07-30 21:28:34 +08:00
bors
02f78b089c 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. :)
2021-07-27 12:23:56 +00:00
Ralf Jung
df9d481989 tell users how to disable the leak check 2021-07-25 14:21:06 +02:00
Ralf Jung
71efd950d1 also ignore 'thread leaks' with -Zmiri-ignore-leaks 2021-07-25 14:21:06 +02:00
bors
eb9e3073a0 Auto merge of #1856 - RalfJung:no-mir, r=RalfJung
show proper error when using a sysroot without MIR

Fixes https://github.com/rust-lang/miri/issues/1834
2021-07-25 09:50:06 +00:00
Smit Soni
20d0f2ee26 Move shim argument checks before isolation check
This allows catching extremely incorrect arguments before rejecting
due to isolation.
2021-07-24 11:54:55 -07:00
Ralf Jung
46d31f9230 show proper error when using a sysroot without MIR 2021-07-24 14:02:09 +02:00
Smit Soni
da6880427a Update error code for fs ops in isolation
Change the code to either `EACCES` (if the op is performed on the
path), or `EBADF` (if the op is performed the fd)

Updated ops: `stat`, `opendir`, `ftruncate64`, and `readlink`

Add a new test for fs ops in isolation.
2021-07-20 08:23:51 -07:00
Smit Soni
a1cabac727 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".
2021-07-20 08:23:51 -07:00
Ralf Jung
46ed39ec20 adjust for PointerOutOfBounds change 2021-07-20 13:30:49 +02:00
Ralf Jung
a1233a721d adjust Miri to Pointer type overhaul 2021-07-16 10:10:12 +02:00
Ralf Jung
0341b8ac84 fmt: set force_multiline_blocks=true 2021-07-11 14:18:44 +02:00
Ralf Jung
447f23c71b fmt 2021-07-06 10:13:30 +02:00
Ralf Jung
340267525c exported_symbols_cache: ensure we do not overwrite anything 2021-07-06 10:09:53 +02:00
Ralf Jung
9b57313a4d also treat CallerLocation and Machine memory as properly tagged 2021-07-06 10:07:48 +02:00
Ralf Jung
efd582c6d8 explicitly list memory kinds for stacked borrows 2021-07-06 10:04:16 +02:00
Smitty
d19376985d Make work after mir-alloc-oom 2021-07-04 09:59:55 -04:00
hyd-dev
76fe48543c
Update for TyCtxt::crates() change 2021-07-02 16:08:27 +08:00
Ralf Jung
e33bf695db rustup 2021-06-29 20:47:28 +02:00
Ralf Jung
7b2d2cfa46 use exhaustive struct match for manual Debug impl 2021-06-20 19:33:05 +02:00
bors
35af23b6a9 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:🐛:opt_span_bug_fmt
   6: rustc_middle::util:🐛: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:🔙:symbol_export::symbol_name_for_instance_in_crate
  14: rustc_codegen_ssa:🔙:linker::exported_symbols
  15: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  16: rustc_codegen_ssa:🔙:linker::LinkerInfo::new
  17: rustc_codegen_ssa:🔙: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:🔙:symbol_export::symbol_name_for_instance_in_crate` is called for for every `exported_symbols`: fb3ea63d9b/compiler/rustc_codegen_ssa/src/back/linker.rs (L1300-L1304)
- it calls `rustc_middle::middle::exported_symbols::ExportedSymbol::symbol_name_for_local_instance`: fb3ea63d9b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs (L412)
- which calls `rustc_symbol_mangling::symbol_name_provider`: fb3ea63d9b/compiler/rustc_middle/src/middle/exported_symbols.rs (L37-L44)
- which calls `item_name`: fb3ea63d9b/compiler/rustc_symbol_mangling/src/lib.rs (L216), which triggers the ICE

It might also be problematic for d39f0c64b8/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.
2021-06-15 10:07:24 +00:00
bors
486b5dfe74 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.
2021-06-15 09:53:05 +00:00
hyd-dev
aaaa142dc1
Rename all link_name_sym to link_name and remove the only remaining let link_name = link_name_sym.as_str() 2021-06-15 01:24:09 +08:00
hyd-dev
9011524454
Remove strip_linker_suffix 2021-06-15 01:16:38 +08:00
hyd-dev
a67a65359f
Only pass Symbol to emulate_foreign_item_by_name 2021-06-15 00:43:15 +08:00
hyd-dev
34603e586f
Add whitespace 2021-06-14 23:38:15 +08:00
hyd-dev
d1e72d0854
Check argument count for CreateThread 2021-06-14 23:01:06 +08:00
hyd-dev
89c722ac32
Add some comments about check_shim 2021-06-14 22:53:17 +08:00
hyd-dev
da2ed6f768
Don't report UB for #[no_mangle] on associated functions 2021-06-14 20:58:54 +08:00
hyd-dev
99467349f2
Do not return DefId that doesn't have exported symbol in exported_symbols 2021-06-14 20:55:27 +08:00
hyd-dev
49a8f002a0
let-bind exp_abi of "exit" | "ExitProcess" 2021-06-11 15:53:58 +08:00
hyd-dev
e46aab5816
Use check_shim() for abort 2021-06-11 15:47:12 +08:00
hyd-dev
c822ec59aa
Implement cache for not found symbols 2021-06-11 15:24:51 +08:00
hyd-dev
ce7040075a
Disallow #[no_mangle]/#[export_name = ...] functions that have the same symbol name as built-in shims 2021-06-11 15:18:47 +08:00
hyd-dev
4f3718ef85
Fix the wrong EmulateByNameResult::NotSupported in syscall shim 2021-06-11 11:44:57 +08:00
bors
e5c3af6f51 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
2021-06-09 18:09:06 +00:00
Ralf Jung
a38f02c44c isolated operations return EPERM; tweak isolation hint 2021-06-09 18:24:59 +02:00
Smit Soni
ba64f485c8 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.
2021-06-09 06:28:35 -07:00
Smit Soni
892f706ce5 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.
2021-06-09 05:50:52 -07:00
Lander Brandt
ae237098f8 Add support for panicking in the emulated application when unsupported syscalls are encountered 2021-06-07 15:21:53 -07:00
hyd-dev
3871c493b2
in_std -> frame_in_std 2021-06-06 11:21:20 +08:00
hyd-dev
545101040d
Don't unwrap() in in_std() 2021-06-06 11:12:13 +08:00
hyd-dev
879000b133
Detect std by checking if the crate defines #[lang = "start"] rather than string comparison 2021-06-06 11:12:05 +08:00
bors
28717a0e90 Auto merge of #1776 - hyd-dev:1170, r=RalfJung
Implement calls to exported symbols (#1170)

Closes #1170.
2021-06-03 15:59:56 +00:00
Ralf Jung
57e4f1d285
fix typo 2021-06-03 17:47:34 +02:00
hyd-dev
647ee17b40
original_crate_name -> crate_name 2021-06-03 10:22:31 +08:00
Aaron Hill
73700bc01c
Rustup for const_err changes 2021-05-31 10:50:25 -05:00
hyd-dev
e026ad584d
Use unwrap_or_else() 2021-05-31 11:57:15 +08:00
hyd-dev
b054a19f94
We don't need to check SymbolExportLevel 2021-05-31 11:57:14 +08:00
hyd-dev
382295cd47
Move check_abi() into EvalContextExt 2021-05-31 11:15:31 +08:00
hyd-dev
41f33a64f8
Implement calls to exported symbols 2021-05-31 11:15:29 +08:00
hyd-dev
71f4140550
Add -Zmiri-disable-abi-check 2021-05-31 11:14:23 +08:00
Ralf Jung
c89a5d62ee
add comment to debug impl 2021-05-30 17:13:49 +02:00
Aaron Hill
0317e5bfd6
Address more review comments 2021-05-30 10:04:57 -05:00
Aaron Hill
20f1b2a969
Run fmt 2021-05-29 17:16:12 -05:00
Aaron Hill
16f469280e
Address review comments 2021-05-29 17:10:54 -05:00
Aaron Hill
2166eaed90
Use active thread id 2021-05-29 17:01:54 -05:00
Aaron Hill
7e9da8d30e
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, switching between virtual threads will cause
  events from different threads to be interleaved. Additionally, the
  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>`
2021-05-29 17:01:52 -05:00
hyd-dev
9b2d42587f
unwind is no longer Option<BasicBlock> 2021-05-28 22:08:51 +08:00
Ralf Jung
c60efa0c69 allocate backtrace strings mutably 2021-05-23 18:04:13 +02:00
Ralf Jung
9e0e9386a6 better approach to skip ZST reborrows 2021-05-23 18:04:13 +02:00
Ralf Jung
e09c571eec avoid some borrow_mut calls in data_race 2021-05-23 18:04:13 +02:00
Ralf Jung
543777acbd avoid unnecessary RefCell calls in Stacked Borrows 2021-05-23 18:04:13 +02:00
Ralf Jung
d77d95d0a8 rustup 2021-05-23 12:39:27 +02:00
Ralf Jung
c73f8b1097 fmt 2021-05-22 14:55:33 +02:00
Ralf Jung
1bbd6e609c get rid of Rc in data_race 2021-05-22 14:47:14 +02:00
Ralf Jung
ca7283d746 get rid of Rc in Stacked Borrows 2021-05-22 13:24:08 +02:00
Ralf Jung
c151af5cf5 rustup 2021-05-20 13:32:18 +02:00
Ralf Jung
aba96b82b4 fix write_os_str_to_wide_str 2021-05-19 16:34:14 +02:00
Ralf Jung
e4a27150cb fmt 2021-05-19 16:10:28 +02:00
Ralf Jung
801a1744cd update for Memory API changes 2021-05-19 15:27:58 +02:00
Ralf Jung
1bfd9ac56c rustup 2021-05-18 00:11:05 +02:00
Ralf Jung
4f171d7fe3 stop relying on c_str/wide_str helpers in rustc 2021-05-17 14:31:59 +02:00
Ralf Jung
78f74c69e3 fix rustfmt fallout 2021-05-17 10:57:21 +02:00
Ralf Jung
cf3376e541 rustup 2021-05-17 09:34:39 +02:00
Ralf Jung
d6fdfaa047 hand-held formatting for remaining files 2021-05-16 11:51:39 +02:00
Ralf Jung
4e231bab5e format much of Miri 2021-05-16 11:48:28 +02:00
Andy Wang
0d2278c6c6
Prefer remapped filename in backtrace to match rustc behaviour 2021-05-12 15:49:33 +01:00
bors
bdce1ddf88 Auto merge of #1785 - Smittyvb:fast-math-ub, r=RalfJung
Throw UB if f*_fast intrinsic called with non-finite value

Calling these intrinsics with non-finite values is undefined behaviour, since they result in `f*` intrinsics in LLVM with the `fast` flag, and `fast` math on non-finite values results in `poison` values. (technically LLVM only considers it UB upon _using_ the value, but that shouldn't make much of a difference)
2021-05-03 17:32:50 +00:00
Smitty
e0e59f6020 Simplify finiteness checking 2021-05-03 10:08:42 -04:00
Ralf Jung
c3ae8a6f90 adjust for different 'yield' hint on aarch64 2021-05-03 11:25:05 +02:00
Ralf Jung
aac6e2ad3e fix checking os_family 2021-05-03 09:57:13 +02:00
Smitty
e591b83185 UB if f*_fast intrinsic called with nonfinite value 2021-05-02 12:25:00 -04:00
hyd-dev
b30c5fef5b
Rustup for rust-lang/rust#84401 2021-04-30 19:35:59 +08:00
bors
e6ffc689aa Auto merge of #1772 - RalfJung:less-timeout-checking, r=RalfJung
only check timeouts when a thread yields

Currently, we check for expired timeouts after each step of execution. That seems excessive. This changes the scheduler to only check for timeouts when the active thread cannot continue running any more.

`@vakaras` does this sound right? `pthread_cond_timedwait` anyway already yields, of course, since it blocks on getting the signal (or the timeout).
2021-04-11 14:59:27 +00:00
Vytautas Astrauskas
50f68dce21 Reference issue 1763 in the comment. 2021-04-11 13:39:03 +02:00
Ralf Jung
bda328e26a only check timeouts when a thread yields 2021-04-11 13:32:47 +02:00
Vytautas Astrauskas
72ca2a7a85 Attempt to fix #1763 by asking the scheduler to retry choosing an operation. 2021-04-10 20:23:32 +02:00
hyd-dev
3dff1d4fcd
Don't use MIRI_DEFAULT_ARGS to compile host crates 2021-04-09 00:57:59 +08:00
Ralf Jung
31bd77c7d8 bump miri dependencies 2021-04-04 11:48:20 +02:00
Ralf Jung
20e31dbdad fix newer getrandom on Windows 2021-04-04 11:41:04 +02:00
hyd-dev
4eed610723
Remove #![feature(or_patterns)] 2021-03-23 16:58:00 +08:00
bstrie
4f899ce9ac Replace deprecated collections::Bound 2021-03-17 18:34:44 -04:00
hyd-dev
7ec919daa4
Remove the macro and expand it manually 2021-03-17 22:27:57 +08:00
hyd-dev
3ee865461f
Revert "Don't duplicate check_abi()"
This reverts commit 1c7d7471da.
2021-03-17 21:51:07 +08:00
hyd-dev
bbc348539b
Unsupported foreign non-"C"/"system"-ABI function calls are not UB 2021-03-17 21:20:04 +08:00
hyd-dev
1c7d7471da
Don't duplicate check_abi() 2021-03-17 00:40:53 +08:00
bors
0788188c7b Auto merge of #1743 - RalfJung:callee-checks, r=RalfJung
Check callee ABI when Miri calls closures

Fixes https://github.com/rust-lang/miri/issues/1741
2021-03-14 18:05:18 +00:00
Ralf Jung
15465a5881 don't ICE when we unwind despite panic=abort 2021-03-14 17:10:45 +01:00
Ralf Jung
d1dec9cd23 don't ICE when callee has the wrong number of arguments 2021-03-14 15:38:22 +01:00
Ralf Jung
893843fd45 when Miri calls a function ptr, make sure it has the right ABI 2021-03-14 15:30:37 +01:00
Ralf Jung
98f28ac9c8 rustup 2021-03-11 09:07:05 +01:00
Mara Bos
5bd5ea21ea Remove unwrap_none as it won't be stabilized.
This upgrades to the latest rustc to be able to use try_insert()
instead.
2021-03-08 16:59:20 +01:00
Smittyvb
8d43d727f4
Check arg count
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-03-05 07:16:50 -05:00
Smitty
26e97ec54f Support breakpoint intrinsic 2021-03-04 07:48:28 -05:00
Ralf Jung
9f3dbad5d0 rename atomic_op_min_max -> atomic_op 2021-03-02 19:54:45 +01:00
bors
2670839e1a Auto merge of #1721 - henryboisdequin:add-atomic-min-and-max, r=oli-obk
Add atomic min and max

Closes #1718
Previous attempt: #1653

TODO:

- [x] Merge `atomic_op` and `atomic_min_max` functions
- [x] Fix CI

**Note:** this PR also removes arbitrary trailing whitespace and generally formats the affected files
2021-03-02 14:52:32 +00:00
Henry Boisdequin
f8440d6c99 Add in atomic_{min,max}_x intrinsics
Co-authored-by: Greg Bowyer <gbowyer@fastmail.co.uk>
2021-03-02 20:17:05 +05:30
Henry Boisdequin
7d1531f3c1 fmt data_race.rs and intrinsics.rs 2021-03-02 18:06:12 +05:30
Ralf Jung
48f7c8e2e6 fix reborrowing of tagged ZST references 2021-02-27 20:10:50 +01:00
Tomasz Miąsko
0eb341417c rustup to e7c23ab933 2021-02-20 00:00:00 +00:00
Ralf Jung
2672baafe1 rustup 2021-02-18 10:34:32 +01:00
Mara Bos
c5bb29141e Remove unnecessary format!() in panic!(). 2021-02-02 21:40:30 +01:00
Ralf Jung
052cd3bff7 rustup; remove some no-longer-needed Windows shims 2021-01-31 14:23:49 +01:00
bors
b38dc837f2 Auto merge of #1670 - unseddd:abi, r=RalfJung
Add ABI check for shims

Resolves #1631
2021-01-29 19:36:30 +00:00
Yuki Okushi
53612ece7c Rustup for rust-lang/rust#79951 2021-01-28 22:31:22 +09:00
Nym Seddon
de4eea9d49
Add ABI check for shims 2021-01-27 22:32:25 +00:00
Thom Chiovoloni
d310620c11 Allow configuring the failure rate with -Zmiri-compare-exchange-weak-failure-rate 2021-01-26 00:13:54 -08:00
Thom Chiovoloni
d4b592ed17 Fail 80% of the time on weak cmpxchg, not 50% 2021-01-26 00:13:54 -08:00
Thom Chiovoloni
c678bd722e Add random failures to compare_exchange_weak 2021-01-26 00:13:54 -08:00
Ralf Jung
13dd513254 adjust Windows shims for stdlib changes (Windows XP removal) 2021-01-25 10:43:48 +01:00
Ralf Jung
7d8f8c405f macos: support aarch64 link names 2021-01-23 18:14:57 +01:00
Ralf Jung
848be1bf82 implement aarch64 hint 'intrinsic' 2021-01-23 18:11:01 +01:00
Corey Farwell
2aedbf0993 Add shim for libc::sysconf(libc::_SC_NPROCESSORS_CONF) 2021-01-22 09:16:27 -05:00
bors
903bfd82bf Auto merge of #1681 - RalfJung:rustup, r=RalfJung
rustup; remove some intrinsics that are gone or moved to rustc
2021-01-18 12:02:12 +00:00
Ralf Jung
3d01ba11c0 rustup; remove some intrinsics that are gone or moved to rustc 2021-01-18 12:55:30 +01:00
hyd-dev
9949d9e417
Remove #![feature(const_generics)] and #![allow(incomplete_features)] 2021-01-17 23:28:20 +08:00
Ralf Jung
4a035103dc rustup; make tests pass again 2021-01-15 16:41:14 +01:00
Ralf Jung
8e15f3221e rustup 2021-01-11 12:35:13 +01:00
Ralf Jung
65f5c27d61 remove intrinsic that is now implemented in the rustc side 2020-12-22 12:47:59 +01:00
JCTyblaidd
c13aabcb45 Tidy new_allocation 2020-12-13 11:14:41 +00:00
JCTyblaidd
e73579632b Rework to work with machine hook. 2020-12-13 11:04:58 +00:00
JCTyblaidd
81c4eb7d74 Update src/data_race.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-12-13 11:04:58 +00:00
JCTyBlaidd
aaf8ca4c77 Fix review changes 2020-12-13 11:04:58 +00:00
JCTyBlaidd
296ba8b1c8 Fix bug with reporting wrong thread for races with reads & add thread ids to data-race tests 2020-12-13 11:04:58 +00:00
JCTyblaidd
c4ccd0b6a1 Fix nits
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-12-13 11:04:58 +00:00
JCTyBlaidd
1ded6d328a Remove old FIXME 2020-12-13 11:04:58 +00:00
JCTyBlaidd
c45b1b16be More tests, fix issue 1643 and detect races with allocation. 2020-12-13 11:04:58 +00:00
Ralf Jung
7bbd6bca77 rustup 2020-12-10 19:53:45 +01:00
JCTyblaidd
6db821537f
Fix caps
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-12-06 17:59:49 +00:00
JCTyBlaidd
4cf614ef33 Update release sequence handling to C++20 semantics. 2020-12-06 16:58:32 +00:00
Ralf Jung
6145709bfc remove miri-rustc-tests 2020-11-29 21:00:50 +01:00
bors
d473242ecd Auto merge of #1617 - JCTyblaidd:data_race_detector, r=RalfJung
Add simple data-race detector

Partially fixes data-race detection, see #1372, based on Dynamic Race Detection for C++11

- This does not explore weak memory behaviour, only exploring one sequentially consistent ordering.
- Data-race detection is only enabled after the first thread is created, so should have minimal overhead for non-concurrent execution.
- ~~Does not attempt to re-use thread id's so creating and joining threads lots of time in an execution will result in the vector clocks growing in size and slowing down program execution~~ It does now
2020-11-29 18:44:28 +00:00
Ralf Jung
cbb695f782
fix some typos 2020-11-29 19:43:44 +01:00
JCTyBlaidd
6c5722933e Fix typos - looked into the papers handling of timestamps, after looking into it again, it seems the paper only increments the timestamp after release operations, so changed to approximation of that implementation. 2020-11-28 17:17:07 +00:00
JCTyBlaidd
55fc552d99 Apply review changes, incrementing the clocks twice is an unnecessary hold-over from earlier versions so fixed. 2020-11-27 19:26:06 +00:00
JCTyBlaidd
3268f56a97 Fix review changes 2020-11-22 17:28:12 +00:00
Ralf Jung
697f6e36bd rustup 2020-11-20 14:07:52 +01:00
Ralf Jung
517728bf97 avoid fallback logic (and we do not need the flag value currently anyway) 2020-11-19 09:36:33 +01:00
Mara Bos
cdb7adb4b3 Make weak syscalls in std work.
std now looks up `getrandom` and `statx` with `dlsym` before attempting
to use `syscall(SYS_.., ..)`.

It also now passes all arguments as a machine-sized word, instead of
their original types.
2020-11-19 09:34:46 +01:00
JCTyBlaidd
0b0264fc82 Run rustfmt on vector_clock.rs and data_race.rs 2020-11-15 20:19:34 +00:00
JCTyBlaidd
a3b7839bbd Add comment regarding seq-cst ordering & add test for disabling the data-race detector. 2020-11-15 20:12:58 +00:00
JCTyBlaidd
69fb6413dd Tidy up comments and function layout, should fix most of the review notes. 2020-11-15 18:30:26 +00:00
Ralf Jung
43673d9a87 rustup 2020-11-11 10:29:10 +01:00
JCTyBlaidd
2a40d9b7a0 More aggressive vector index re-use, and added some tests. 2020-11-06 17:29:54 +00:00
Ralf Jung
f31f00d5af rustup 2020-11-05 17:09:44 +01:00
JCTyBlaidd
c70bbea257 Move to use of thread termination hook for vector re-use,
convert validate atomic op to use shared reference and get_raw
 instead of get_raw_mut so it can be used for validate_atomic_load as well
2020-11-05 14:18:28 +00:00
JCTyBlaidd
9cb6b8da3f Split out vector_clock to separate file, general tidy up of some of the
code & add support for vector index re-use for multiple threads
 after termination.
2020-11-05 03:54:39 +00:00
JCTyBlaidd
95c99b2044 Detect races between atomic and non-atomic accesses of a variable,
previously only data races between two non-atomic accesses were
 detected.
2020-11-04 21:35:48 +00:00
JCTyBlaidd
fe2e857cc3 Add newlines at end of file + use replace.
add dangling thread variant of one of the benchmarks
2020-11-02 13:08:09 +00:00
JCTyBlaidd
cae4302003 Fix & rebase 2020-11-02 03:06:30 +00:00
JCTyBlaidd
ed32b260f9 Add tests, and fix bug in atomic RMW relaxed stores 2020-11-02 02:57:06 +00:00
JCTyBlaidd
89814f1b3f Initial data-race detector,
passes all current tests but additional tests are required
2020-11-02 02:57:05 +00:00
Ralf Jung
194451345d add an option to track raw pointer tags in Stacked Borrows 2020-10-28 12:23:35 +01:00
Ralf Jung
39f7b35327 Stacked Borrows: print affected memory location on errors 2020-10-28 12:04:39 +01:00
Ralf Jung
086e9c49a9 pointer tag tracking: also show when tag is being created 2020-10-27 14:22:29 +01:00
Camelid
05e9ae042c Make miri_default_args() a constant 2020-10-24 12:46:38 -07:00
est31
1ae157bc9e Replace target.target with target
Rustc removed the target wrapper and exposed the target directly.

Result of running:

find . -type f -exec sed -i -e 's/target\.target\([)\.,;]\)/target\1/g' {} \;

Plus one manual edit of the rust-version file
2020-10-15 21:18:23 +02:00
bors
73d5c42076 Auto merge of #1580 - Aaron1011:feature/backtrace-fn-ptr, r=RalfJung
Add an `fn_ptr` field to `MiriFrame`

The `backtrace-rs` crate can use this to implement
`Frame::symbol_address`, which is used to skip frames
above the call to `Backtrace::capture` on the stack.

The function pointer will not be useable for comparison purposes if the
function is generic, as CTFE creates a new function pointer for each
cast of a (monomorphized) generic function. However, this already
affects code running under Miri, and isn't a problem for `backtrace-rs`
(which only casts a non-generic function).

I've added logic to allow `MiriFrame` to have either 4 or 5 fields - if
a 5th field is present, we write the function pointer to it.
2020-10-11 22:34:57 +00:00
Aaron Hill
c889eba4b2
Add comment about deprecation 2020-10-11 17:57:49 -04:00
Aaron Hill
0893ea1973
Rustup
This gets Miri building again after the `run_compiler` changes
2020-10-11 17:31:52 -04:00
Aaron Hill
6a6767fa2a
Apply suggestions from code review
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-10-11 13:40:00 -04:00
Aaron Hill
be51e6bd07
Add an fn_ptr field to MiriFrame
The `backtrace-rs` crate can use this to implement
`Frame::symbol_address`, which is used to skip frames
above the call to `Backtrace::capture` on the stack.

The function pointer will not be useable for comparison purposes if the
function is generic, as CTFE creates a new function pointer for each
cast of a (monomorphized) generic function. However, this already
affects code running under Miri, and isn't a problem for `backtrace-rs`
(which only casts a non-generic function).

I've added logic to allow `MiriFrame` to have either 4 or 5 fields - if
a 5th field is present, we write the function pointer to it.
2020-10-10 13:07:57 -04:00
Aaron Hill
8e8828259a
Use macro callsite spans in backtrace
This mirrors what we do in the debuginfo used for runtime backtraces.
2020-10-05 17:29:55 -04:00
Ralf Jung
3aaab3dd98
more punctuation 2020-10-04 23:07:19 +02:00
Aaron Hill
c1c82c2503
Properly capitalize PathConversion 2020-10-04 16:28:09 -04:00
Aaron Hill
9e6320f101
Move convert_path_separator to trait and use it in readlink 2020-10-04 12:34:13 -04:00
Aaron Hill
462f58298a
Make helper functions freestanding 2020-10-04 12:06:51 -04:00
Aaron Hill
8b89c7e1da
Use panicking coversions instead of as 2020-10-04 12:06:51 -04:00
Aaron Hill
186d59a3ec
Move some helper functions around 2020-10-04 12:06:51 -04:00
Aaron Hill
78bc89b4fc
Implement readlink
Due to the truncating behavior of `readlink`, I was not able to
directly use any of the existing C-cstring helper functions.
2020-10-04 12:06:51 -04:00
Ralf Jung
2b2a3a0cc1 check that all syscall arguments are scalars 2020-10-03 16:01:53 +02:00
Ralf Jung
b350c80a31 add backtics back in isolation error message 2020-10-03 15:25:30 +02:00
Mara Bos
68776d2921
Add FIXME about type of addr in futex implementation.
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-10-03 14:32:30 +02:00
Mara Bos
c268ee2bcb
Add note about use of force_ptr in futex implementation.
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-10-03 14:21:37 +02:00
Mara Bos
dfcb46a4e0 Update syscall FIXME to include note about 'wrong' types. 2020-10-03 13:39:16 +02:00
Mara Bos
9d764c5750 Add FIXME note about variadic syscall(). 2020-10-03 12:18:38 +02:00
Mara Bos
6df54c47a7 Use read_scalar_at_offset in futex_wait instead of memory.get_raw. 2020-10-03 12:11:24 +02:00
Mara Bos
66282754ff Remove backtics from isolation error.
Otherwise `FUTEX_WAIT with timeout` will look weird.
2020-10-03 11:38:16 +02:00
Mara Bos
924fd56944 Only allow FUTEX_WAIT with timeout when isoloation is disabled. 2020-10-03 11:35:13 +02:00
Mara Bos
c9627b25fb Use correct return type for syscall(SYS_futex). 2020-10-03 00:40:53 +02:00
Mara Bos
e64ead2f46 Implement timeouts for FUTEX_WAIT. 2020-10-02 23:34:14 +02:00
Mara Bos
d5b3f54b46 Use force_ptr in futex implementation. 2020-10-02 21:59:11 +02:00
Mara Bos
422b5053a9
Add note about arguments in futex implementation.
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-10-02 20:56:01 +02:00
Mara Bos
dabd980567 Update note about number of arguments to SYS_futex. 2020-10-02 20:53:31 +02:00
Mara Bos
ee3eb4b223 Add comments that document SYS_futex better. 2020-10-02 10:47:53 +02:00
Mara Bos
712e8006b3 Improve handling of the addr argument in SYS_futex. 2020-10-02 10:47:36 +02:00
Mara Bos
c2fa27c3b8 Check maximum amount of arguments to SYS_futex. 2020-10-02 10:46:57 +02:00
Mara Bos
1c582e7c96 Return correct value from futex_wait. 2020-10-02 01:49:20 +02:00
Mara Bos
69cea1dc92 Only check futex pointer in futex_wait and not in futex_wake.
futex_wake doesn't access the futex itself, so should accept pointers to
memory that's no longer there.
2020-10-01 22:57:27 +02:00
Mara Bos
6c2f36eb6b Erase tag from futex pointers. 2020-10-01 21:06:16 +02:00
Mara Bos
281a538226 Move futex syscall to its own file. 2020-10-01 21:03:36 +02:00
Mara Bos
1ffc5bb563 Implement futex_wait and futex_wake.
This does not support futex_wait with a timeout yet.
2020-10-01 20:55:54 +02:00
Ralf Jung
eaf56c57e5 rustup; adjust for rustc_driver changes 2020-09-29 11:05:10 +02:00
Aaron Hill
5571bcfc4f
Require #[repr(C)] on MiriFrame 2020-09-28 13:44:46 -04:00
Aaron Hill
e1bce19ca9
Make some error messages lowercase 2020-09-28 13:44:45 -04:00
Aaron Hill
f756e3a93f
Explain encoding scheme 2020-09-28 13:44:45 -04:00
Aaron Hill
b89f6561e5
Move things around 2020-09-28 13:44:45 -04:00
Aaron Hill
ef43c5a614
Use a 'flags' parameter instead of 'version' 2020-09-28 13:44:45 -04:00
Aaron Hill
22f1eb01ee
Add API for capturing backtrace
This PR adds two new Miri-defined extern functions:
`miri_get_backtrace` and `miri_resolve_frame`, which are documented in
the README. Together, they allow obtaining a backtrace for the currently
executing program.

I've added a test showing how these APIs are used. I've also prepared a
companion PR `backtrace-rs`, which will allow
`backtrace::Backtrace::new()` to work automatically under Miri.

Once these two PRs are merged, we will be able to print backtraces from
the normal Rust panic hook (since libstd is now using backtrace-rs).

A few notes:
* Resolving the backtrace frames is *very* slow - you can actually see
  each line being printed out one at a time. Some local testing showed
  that this is not (primrary) caused by resolving a `Span` - it seems
  to be just Miri being slow.
* For the first time, we now interact directly with a user-defined
  struct (instead of just executing the user-provided MIR that
  manipulates the struct). To allow for future changes, I've added
  a 'version' parameter (currently required to be 0). This should allow
  us to change the `MiriFrame` struct should the need ever arise.
* I used the approach suggested by @oli-obk - a returned backtrace
  pointer consists of a base function allocation, with the 'offset'
  used to encode the `Span.lo`. This allows losslessly reconstructing
  the location information in `miri_resolve_frame`.
* There are a few quirks on the `backtrace-rs` side:
  * `backtrace-rs` calls `getcwd()` by default to try to simplify
    the filename. This results in an isolation error by default,
    which could be annoying when printing a backtrace from libstd.
  * `backtrace-rs` tries to remove 'internal' frames (everything between
     the call to `Backtrace::new()` and the internal API call made by
     backtrace-rs) by comparing the returned frame pointer value to
     a Rust function pointer. This doesn't work due to the way we
     construct the frame pointers passed to the caller. We could
     attempt to support this kind of comparison, or just add a
    `#[cfg(miri)]` and ignore the frames ourselves.
2020-09-28 13:44:45 -04:00
Lzu Tao
56ea94dfa3 Remove assume intrinsic from EvalContextExt
It has been moved to rustc_mir.
2020-09-27 10:00:06 +07:00
Ralf Jung
b0baa151b2 rustup 2020-09-20 13:13:57 +02:00
Ralf Jung
97a71c0c77
fmt
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2020-09-18 13:34:25 +02:00
Ralf Jung
32cdb7131b support panic=abort 2020-09-18 13:10:18 +02:00
bors
ce29fbf406 Auto merge of #1540 - RalfJung:cargo-miri-redone, r=oli-obk
Redo cargo-miri logic

This rewrite the cargo-miri logic for running the requested crate(s) following what we outlined in https://github.com/rust-lang/miri/issues/739: `cargo miri run/test $FLAGS` (almost) literally invokes `cargo run/test $FLAGS` but with some environment variables set so that we can control what happens:
* `RUSTC_WRAPPER` is set so that we get invoked instead of `rustc`. We use that power to mess with the flags being used for the build (things to be interpreted by Miri use a different sysroot), and when we are detecting a binary crate meant to be run by Miri, we grab the info we care about and put it into a JSON file for later use.
* `CARGO_TARGET_$TARGET_RUNNER` is set so what we get invoked when cargo wants to run a binary. At that point we take that JSON info from before and use it to invoke Miri.

Overall this works great! We get all sorts of cargo magic for free, and do not even need `cargo-metadata` any more. There's one annoying point though, which I have not managed to entirely work around yet: this means we are doing a full build, not just a check-build. Given that our sysroot is MIR-only, I was surprised that this even worked, but still -- this means we are doing more work than we should. So I also added some patching of arguments to make sure `--emit` does not contain `link`, and then more patching was required of the `--extern` flags for the binary because those referenced the `.rlib` files but now only `.rmeta` exists, and that is still not fully working because cargo seems to expect those `.rmeta` files and now triggers a rebuild each time as those files are still missing. My current plan is to make our wrapper create some empty dummy files with the right names, but the amount of hacks we are stacking on top of each other here is getting worrysome.^^ `@ehuss` your input would be welcome on this issue.

Due to re-using cargo more literally, this also changes flag parsing to match `cargo`. So `-Zmiri` flags now have to be passed via an environment variable (Cc https://github.com/rust-lang/miri/issues/1416).

This PR is not ready yet, but the parts that are there I think can be reviewed already. TODO:
* [x] [Fix Windows](https://github.com/rust-lang/miri/pull/1540#issuecomment-688733741).
* [x] Figure out how we can do check-only builds without the rebuild problem above. ~~I am also worried about cases where `build.rs` script might detect check-only builds and then do less work; I think some crates in rustc are doing that and if this is a thing in the wider ecosystem we need to find a way to support this as well.~~ (postponed that until we have a concrete example)
* [x] Currently cargo runs doctests as well, and they are not run in Miri. We should at least figure out a way to not run them at all (resolving https://github.com/rust-lang/miri/issues/584 is left for a future PR).
* [x] For some time, detect the old way of passing `-Zmiri` flags and warn that this will need updating. For some simple situations we can probably make it still support the old way, but I plan to remove those hacks after a bit. This is just to give people and me time to go around and send PRs to all projects that use Miri on CI, and update their use of the flags.
* [x] Add a test for stdin handling (https://github.com/rust-lang/miri/issues/1505). This should work now but we should be sure.
* [x] Add a test for cargo env vars (https://github.com/rust-lang/miri/issues/1515).
* [x] Check if https://github.com/rust-lang/miri/issues/1516 is resolved.
* [x] Check if https://github.com/rust-lang/miri/issues/1001 and https://github.com/rust-lang/miri/issues/1514 are resolved.
* [x] Check if https://github.com/rust-lang/miri/issues/1312 is resolved (not sure if it is wort adding a test).
* [x] Check if https://github.com/rust-lang/miri/issues/1512 is resolved (not sure if it is wort adding a test).

Fixes https://github.com/rust-lang/miri/issues/700.
Fixes https://github.com/rust-lang/miri/issues/739.
Fixes https://github.com/rust-lang/miri/issues/1001.
Fixes https://github.com/rust-lang/miri/issues/1312 (without a test, as we run without cargo's stdin/stdout wrapping now, as the test for stdin confirms).
Fixes https://github.com/rust-lang/miri/issues/1416.
Fixes https://github.com/rust-lang/miri/issues/1505.
Fixes https://github.com/rust-lang/miri/issues/1512 (without a test, as cargo now does all that handling anyway, which various other tests confirm).
Fixes https://github.com/rust-lang/miri/issues/1514.
Fixes https://github.com/rust-lang/miri/issues/1516.

Cc `@alecmocatta` who reported many of the bugs above; would be great if you could help with the tests e.g. by providing some small examples I could try.
r? `@oli-obk`
2020-09-17 16:52:23 +00:00
Ralf Jung
3163242ff1 rustup; no need to special-case the guaranteed_eq/ne intrinsics any more 2020-09-17 17:42:52 +02:00
Ralf Jung
b244a2ddaa make sure subcrate tests have the right cwd 2020-09-17 17:33:47 +02:00
Samrat Man Singh
563fb8e43d Implement dup and close for stdin/stdout/stderr
Support F_DUPFD on stdin/stdout/stderr

Enable `close`-ing stdin/stdout/stderr

For `dup`, check if FD is `File` first

If not, clone the appropriate standard IO stream

Merge POSIX `close` and `dup` tests into same module

Also, add assertion that `write` on a closed FD returns an error.

Add `dup` as FileDescriptor trait fn

Also:
- Fix `close` so it drops `self` instead of reference to it
- Remove FD clamping in insert_fd_with_min_fd, since FDs 0-2 can be
closed

Fix fs_libc tests

Make error message when closing stdin/out/err more specific

Return io::Result from `FileDescriptor::dup`

Change error message when closing stdin/out/err

Refactor `FileDescriptor::dup` impl for `FileHandle`

Remove empty line
2020-09-09 23:26:33 +05:30
David Cook
b06f0d16a9 Use try block instead of closure 2020-09-07 15:09:34 -05:00
David Cook
597360f499 Simplify read_timespec error handling 2020-09-07 11:31:28 -05:00
David Cook
33e928c9ca Review comments 2020-09-07 10:54:39 -05:00
David Cook
417ac2939a Implement libc::nanosleep shim 2020-09-06 18:07:17 -05:00
David Cook
6d323e1032 Refactor timespec parsing, improve error handling 2020-09-06 18:07:14 -05:00
LeSeulArtichaut
4f2f87b2df Change ty.kind -> ty.kind() 2020-09-04 22:03:45 +02:00
David Cook
a6746ad893 Add comment 2020-09-02 20:58:41 -05:00
David Cook
7a2c6812b9 Per-thread errno storage 2020-09-02 20:57:20 -05:00