Commit Graph

4092 Commits

Author SHA1 Message Date
bors
9fe39ba763 Auto merge of #1250 - RalfJung:error-context, r=oli-obk
give some context in error messages

### Some examples for how different errors look now

Unsupported operation:
```
error: unsupported operation: Miri does not support threading
  --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/thread.rs:68:19
   |
68 |         let ret = libc::pthread_create(&mut native, &attr, thread_start, &*p as *const _ as *mut _);
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri does not support threading
   |
   = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
```
Unsupported operation that works without isolation:
```
error: unsupported operation: `clock_gettime` not available when isolation is enabled
   --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/sys/unix/time.rs:349:22
    |
349 |         cvt(unsafe { libc::clock_gettime(clock, &mut t.t) }).unwrap();
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `clock_gettime` not available when isolation is enabled
    |
    = help: pass the flag `-Zmiri-disable-isolation` to disable isolation
```
Program abort:
```
error: program stopped: the evaluated program aborted execution
   --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/src/libstd/panicking.rs:530:18
    |
530 |         unsafe { intrinsics::abort() }
    |                  ^^^^^^^^^^^^^^^^^^^ the evaluated program aborted execution
    |
```
UB:
```
error: Undefined Behavior: type validation failed: encountered 2, but expected a boolean
 --> tests/compile-fail/validity/invalid_bool.rs:2:23
  |
2 |     let _b = unsafe { std::mem::transmute::<u8, bool>(2) }; //~ ERROR encountered 2, but expected a boolean
  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 2, but expected a boolean
  |
  = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
```
Experimental UB:
```
error: Undefined Behavior: not granting access to tag <1562> because incompatible item is protected: [Unique for <1567> (call 1189)]
  --> tests/compile-fail/stacked_borrows/aliasing_mut1.rs:3:1
   |
3  | pub fn safe(_x: &mut i32, _y: &mut i32) {} //~ ERROR protect
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not granting access to tag <1562> because incompatible item is protected: [Unique for <1567> (call 1189)]
   |
   = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
```

Fixes https://github.com/rust-lang/miri/issues/417
2020-03-22 22:34:23 +00:00
Ralf Jung
6e302b830a link to some websites for UB explanations 2020-03-22 23:32:19 +01:00
Ralf Jung
dd4fef0cd9 fix outdated sysroot help message 2020-03-22 20:09:14 +01:00
Ralf Jung
6dcca62b63 move -Zmiri-disable-isolation hint to help 2020-03-22 19:48:59 +01:00
Ralf Jung
a1b823886c give some context in error messages 2020-03-22 18:59:06 +01:00
bors
d7d2266414 Auto merge of #1249 - RalfJung:rustup, r=RalfJung
Cross-test targets

We should now be able to run Linux targets on macOS hosts and vice versa.
Cc https://github.com/rust-lang/miri/issues/1198
2020-03-22 08:05:35 +00:00
Ralf Jung
b843de6dd2 run-test.py: also print what we are testing for 2020-03-22 09:04:10 +01:00
Ralf Jung
e1b654f09a mention cross-running in docs 2020-03-22 08:55:53 +01:00
Ralf Jung
d85f09c4e4 platform -> target 2020-03-22 08:55:39 +01:00
Ralf Jung
dece5bc4ee fix bad use of FOREIGN_TARGET 2020-03-21 23:28:10 +01:00
Ralf Jung
82fe771676 also cross-test Windows from Linux, macOS 2020-03-21 23:26:44 +01:00
Ralf Jung
78fe5288d0 do more cross-testing 2020-03-21 23:17:18 +01:00
Ralf Jung
8306073835 bump Rust 2020-03-21 23:17:07 +01:00
bors
7f476266fd Auto merge of #1248 - RalfJung:overflow, r=RalfJung
detect UB: overflow in copy/write_bytes

Fixes https://github.com/rust-lang/miri/issues/1234
2020-03-21 17:09:57 +00:00
Ralf Jung
238ed49a07 detect UB: overflow in copy/write_bytes 2020-03-21 17:54:33 +01:00
Ralf Jung
8acfafe186 test for zero-sized write_bytes to NULL 2020-03-21 17:54:18 +01:00
Ralf Jung
eb3be2f97d ./miri check 2020-03-21 17:43:28 +01:00
bors
70ab91d087 Auto merge of #1247 - RalfJung:rustup, r=RalfJung
call error location was fixed by rustup
2020-03-21 12:13:39 +00:00
Ralf Jung
6355228d4e remove no longer needed (and sometimes broken) 'extern crate' 2020-03-21 13:13:08 +01:00
Ralf Jung
e890d4d5e1 call error location was fixed by rustup 2020-03-21 12:52:23 +01:00
bors
b2605d809d Auto merge of #1241 - RalfJung:dont-panic, r=RalfJung
whitelist platforms where panicking should work

@CAD97 [proposed](https://github.com/rust-lang/miri/issues/1059#issuecomment-601217992) trying to get a better error for failed panics on Windows.

Could you test if this works for you?
2020-03-21 09:55:23 +00:00
Ralf Jung
5c09047411 fix tests 2020-03-21 10:54:56 +01:00
Ralf Jung
bde3111c61 test windows panic message 2020-03-21 10:17:57 +01:00
bors
ee71b2e140 Auto merge of #1243 - RalfJung:instant, r=RalfJung
implement Instant::now

For now, this is Linux-only.

Unlike `SystemTime`, we cannot convert `Instant` to something absolute via an epoch. But that's okay, that clock is relative anyway, so we just make up our own time anchor when interpretation starts.

Fixes https://github.com/rust-lang/miri/issues/1242
2020-03-20 15:18:06 +00:00
Ralf Jung
f430e54456 implement mach_absolute_time for macOS 2020-03-20 16:15:37 +01:00
bors
0cfb20d9ea Auto merge of #1244 - RalfJung:readme, r=RalfJung
README updates
2020-03-20 14:57:58 +00:00
Ralf Jung
3a5f601710 add some more miri-detected issues 2020-03-20 15:57:11 +01:00
Ralf Jung
04c937e281 assert platform in time shims 2020-03-20 15:11:54 +01:00
bors
22de46402e Auto merge of #1245 - RalfJung:rustup, r=RalfJung
rustup

Just to make sure the CI failure we just saw was truly spurious (travis macOS being unreliable, as usual)
2020-03-20 09:35:08 +00:00
Ralf Jung
e3a72be107 rustup 2020-03-20 10:34:24 +01:00
Ralf Jung
c3f6f47f7a we also do not check floats for being init'd 2020-03-19 23:19:17 +01:00
Ralf Jung
4608b94bd8 implement CLOCK_MONOTONIC on Linux 2020-03-19 23:01:24 +01:00
Ralf Jung
0f1713f67c whitelist platforms where panicking should work 2020-03-19 15:54:09 +01:00
bors
0ff05c4cfe Auto merge of #1219 - RalfJung:error-cleanup, r=RalfJung
rustup for error reform

This is the Miri side of https://github.com/rust-lang/rust/pull/69839.
2020-03-19 07:42:53 +00:00
Ralf Jung
49051e05ea rustup, and some final message adjustments 2020-03-19 08:41:01 +01:00
Ralf Jung
e1e158e103 adjust error messages for lower-case start 2020-03-19 08:26:08 +01:00
Ralf Jung
681819c8ad getting a path should never fail
we basically treat them as lang items
2020-03-19 08:26:08 +01:00
Ralf Jung
77cc0cddd9 add test for validation finding use-after-free 2020-03-19 08:25:08 +01:00
Ralf Jung
e6e8773272 start messages in lower-case 2020-03-19 08:25:08 +01:00
Ralf Jung
1103a10e2c adjust for error reform 2020-03-19 08:25:08 +01:00
bors
6b56aefa0b Auto merge of #1239 - elichai:2020-03-abort-intrinsics, r=RalfJung
Abort instead of panic on asserting intrinsics

This fixes #1222
replacing the panic with an abort and a corresponding message.
the stack trace is already printed, this just adds an optional message the caller can pass, and I just pass the same message we passed to the panic but now to the abort instead.

r? @RalfJung
2020-03-18 12:20:30 +00:00
Elichai Turkel
0826899ca0
Remove uninhabit/zeroed tests to a new test file for abort checking 2020-03-18 14:14:23 +02:00
Elichai Turkel
52e1372e03
Abort instead of panic in asserting intrinsics, because they might not be panic safe 2020-03-18 14:14:23 +02:00
Elichai Turkel
1b8979c8c7
Add an optional message to abort 2020-03-18 14:14:23 +02:00
bors
5e7fd2b44d Auto merge of #1238 - RalfJung:mir-opt-test, r=oli-obk
move repeated run of test suite (without and with MIR optimizations) out of compiletest

Just like we already pass the target architecture to our compiletest wrapper via `MIRI_TEST_TARGET` (and then have CI run compiletest with different values for that env var), we now do the same for running the tests with and without MIR optimizations.

This has the advantage of speeding up local `./miri test`, where in the vast majority of cases running tests both with and without optimizations is just a waste of time.
2020-03-18 10:36:41 +00:00
Ralf Jung
a32e25677f move repeated run of test suite (without and with MIR optimizations) out of compiletest 2020-03-18 11:19:01 +01:00
bors
ff2e799e36 Auto merge of #1237 - RalfJung:rustup, r=RalfJung
rustup; remove no longer existing intrinsics
2020-03-17 20:12:14 +00:00
Ralf Jung
b82cf36117 rustup; remove no longer existing intrinsics 2020-03-17 21:11:19 +01:00
bors
12b7cf877b Auto merge of #1235 - RalfJung:check-arith, r=RalfJung
avoid using unchecked casts or arithmetic
2020-03-17 14:22:44 +00:00
Ralf Jung
8b6af3eacb avoid using unchecked casts or arithmetic 2020-03-17 15:21:43 +01:00