about summary refs log tree commit diff
path: root/src/tools/miri/tests
AgeCommit message (Collapse)AuthorLines
2023-12-20Auto merge of #119037 - RalfJung:repr-c-abi-mismatch, r=scottmcmbors-0/+33
do not allow ABI mismatches inside repr(C) types In https://github.com/rust-lang/rust/pull/115476 we allowed ABI mismatches inside `repr(C)` types. This wasn't really discussed much; I added it because from how I understand calling conventions, this should actually be safe in practice. However I entirely forgot to actually allow this in Miri, and in the mean time I have learned that too much ABI compatibility can be a problem for CFI (it can reject fewer calls so that gives an attacker more room to play with). So I propose we take back that part about ABI compatibility in `repr(C)`. It is anyway something that C and C++ do not allow, as far as I understand. In the future we might want to introduce a class of ABI compatibilities where we say "this is a bug and it may lead to aborting the process, but it won't lead to arbitrary misbehavior -- worst case it'll just transmute the arguments from the caller type to the callee type". That would give CFI leeway to reject such calls without introducing the risk of arbitrary UB. (The UB can still happen if the transmute leads to bad results, of course, but it wouldn't be due to ABI weirdness.) #115476 hasn't reached beta yet so if we land this before Dec 22nd we can just pretend this all never happened. ;) Otherwise we should do a beta backport (of the docs change at least). Cc `@rust-lang/opsem` `@rust-lang/types`
2023-12-17do not allow ABI mismatches inside repr(C) typesRalf Jung-0/+33
2023-12-16Visit the AllocIds and BorTags in borrow state FrameExtraBen Kimock-0/+17
2023-12-15Auto merge of #3226 - saethlin:deadpool-test, r=RalfJungbors-0/+16
Add a regression test for rust#115145 Per https://github.com/rust-lang/rust/pull/118805#issuecomment-1855264860
2023-12-15Add the test minimized from deadpoolBen Kimock-0/+16
2023-12-15Merge from rustcThe Miri Conjob Bot-0/+21
2023-12-14add test for uninhabited saved locals in a coroutineRalf Jung-0/+31
2023-12-14Merge from rustcThe Miri Conjob Bot-0/+43
2023-12-13fix computing the dynamic alignment of packed structs with dyn trait tailsRalf Jung-0/+21
2023-12-13Auto merge of #118534 - RalfJung:extern-type-size-of-val, r=WaffleLapkinbors-0/+43
codegen: panic when trying to compute size/align of extern type The alignment is also computed when accessing a field of extern type at non-zero offset, so we also panic in that case. Previously `size_of_val` worked because the code path there assumed that "thin pointer" means "sized". But that's not true any more with extern types. The returned size and align are just blatantly wrong, so it seems better to panic than returning wrong results. We use a non-unwinding panic since code probably does not expect size_of_val to panic.
2023-12-12also add a Miri testRalf Jung-0/+43
2023-12-12fmtThe Miri Conjob Bot-1/+0
2023-12-12Merge from rustcThe Miri Conjob Bot-7/+7
2023-12-11Auto merge of #3222 - RalfJung:waker-noop, r=RalfJungbors-63/+17
tests: use Waker::noop instead of defining our own Waker
2023-12-11use Waker::noop instead of defining our own WakerRalf Jung-63/+17
2023-12-11Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwcobors-0/+2
Add lint against ambiguous wide pointer comparisons This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang. ## `ambiguous_wide_pointer_comparisons` *warn-by-default* The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands. ### Example ```rust let ab = (A, B); let a = &ab.0 as *const dyn T; let b = &ab.1 as *const dyn T; let _ = a == b; ``` ### Explanation The comparison includes metadata which may not be expected. ------- This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one. ~~One thing: is the current naming right? `invalid` seems a bit too much.~~ Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-11Auto merge of #118032 - RalfJung:char-u32, r=Mark-Simulacrumbors-1/+5
guarantee that char and u32 are ABI-compatible In https://github.com/rust-lang/rust/pull/116894 we added a guarantee that `char` has the same alignment as `u32`, but there is still one axis where these types could differ: function call ABI. So let's nail that down as well: in a function signature, `char` and `u32` are completely equivalent. This is a new stable guarantee, so it will need t-lang approval.
2023-12-10Return MAP_FAILED when mmap failsBen Kimock-0/+79
2023-12-10remove redundant importssurechen-6/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-08Fix x86 SSE4.1 ptestnzcEduardo Sánchez Muñoz-0/+5
`(op & mask) == 0` and `(op & mask) == mask` need each to be calculated for the whole vector. For example, given * `op = [0b100, 0b010]` * `mask = [0b100, 0b110]` The correct result would be: * `op & mask = [0b100, 0b010]` Comparisons are done on the vector as a whole: * `all_zero = (op & mask) == [0, 0] = false` * `masked_set = (op & mask) == mask = false` * `!all_zero && !masked_set = true` The previous method: `op & mask = [0b100, 0b010]` Comparisons are done element-wise: * `all_zero = (op & mask) == [0, 0] = [true, true]` * `masked_set = (op & mask) == mask = [true, false]` * `!all_zero && !masked_set = [true, false]` After folding with AND, the final result would be `false`, which is incorrect.
2023-12-06Adjust tests for newly added ambiguous_wide_pointer_comparisons lintUrgau-0/+2
2023-12-05fix miri_promise_symbolic_alignment for huge alignmentsRalf Jung-0/+34
2023-12-05fix typo in commentRalf Jung-1/+1
2023-12-05fmtThe Miri Conjob Bot-20/+24
2023-12-05Merge from rustcThe Miri Conjob Bot-21/+89
2023-12-04Rollup merge of #118540 - RalfJung:unsized-packed-offset, r=TaKO8KiTakayuki Maeda-0/+73
codegen, miri: fix computing the offset of an unsized field in a packed struct `#[repr(packed)]` strikes again. Fixes https://github.com/rust-lang/rust/issues/118537 Fixes https://github.com/rust-lang/miri/issues/3200 `@bjorn3` I assume cranelift needs the same fix.
2023-12-04fmtThe Miri Conjob Bot-10/+2
2023-12-04Merge from rustcThe Miri Conjob Bot-37/+111
2023-12-04Auto merge of #116915 - bend-n:unwet, r=saethlinbors-21/+16
Add an assume that the index is inbounds to slice::get_unchecked Fixes #116878
2023-12-04use `assume(idx < self.len())` in `[T]::get_unchecked`bendn-21/+16
2023-12-03Auto merge of #117840 - RalfJung:miri-promise-align, r=cjgillotbors-30/+104
miri: support 'promising' alignment for symbolic alignment check Then use that ability in `slice::align_to`, so that even with `-Zmiri-symbolic-alignment-check`, it no longer has to return spuriously empty "middle" parts. Fixes https://github.com/rust-lang/miri/issues/3068
2023-12-03miri: support 'promising' alignment for symbolic alignment checkRalf Jung-30/+104
2023-12-03SIMD bitmasks: use 'round up to multiple of 8' rather than 'clamp to at least 8'Ralf Jung-2/+0
2023-12-03disable a test that currently fails on big-endianRalf Jung-5/+9
2023-12-03also test directly calling simd_select_bitmaskRalf Jung-4/+39
2023-12-03also test simd_select_bitmask on arrays for less than 8 elementsRalf Jung-1/+6
2023-12-03Auto merge of #118567 - RalfJung:miri, r=RalfJungbors-12/+60
Miri subtree update r? `@ghost`
2023-12-03add simd_bswap and simd_bitreverseRalf Jung-0/+13
2023-12-03add simd_cttz and simd_ctlzRalf Jung-0/+5
2023-12-03simd_select_bitmask: support passing the mask as an arrayRalf Jung-0/+16
2023-12-03codegen, miri: fix computing the offset of an unsized field in a packed structRalf Jung-0/+73
2023-12-03Auto merge of #118487 - RalfJung:exposed-provenance, r=thomccbors-7/+7
move exposed-provenance APIs into separate feature gate We have already stated explicitly for all the 'exposed' functions that > Using this method means that code is *not* following strict provenance rules. However, they were part of the same feature gate and still described as part of the strict provenance experiment. Unfortunately, their semantics are much less clear and certainly nowhere near stabilization, so in preparation for an attempt to stabilize the strict provenance APIs, I suggest we split the things related to "exposed" into their own feature gate. I also used this opportunity to better explain how Exposed Provenance fits into the larger plan here: this is *one possible candidate* for `as` semantics, but we don't know if it is actually viable, so we can't really promise that it is equivalent to `as`. If it works out we probably want to make `as` equivalent to the 'exposed' APIs; if it doesn't, we will remove them again and try to find some other semantics for `as`.
2023-12-03Merge from rustcThe Miri Conjob Bot-9/+7
2023-12-02Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, ↵bors-9/+7
r=workingjubilee Portable SIMD subtree update Syncs nightly to the latest changes from rust-lang/portable-simd r? `@rust-lang/libs`
2023-11-30move exposed-provenance APIs into separate feature gate and explain the ↵Ralf Jung-7/+7
relationship of Exposed Provenance and Strict Provenance
2023-11-30give macOS some extra time, it needs thatRalf Jung-1/+1
2023-11-30move some validity-related tests into subdirRalf Jung-8/+8
2023-11-30move 'uninit' tests into common directoryRalf Jung-2/+4
2023-11-30Merge from rustcRalf Jung-0/+42
2023-11-29explain tests that disable the provenance GCRalf Jung-0/+9