about summary refs log tree commit diff
path: root/src/tools/miri/tests
AgeCommit message (Collapse)AuthorLines
2023-09-21Implement `llvm.ctpop.v*` intrinsicsEduardo Sánchez Muñoz-0/+257
Tested through x86 avx512vpopcntdq and avx512bitalg functions.
2023-09-21deprecate -Zmiri-disable-abi-checkRalf Jung-0/+8
2023-09-19Auto merge of #3054 - Vanille-N:spurious-fail, r=RalfJungbors-2/+2
Issue discovered in TB: spurious reads are not (yet) possible in a concurrent setting We discovered a week ago that in general, the current model of TB does not allow spurious reads because although reads provably never invalidate other reads, they migh invalidate writes. Consider the code ```rs fn f1(x: &u8) {} fn f2(y: &mut u8) -> &mut u8 { &mut *y } let mut data = 0; let _ = thread::spawn(|| { f1(&mut data) }; let _ = thread::spawn(|| { let y = f2(&mut data); *y = 42; }); ``` of which one possible interleaving is ```rs 1: retag x (&, protect) // x: [P]Frozen 2: retag y (&mut, protect) // y: [P]Reserved, x: [P]Frozen 1: return f1 // x: [P]Frozen -> Frozen, y: [P]Reserved 2: return f2 // x: Frozen, y: [P]Reserved -> Reserved 2: write y // x: Disabled, y: Active ``` that does not have UB. Assume enough barriers to force this specific interleaving, and consider that the compiler could choose to insert a spurious read throug `x` during the call to `f1` which would produce ```rs 1: retag x (&, protect) // x: [P]Frozen 2: retag y (&mut, protect) // y: [P]Reserved, x: [P]Frozen 1: spurious read x // x: [P]Frozen, y: [P]Reserved -> [P]Frozen 1: return f1 // x: [P]Frozen -> Frozen, y: [P]Frozen 2: return f2 // x: Frozen, y: [P]Frozen -> Frozen 2: write y // UB ``` Thus the target of the optimization (with a spurious read) has UB when the source did not. This is bad. SB is not affected because the code would be UB as early as `retag y`, this happens because we're trying to be a bit more subtle than that, and because the effects of a foreign read on a protected `&mut` bleed outside of the boundaries of the protector. Fortunately we have a fix planned, but in the meantime here are some `#[should_panic]` exhaustive tests to illustrate the issue. The error message printed by the `#[should_panic]` tests flags the present issue in slightly more general terms: it says that the sequence `retag x (&, protect); retag y (&mut, protect);` produces the configuration `C_source := x: [P]Frozen, x: [P]Reserved`, and that inserting a spurious read through `x` turns it into `C_target := x: [P]Frozen, y: [P]Reserved`. It then says that `C_source` is distinguishable from `C_target`, which means that there exists a sequence of instructions applied to both that triggers UB in `C_target` but not in `C_source`. It happens that one such sequence is `1: return f1; 2: return f2; 2: write y;` as shown above, but it is not the only one, as for example the interleaving `1: return f1; 2: write y;` is also problematic.
2023-09-19Issue of the current model: spurious reads are not possibleNeven Villani-2/+2
This occurs because in some interleavings, inserting a spurious read turns a Reserved into Frozen. We show here an exhaustive test (including arbitrary unknown code in two different threads) that makes this issue observable.
2023-09-14don't point at const usage site for resolution-time errorsRalf Jung-4/+4
also share the code that emits the actual error
2023-09-12Auto merge of #3055 - eduardosm:x86-sse2-intrinsics, r=RalfJungbors-2/+849
Implement some `llvm.x86.sse2.*` intrinsics and add tests Continuation of https://github.com/rust-lang/miri/pull/2989 with SSE2 intrinsics. Thankfully, a significant amount of SSE2 functions use `simd_*` intrinsics, which are already implemented in Miri.
2023-09-12Implement some `llvm.x86.sse2.*` intrinsics and add testsEduardo Sánchez Muñoz-0/+828
Implements LLVM intrisics needed to run most SSE2 functions from `core::arch::x86{,_64}`. Also adds miri tests for those functions (mostly copied from core_arch tests).
2023-09-12Ignore all archs except x86 and x86_64 in SSE testsEduardo Sánchez Muñoz-2/+21
2023-09-12extra ABI tests, in particular for DispatchFromDynRalf Jung-6/+16
2023-09-12fmtThe Miri Conjob Bot-1/+3
2023-09-09implement and test ABI compatibility for transparent wrappers around NPO typesRalf Jung-5/+8
2023-09-09implement and test fn ptr ABI compatibility rulesRalf Jung-0/+5
2023-09-09give extra context to ABI mismatch errorsRalf Jung-0/+12
2023-09-09interpret: change ABI-compat test to be type-based, so the test is ↵Ralf Jung-18/+21
consistent across targets
2023-09-06miri: catch function calls where the argument is caller-invalid / the return ↵Ralf Jung-4/+101
value callee-invalid
2023-09-02Rollup merge of #115443 - epage:os_str, r=cuviperMatthias Krüger-1/+1
feat(std): Stabilize 'os_str_bytes' feature Closes #111544
2023-09-01fix(std): Rename os_str_bytes to encoded_bytesEd Page-1/+1
2023-08-31miri ABI check: fix handling of 1-ZST; don't accept sign differencesRalf Jung-11/+15
2023-08-31update abi_compat.rsRalf Jung-12/+3
2023-08-31more ABI compat testsRalf Jung-12/+48
2023-08-31fmtRalf Jung-1/+1
2023-08-31Merge from rustcRalf Jung-12/+117
2023-08-31Merge from rustcThe Miri Conjob Bot-2/+26
2023-08-30miri function ABI check: specifically look for repr(transparent)Ralf Jung-0/+35
2023-08-30organize failing ABI compat tests and add some moreRalf Jung-10/+58
2023-08-30interpret: make sure we accept transparent newtypes as ABI-compatibleRalf Jung-1/+23
also we were missing the case for Vector arguments, so handle those as well
2023-08-30storage_live: avoid computing the layout unless necessaryRalf Jung-4/+4
2023-08-30move marking-locals-live out of push_stack_frame, so it happens with ↵Ralf Jung-5/+5
argument passing this entirely avoids even creating unsized locals in Immediate::Uninitialized state
2023-08-30interpret: fix projecting into an unsized field of a localRalf Jung-0/+24
new invariant: Place::Local never refers to something unsized
2023-08-29fmtThe Miri Conjob Bot-4/+6
2023-08-29Merge from rustcThe Miri Conjob Bot-2/+28
2023-08-28Auto merge of #115182 - RalfJung:abi-compat-sign, r=b-naberbors-0/+27
miri ABI compatibility check: accept u32 and i32 If only the sign differs, then surely these types are compatible. (We do still check that `arg_ext` is the same, just in case.) Also I made it so that the ABI check must *imply* that size and alignment are the same, but it doesn't actively check that itself. With how crazy ABI constraints get, having equal size and align really shouldn't be used as a signal for anything I think...
2023-08-28add tests for track_caller in closures and generatorsRalf Jung-5/+148
2023-08-28move basic track_caller test into their own fnRalf Jung-36/+39
2023-08-28Auto merge of #3039 - RalfJung:catch_panic, r=RalfJungbors-17/+19
tests/catch_panic: make output easier to interpret
2023-08-28tests/catch_panic: make output easier to interpretRalf Jung-17/+19
2023-08-28Rollup merge of #115280 - RalfJung:panic-cleanup-triple-backtrace, r=AmanieuMatthias Krüger-2/+1
avoid triple-backtrace due to panic-during-cleanup Supersedes https://github.com/rust-lang/rust/pull/115020 Cc https://github.com/rust-lang/rust/issues/114954 r? ``@Amanieu``
2023-08-27avoid triple-backtrace due to panic-during-cleanupRalf Jung-2/+1
2023-08-26Merge from rustcThe Miri Conjob Bot-7/+76
2023-08-25Auto merge of #115184 - saethlin:local-allocated-spans, r=RalfJungbors-5/+74
Record allocation spans inside force_allocation This expands https://github.com/rust-lang/miri/pull/2940 to cover locals r? `@RalfJung`
2023-08-25Record allocation spans inside force_allocationBen Kimock-5/+74
2023-08-24miri ABI compatibility check: accept u32 and i32Ralf Jung-0/+27
2023-08-24when terminating during unwinding, show the reason whyRalf Jung-2/+2
2023-08-22fix some bad regex capture group references in test normalizationRalf Jung-14/+14
2023-08-22respect CARGO_EXTRA_FLAGS in more placesRalf Jung-3/+10
2023-08-20interpret: have assert_* intrinsics call the panic machinery instead of a ↵Ralf Jung-13/+50
direct abort
2023-08-20interpret/miri: call panic_cannot_unwind lang item instead of hard-coding ↵Ralf Jung-39/+119
the same message
2023-08-19custom_mir: change Call() terminator syntax to something more readableRalf Jung-35/+35
2023-08-16on out-of-bounds error, show where the allocation was createdRalf Jung-7/+45
2023-08-16Auto merge of #2940 - saethlin:use-after-free-spans, r=RalfJungbors-14/+169
When reporting a heap use-after-free, say where the allocation was allocated and deallocated This is a partial solution to: https://github.com/rust-lang/miri/issues/2917 Currently in the interpreter, we only have accurate information for where heap allocations are allocated and deallocated (see https://github.com/rust-lang/miri/pull/2940#discussion_r1243559711). So this just implements support for allocations where the information is already available, and the full support will require more interpreter tweaks.