Commit Graph

2641 Commits

Author SHA1 Message Date
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