Commit Graph

5763 Commits

Author SHA1 Message Date
Ralf Jung
3ed8ad4423 avoid repeated string matching, and add more simd_reduce intrinsics 2022-03-05 18:46:14 -05:00
bors
3854a76ace Auto merge of #1970 - asquared31415:open_unix_varargs, r=RalfJung
Allow varargs for libc::open when it is allowed by the second argument

This PR allows `libc::open` to be called using two or three arguments as defined in https://man7.org/linux/man-pages/man2/open.2.html

The presence of the third argument depends on the value of the second argument.  If the second argument dictates that the third argument is *required* miri will emit an error if the argument is missing.  If the second argument does *not* require a third argument, then the argument is ignored and passed as 0 internally (it would be ignored by libc anyway)
2022-03-05 22:47:51 +00:00
asquared31415
8e97599af4 allow varargs for libc::open when it is allowed by the second argument 2022-03-05 17:29:48 -05:00
bors
2c1b9ce348 Auto merge of #1998 - RalfJung:rustup, r=RalfJung
rustup

Adjusts our tests for https://github.com/rust-lang/rust/pull/92697
2022-03-05 22:26:57 +00:00
Ralf Jung
ec0e513c64 rustup 2022-03-05 17:26:32 -05:00
bors
926af6493b Auto merge of #1999 - RalfJung:forward-env, r=oli-obk
add flag to forward specific env vars (while isolation remains enabled)

The flag is called `-Zmiri-env-forward=<var>`, but I am open to bikeshedding. ;)
2022-03-05 19:36:10 +00:00
bors
0242acc786 Auto merge of #2000 - RalfJung:simd, r=RalfJung
implement missing SIMD comparison operators, simd_xor, and simd_reduce_all
2022-03-05 18:47:28 +00:00
Ralf Jung
90207a5484 implement missing SIMD comparison operators, simd_xor, and simd_reduce_all 2022-03-05 13:45:13 -05:00
Ralf Jung
ceec2b3ceb avoid env var forwarding logic panicking for non-UTF-8 env vars 2022-03-05 11:14:37 -05:00
Ralf Jung
3adc203c1c add flag to forward specific env vars (while isolation remains enabled) 2022-03-05 11:14:37 -05:00
bors
a715171534 Auto merge of #1997 - RalfJung:simd, r=RalfJung
implement simd_neg and simd_fabs

This lets us run the puny portable-simd smoke test in the core test suite. ;)
2022-03-03 20:08:02 +00:00
Ralf Jung
0d4902f12f implement simd_neg and simd_fabs 2022-03-03 14:54:54 -05:00
Ralf Jung
0147b88ce5 use binary_op over overflowing_binary_op 2022-03-03 14:44:50 -05:00
bors
80c3f424b9 Auto merge of #1995 - saethlin:trophies, r=RalfJung
rkyv deallocation alignment issue
2022-03-03 18:57:56 +00:00
Ben Kimock
0bd83245ed rkyv deallocation alignment issue 2022-03-03 13:10:05 -05:00
bors
2f9ecdeba4 Auto merge of #1992 - RalfJung:sdiv, r=RalfJung
adjust for div/rem overflow being UB

This is the Miri side of https://github.com/rust-lang/rust/pull/94512. Just some error messages change.
2022-03-03 17:32:59 +00:00
Ralf Jung
c0f7251055 add test for simd division overflow UB 2022-03-03 12:32:42 -05:00
Ralf Jung
d7c7fc0fa2 rustup 2022-03-03 12:26:42 -05:00
Ralf Jung
97ddcf1f6b adjust for div/rem overflow being UB 2022-03-03 12:14:24 -05:00
bors
2b23786c48 Auto merge of #1994 - RalfJung:unaligned-ptr-test, r=RalfJung
Make sure we notice when a u16 is loaded at offset 1 into a u8 allocation

Cc https://github.com/rust-lang/miri/pull/1990 which would have changed the integer address logic in a way that this bug could not be found any more.
2022-03-02 18:07:58 +00:00
Ralf Jung
798dc5a78a Make sure we notice when a u16 is loaded at offset 1 into a u8 allocation 2022-03-02 13:06:28 -05:00
bors
c6b3f687d5 Auto merge of #1991 - RalfJung:rustup, r=RalfJung
Rustup: simd_select

Cc https://github.com/rust-lang/rust/issues/94474
2022-03-01 23:47:10 +00:00
Ralf Jung
363236e2d4 test overflowing Div/Rem 2022-03-01 18:44:37 -05:00
Ralf Jung
aa4f82ea48 implement simd_select 2022-03-01 18:40:40 -05:00
Ralf Jung
f672282bf2 factor SIMD bool handling into helper functions 2022-03-01 18:15:39 -05:00
bors
e05a543f74 Auto merge of #1985 - RalfJung:fn-ptr, r=RalfJung
update fn ptr tests

This adjusts the tests for https://github.com/rust-lang/rust/pull/94343.
2022-02-27 20:27:47 +00:00
Ralf Jung
c347b04e82 add test for rust issue 94371 2022-02-27 15:27:34 -05:00
Ralf Jung
71075672f5 rustup 2022-02-27 15:22:49 -05:00
bors
b490e6b01b Auto merge of #1989 - saethlin:short-backtraces, r=RalfJung
Only print the pruning note if the trace was definitely pruned

Per https://github.com/rust-lang/miri/pull/1987#discussion_r815337994

The only problem with this is that it looks like we can't emit the note about `-Zmiri-backtrace=full` if we also emit a tag-tracking diagnostic. The final note about the setting simply doesn't appear on the final error if it is printed before. I feel like we're running up against some diagnostic deduplication logic?
2022-02-26 22:17:04 +00:00
Ben Kimock
f1c649890b Only print the pruning note if the trace was definitely pruned 2022-02-26 17:02:17 -05:00
bors
144d56532c Auto merge of #1987 - saethlin:short-backtraces, r=oli-obk
Prune stacktraces for tag-tracking diagnostics too

In https://github.com/rust-lang/miri/pull/1977 we forgot to use the pruning logic when printing tag-tracking messages. I just saw this output before this PR which is very silly:
```
test sanity ... note: tracking was triggered
   --> src/lib.rs:110:21
    |
110 |         unsafe { &*(&self.value[range] as *const [T] as *const Aligned<A, [T]>) }
    |                     ^^^^^^^^^^^^^^^^^^ created tag 160954
    |
    = note: inside `<Aligned<A4, [u8]> as std::ops::Index<std::ops::RangeTo<usize>>>::index` at src/lib.rs:110:21
note: inside `sanity` at src/lib.rs:261:30
   --> src/lib.rs:261:30
    |
261 |     let y: &Aligned<_, _> = &y[..2];
    |                              ^^^^^^
note: inside closure at src/lib.rs:229:1
   --> src/lib.rs:229:1
    |
228 |   #[test]
    |   ------- in this procedural macro expansion
229 | / fn sanity() {
230 | |     use core::mem;
231 | |
232 | |     let x: Aligned<A2, _> = Aligned([0u8; 3]);
...   |
284 | |     let _: &[u8] = y;
285 | | }
    | |_^
    = note: inside `<[closure@src/lib.rs:229:1: 285:2] as std::ops::FnOnce<()>>::call_once - shim` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `test::__rust_begin_short_backtrace::<fn()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:575:5
    = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:566:30
    = note: inside `<[closure@test::run_test::{closure#1}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1854:9
    = note: inside `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9
    = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
    = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
    = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
    = note: inside `test::run_test_in_process` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:598:18
    = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:492:39
    = note: inside `test::run_test::run_test_inner` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:530:13
    = note: inside `test::run_test` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:562:28
    = note: inside `test::run_tests::<[closure@test::run_tests_console::{closure#2}]>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:305:17
    = note: inside `test::run_tests_console` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/console.rs:286:5
    = note: inside `test::test_main` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:116:15
    = note: inside `test::test_main_static` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:135:5
    = note: inside `main`
    = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:122:18
    = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:145:18
    = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
    = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
    = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
    = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
    = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:128:48
    = note: inside `std::panicking::r#try::do_call::<[closure@std::rt::lang_start_internal::{closure#2}], isize>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
    = note: inside `std::panicking::r#try::<isize, [closure@std::rt::lang_start_internal::{closure#2}]>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
    = note: inside `std::panic::catch_unwind::<[closure@std::rt::lang_start_internal::{closure#2}], isize>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
    = note: inside `std::rt::lang_start_internal` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:128:20
    = note: inside `std::rt::lang_start::<()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:144:17
    = note: this note originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)

error: Undefined Behavior: trying to reborrow for SharedReadOnly at alloc61593+0x2, but parent tag <160954> does not have an appropriate item in the borrow stack
   --> src/lib.rs:261:30
    |
261 |     let y: &Aligned<_, _> = &y[..2];
    |                              ^^^^^^ trying to reborrow for SharedReadOnly at alloc61593+0x2, but parent tag <160954> does not have an appropriate item in the borrow stack
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

    = note: inside `sanity` at src/lib.rs:261:30
note: inside closure at src/lib.rs:229:1
   --> src/lib.rs:229:1
    |
228 |   #[test]
    |   ------- in this procedural macro expansion
229 | / fn sanity() {
230 | |     use core::mem;
231 | |
232 | |     let x: Aligned<A2, _> = Aligned([0u8; 3]);
...   |
284 | |     let _: &[u8] = y;
285 | | }
    | |_^
    = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to previous error

error: test failed, to rerun pass '--lib'
```
2022-02-26 08:56:02 +00:00
Ben Kimock
d2bb231954 Prune stacktraces for tag-tracking diagnostics too 2022-02-25 19:18:05 -05:00
Ralf Jung
e9b140b4a5 update fn ptr tests 2022-02-25 12:06:10 -05:00
Ralf Jung
ddd3e3c4e0 rustup 2022-02-25 12:05:59 -05:00
bors
538aedf099 Auto merge of #1984 - RalfJung:rustup, r=RalfJung
rustup
2022-02-24 15:57:56 +00:00
Ralf Jung
444396d620 rustup 2022-02-24 10:55:40 -05:00
bors
6a39eeb764 Auto merge of #1982 - saethlin:trophies, r=oli-obk
Add crossbeam-epoch and integer-encoding to the trophy case

What are the critera for adding SB entries to the trophy case?
2022-02-23 09:13:16 +00:00
Ben Kimock
a20d1f1889 Add crossbeam-epoch and integer-encoding to the trophy case 2022-02-22 21:09:30 -05:00
bors
c71006722e Auto merge of #1977 - saethlin:short-backtraces, r=RalfJung
Prune backtraces similar to RUST_BACKTRACE=1 logic

This removes the majority of output from `cargo miri run` and `cargo miri test` in common usage.

~~I've copied the logic almost directly from `std`:
3b186511f6/library/std/src/sys_common/backtrace.rs (L76-L77~~)

~~It might be nice to have the "some details were omitted" note and a fallback to a setting where we print everything just in case this logic goes sideways, but~~
~~1. I'm not sure where to put the note~~
~~2. `MIRI_BACKTRACE`, `RUST_BACKTRACE`, and `RUSTC_CTFE_BACKTRACE` already do something else. Should we repurpose or add on to the semantics of `MIRI_BACKTRACE`?~~

---
Based on this tiny silly crate:
```rust
fn main() {
    some_function();
}

fn some_function() {
    unsafe {
        let _x: &u8 = core::mem::transmute(1usize);
    }
}

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        unsafe {
            let _x: &'static u8 = core::mem::transmute(1usize);
        }
    }
}
```

`cargo miri run`:
Before:
```
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `/home/ben/.cargo/bin/cargo-miri target/miri/x86_64-unknown-linux-gnu/debug/scratch`
error: Undefined Behavior: type validation failed: encountered a dangling reference (address 0x1 is unallocated)
 --> src/main.rs:7:23
  |
7 |         let _x: &u8 = core::mem::transmute(1usize);
  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (address 0x1 is unallocated)
  |
  = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
  = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

  = note: inside `some_function` at src/main.rs:7:23
note: inside `main` at src/main.rs:2:5
 --> src/main.rs:2:5
  |
2 |     some_function();
  |     ^^^^^^^^^^^^^^^
  = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
  = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:122:18
  = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:145:18
  = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
  = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
  = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
  = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
  = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:128:48
  = note: inside `std::panicking::r#try::do_call::<[closure@std::rt::lang_start_internal::{closure#2}], isize>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
  = note: inside `std::panicking::r#try::<isize, [closure@std::rt::lang_start_internal::{closure#2}]>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
  = note: inside `std::panic::catch_unwind::<[closure@std::rt::lang_start_internal::{closure#2}], isize>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
  = note: inside `std::rt::lang_start_internal` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:128:20
  = note: inside `std::rt::lang_start::<()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:144:17

error: aborting due to previous error

```
After:
```    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `/home/ben/.cargo/bin/cargo-miri target/miri/x86_64-unknown-linux-gnu/debug/scratch`
error: Undefined Behavior: type validation failed: encountered a dangling reference (address 0x1 is unallocated)
 --> src/main.rs:7:23
  |
7 |         let _x: &u8 = core::mem::transmute(1usize);
  |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (address 0x1 is unallocated)
  |
  = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
  = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

  = note: inside `some_function` at src/main.rs:7:23
note: inside `main` at src/main.rs:2:5
 --> src/main.rs:2:5
  |
2 |     some_function();
  |     ^^^^^^^^^^^^^^^

note: Some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace.

error: aborting due to previous error
```

`cargo miri test`
Before:
```
    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests (target/miri/x86_64-unknown-linux-gnu/debug/deps/scratch-9d7717efc37bb64c)

running 1 test
test tests::it_works ... error: Undefined Behavior: type validation failed: encountered a dangling reference (address 0x1 is unallocated)
  --> src/main.rs:16:35
   |
16 |             let _x: &'static u8 = core::mem::transmute(1usize);
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (address 0x1 is unallocated)
   |
   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

   = note: inside `tests::it_works` at src/main.rs:16:35
note: inside closure at src/main.rs:14:5
  --> src/main.rs:14:5
   |
13 |       #[test]
   |       ------- in this procedural macro expansion
14 | /     fn it_works() {
15 | |         unsafe {
16 | |             let _x: &'static u8 = core::mem::transmute(1usize);
17 | |         }
18 | |     }
   | |_____^
   = note: inside `<[closure@src/main.rs:14:5: 18:6] as std::ops::FnOnce<()>>::call_once - shim` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
   = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
   = note: inside `tests::test::__rust_begin_short_backtrace::<fn()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:575:5
   = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:566:30
   = note: inside `<[closure@tests::test::run_test::{closure#1}] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
   = note: inside `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1854:9
   = note: inside `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:271:9
   = note: inside `std::panicking::r#try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
   = note: inside `std::panicking::r#try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
   = note: inside `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
   = note: inside `tests::test::run_test_in_process` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:598:18
   = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:492:39
   = note: inside `tests::test::run_test::run_test_inner` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:530:13
   = note: inside `tests::test::run_test` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:562:28
   = note: inside `tests::test::run_tests::<[closure@tests::test::run_tests_console::{closure#2}]>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:305:17
   = note: inside `tests::test::run_tests_console` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/console.rs:290:5
   = note: inside `tests::test::test_main` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:116:15
   = note: inside `tests::test::test_main_static` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/test/src/lib.rs:135:5
   = note: inside `main`
   = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
   = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:122:18
   = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:145:18
   = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
   = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
   = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
   = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
   = note: inside closure at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:128:48
   = note: inside `std::panicking::r#try::do_call::<[closure@std::rt::lang_start_internal::{closure#2}], isize>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
   = note: inside `std::panicking::r#try::<isize, [closure@std::rt::lang_start_internal::{closure#2}]>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
   = note: inside `std::panic::catch_unwind::<[closure@std::rt::lang_start_internal::{closure#2}], isize>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
   = note: inside `std::rt::lang_start_internal` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:128:20
   = note: inside `std::rt::lang_start::<()>` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:144:17
   = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

error: test failed, to rerun pass '--bin scratch'
```

After:
```
    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests (target/miri/x86_64-unknown-linux-gnu/debug/deps/scratch-9d7717efc37bb64c)

running 1 test
test tests::it_works ... error: Undefined Behavior: type validation failed: encountered a dangling reference (address 0x1 is unallocated)
  --> src/main.rs:16:35
   |
16 |             let _x: &'static u8 = core::mem::transmute(1usize);
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (address 0x1 is unallocated)
   |
   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

   = note: inside `tests::it_works` at src/main.rs:16:35
note: inside closure at src/main.rs:14:5
  --> src/main.rs:14:5
   |
13 |       #[test]
   |       ------- in this procedural macro expansion
14 | /     fn it_works() {
15 | |         unsafe {
16 | |             let _x: &'static u8 = core::mem::transmute(1usize);
17 | |         }
18 | |     }
   | |_____^
   = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)

note: Some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace.

error: aborting due to previous error

error: test failed, to rerun pass '--bin scratch'
```
2022-02-22 15:39:07 +00:00
Ben Kimock
19ecd130b5 Prune backtraces similar to RUST_BACKTRACE=1 logic
Previously, Miri would always print a backtrace including all frames
when encountering an error. This adds -Zmiri-backtrace which defaults
to 1, internally called BacktraceStyle::Short. By default, backtraces
are pruned to start at __rust_begin_short_backtrace, similar to std.
Then we also remove non-local frames from the bottom of the trace.
This cleans up the last one or two shims outside main or a test.

Users can opt out of pruning by setting -Zmiri-backtrace=full, and will
be automatically opted out if there are no local frames because that
means the reported error is likely in the Rust runtime, which this
pruning is crafted to remove.
2022-02-22 10:32:52 -05:00
bors
d03b4a0c58 Auto merge of #1978 - RalfJung:simd_eq, r=RalfJung
implement simd_eq and simd_reduce_any

This lets us re-enable the division and modulo tests, since those operations now internally use simd_eq and simd_reduce_any.

However, I am not sure what exactly the rules are for simd_reduce_any. `@workingjubilee` for now I made it UB to call those with inputs that are not all-0 or all-1, but that might be taking it too far?
2022-02-22 02:43:53 +00:00
Ralf Jung
1ac1e55f3b implement simd_eq and simd_reduce_any 2022-02-21 21:41:52 -05:00
Ralf Jung
c8fff51825 rustup 2022-02-21 21:36:03 -05:00
bors
2b0078e455 Auto merge of #1979 - RalfJung:trophy, r=RalfJung
another for the trophy case
2022-02-21 02:42:18 +00:00
Ralf Jung
a21c98a896 another for the trophy case 2022-02-20 21:41:37 -05:00
bors
0db4090376 Auto merge of #1974 - RalfJung:const, r=RalfJung
implement const_deallocate as a NOP
2022-02-12 11:19:37 +00:00
Ralf Jung
ec66d2934b implement const_deallocate as a NOP 2022-02-12 12:17:37 +01:00
bors
2ba1e843c1 Auto merge of #1973 - RalfJung:rustup, r=RalfJung
implement const_allocate intrinsic

This is needed to make the libcore test suite pass again.
2022-02-12 10:54:24 +00:00
Ralf Jung
dfa0a3b3c7 implement const_allocate intrinsic 2022-02-12 11:53:51 +01:00
bors
a284d4f551 Auto merge of #1968 - RalfJung:rustup, r=RalfJung
rustup; implement simd_and/or

I had to disable the integer division tests since they now require simd_eq, which seems [non-trivial to implement](https://github.com/rust-lang/miri/issues/1912#issuecomment-1030164843).

Cc https://github.com/rust-lang/rust/issues/93619
2022-02-04 17:01:23 +00:00