about summary refs log tree commit diff
path: root/src/tools/miri/tests
AgeCommit message (Collapse)AuthorLines
2025-04-30interpret: better error message for out-of-bounds pointer arithmetic and ↵Ralf Jung-101/+101
accesses
2025-04-30Rollup merge of #140439 - RalfJung:miri-algebraic-float-nondet, r=oli-obkMatthias Krüger-59/+60
miri: algebraic intrinsics: bring back float non-determinism Fixes https://github.com/rust-lang/miri/issues/4289 Cc ```@bjoernager``` r? ```@oli-obk```
2025-04-29add -Zmiri-deterministic-concurrency flag and use it for concurrency testsRalf Jung-137/+91
2025-04-29Merge pull request #4272 from geetanshjuneja/schedulingRalf Jung-72/+72
Make thread scheduling fully random
2025-04-29Added random schedulinggeetanshjuneja-72/+72
2025-04-29miri: algebraic intrinsics: bring back float non-determinismRalf Jung-59/+60
2025-04-29suppress dangerous_implicit_autorefs in TB testRalf Jung-0/+1
2025-04-29fmtThe Miri Cronjob Bot-7/+3
2025-04-29Merge from rustcThe Miri Cronjob Bot-87/+109
2025-04-28Rollup merge of #139656 - scottmcm:stabilize-slice-as-chunks, r=dtolnayChris Denton-2/+1
Stabilize `slice_as_chunks` library feature ~~Draft as this needs #139163 to land first.~~ FCP: https://github.com/rust-lang/rust/issues/74985#issuecomment-2769963395 Methods being stabilized are: ```rust impl [T] { const fn as_chunks<const N: usize>(&self) -> (&[[T; N]], &[T]); const fn as_rchunks<const N: usize>(&self) -> (&[T], &[[T; N]]); const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]]; const fn as_chunks_mut<const N: usize>(&mut self) -> (&mut [[T; N]], &mut [T]); const fn as_rchunks_mut<const N: usize>(&mut self) -> (&mut [T], &mut [[T; N]]); const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]]; } ``` ~~(FCP's not done quite yet, but will in another day if I'm counting right.)~~ FCP Complete: https://github.com/rust-lang/rust/issues/74985#issuecomment-2797951535
2025-04-28Auto merge of #123948 - azhogin:azhogin/async-drop, r=oli-obkbors-85/+104
Async drop codegen Async drop implementation using templated coroutine for async drop glue generation. Scopes changes to generate `async_drop_in_place()` awaits, when async droppable objects are out-of-scope in async context. Implementation details: https://github.com/azhogin/posts/blob/main/async-drop-impl.md New fields in Drop terminator (drop & async_fut). Processing in codegen/miri must validate that those fields are empty (in full version async Drop terminator will be expanded at StateTransform pass or reverted to sync version). Changes in terminator visiting to consider possible new successor (drop field). ResumedAfterDrop messages for panic when coroutine is resumed after it is started to be async drop'ed. Lang item for generated coroutine for async function async_drop_in_place. `async fn async_drop_in_place<T>()::{{closure0}}`. Scopes processing for generate async drop preparations. Async drop is a hidden Yield, so potentially async drops require the same dropline preparation as for Yield terminators. Processing in StateTransform: async drops are expanded into yield-point. Generation of async drop of coroutine itself added. Shims for AsyncDropGlueCtorShim, AsyncDropGlue and FutureDropPoll. ```rust #[lang = "async_drop"] pub trait AsyncDrop { #[allow(async_fn_in_trait)] async fn drop(self: Pin<&mut Self>); } impl Drop for Foo { fn drop(&mut self) { println!("Foo::drop({})", self.my_resource_handle); } } impl AsyncDrop for Foo { async fn drop(self: Pin<&mut Self>) { println!("Foo::async drop({})", self.my_resource_handle); } } ``` First async drop glue implementation re-worked to use the same drop elaboration code as for sync drop. `async_drop_in_place` changed to be `async fn`. So both `async_drop_in_place` ctor and produced coroutine have their lang items (`AsyncDropInPlace`/`AsyncDropInPlacePoll`) and shim instances (`AsyncDropGlueCtorShim`/`AsyncDropGlue`). ``` pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: *mut T) { } ``` AsyncDropGlue shim generation uses `elaborate_drops::elaborate_drop` to produce drop ladder (in the similar way as for sync drop glue) and then `coroutine::StateTransform` to convert function into coroutine poll. AsyncDropGlue coroutine's layout can't be calculated for generic T, it requires known final dropee type to be generated (in StateTransform). So, `templated coroutine` was introduced here (`templated_coroutine_layout(...)` etc). Such approach overrides the first implementation using mixing language-level futures in https://github.com/rust-lang/rust/pull/121801.
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-85/+104
async_drop_in_place::{closure}, scoped async drop added.
2025-04-28Auto merge of #123239 - Urgau:dangerous_implicit_autorefs, ↵bors-0/+4
r=jdonszelmann,traviscross Implement a lint for implicit autoref of raw pointer dereference - take 2 *[t-lang nomination comment](https://github.com/rust-lang/rust/pull/123239#issuecomment-2727551097)* This PR aims at implementing a lint for implicit autoref of raw pointer dereference, it is based on #103735 with suggestion and improvements from https://github.com/rust-lang/rust/pull/103735#issuecomment-1370420305. The goal is to catch cases like this, where the user probably doesn't realise it just created a reference. ```rust pub struct Test { data: [u8], } pub fn test_len(t: *const Test) -> usize { unsafe { (*t).data.len() } // this calls <[T]>::len(&self) } ``` Since #103735 already went 2 times through T-lang, where they T-lang ended-up asking for a more restricted version (which is what this PR does), I would prefer this PR to be reviewed first before re-nominating it for T-lang. ---- Compared to the PR it is as based on, this PR adds 3 restrictions on the outer most expression, which must either be: 1. A deref followed by any non-deref place projection (that intermediate deref will typically be auto-inserted) 2. A method call annotated with `#[rustc_no_implicit_refs]`. 3. A deref followed by a `addr_of!` or `addr_of_mut!`. See bottom of post for details. There are several points that are not 100% clear to me when implementing the modifications: - ~~"4. Any number of automatically inserted deref/derefmut calls." I as never able to trigger this. Am I missing something?~~ Fixed - Are "index" and "field" enough? ---- cc `@JakobDegen` `@WaffleLapkin` r? `@RalfJung` try-job: dist-various-1 try-job: dist-various-2
2025-04-27`unsafe(no_mangle)` in `miri_start` examplesprimoly-1/+1
2025-04-25Merge from rustcThe Miri Cronjob Bot-1/+8
2025-04-24Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etcbendn-1/+8
2025-04-23Merge from rustcThe Miri Cronjob Bot-0/+21
2025-04-22Rollup merge of #140072 - folkertdev:miri-fn-align, r=RalfJungChris Denton-0/+21
handle function alignment in miri tracking issue: https://github.com/rust-lang/rust/issues/82232 Fixes https://github.com/rust-lang/miri/issues/4282 The `#[repr(align(N))]` attribute on functions was ignored when using miri. For such a function, its address should be a multiple of `N`. There is some further discussion in the thread [#t-compiler/const-eval > function address alignment](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/function.20address.20alignment) on how `dyn Fn` should be handled. The behavior there appears to be consistent between miri and nightly, though both may be incorrect. In any case, that can be resolved separately.
2025-04-22TB: add missing interior_mutability test fileRalf Jung-0/+177
2025-04-22Merge from rustcThe Miri Cronjob Bot-2/+2
2025-04-21Rollup merge of #140009 - ShE3py:tls-abort, r=thomccChris Denton-2/+2
docs(LocalKey<T>): clarify that T's Drop shouldn't panic Clarify that should a TLS destructor panics, the process will abort. Also, an abort may be obfuscated as the process can be terminated with `SIGSEGV` or [`STATUS_STACK_BUFFER_OVERRUN`](https://devblogs.microsoft.com/oldnewthing/20190108-00/?p=100655) (i.e., `SIGABRT` is not guaranteed), so explicitly prints that the process was aborted. Context: https://users.rust-lang.org/t/status-stack-buffer-overrun-on-windows-without-any-usage-of-unsafe/128417 ``@rustbot`` label -T-compiler
2025-04-20respect `repr(align(N))` on functions in miriFolkert de Vries-0/+21
2025-04-20Allow `dangerous_implicit_autorefs` lint in some testsUrgau-0/+4
2025-04-20Merge from rustcThe Miri Cronjob Bot-0/+29
2025-04-19Rollup merge of #139042 - compiler-errors:do-not-optimize-switchint, r=saethlinChris Denton-0/+29
Do not remove trivial `SwitchInt` in analysis MIR This PR ensures that we don't prematurely remove trivial `SwitchInt` terminators which affects both the borrow-checking and runtime semantics (i.e. UB) of the code. Previously the `SimplifyCfg` optimization was removing `SwitchInt` terminators when they was "trivial", i.e. when all arms branched to the same basic block, even if that `SwitchInt` terminator had the side-effect of reading an operand which (for example) may not be initialized or may point to an invalid place in memory. This behavior is unlike all other optimizations, which are only applied after "analysis" (i.e. borrow-checking) is finished, and which Miri disables to make sure the compiler doesn't silently remove UB. Fixing this code "breaks" (i.e. unmasks) code that used to borrow-check but no longer does, like: ```rust fn foo() { let x; let (0 | _) = x; } ``` This match expression should perform a read because `_` does not shadow the `0` literal pattern, and the compiler should have to read the match scrutinee to compare it to 0. I've checked that this behavior does not actually manifest in practice via a crater run which came back clean: https://github.com/rust-lang/rust/pull/139042#issuecomment-2767436367 As a side-note, it may be tempting to suggest that this is actually a good thing or that we should preserve this behavior. If we wanted to make this work (i.e. trivially optimize out reads from matches that are redundant like `0 | _`), then we should be enabling this behavior *after* fixing this. However, I think it's kinda unprincipled, and for example other variations of the code don't even work today, e.g.: ```rust fn foo() { let x; let (0.. | _) = x; } ```
2025-04-19simd_select_bitmask: the 'padding' bits in the mask are just ignoredRalf Jung-30/+13
2025-04-19Merge from rustcThe Miri Cronjob Bot-0/+45
2025-04-18rtprintpanic: clarify that the error is aborting the processLieselotte-2/+2
2025-04-18Merge from rustcThe Miri Cronjob Bot-1/+1
2025-04-18Rollup merge of #139553 - petrosagg:channel-double-free, r=RalfJung,tgross35Matthias Krüger-0/+45
sync::mpsc: prevent double free on `Drop` This PR is fixing a regression introduced by #121646 that can lead to a double free when dropping the channel. The details of the bug can be found in the corresponding crossbeam PR https://github.com/crossbeam-rs/crossbeam/pull/1187
2025-04-17Rollup merge of #139483 - RalfJung:nan, r=tgross35Matthias Krüger-1/+1
f*::NAN: guarantee that this is a quiet NaN I think we should guarantee that this is a quiet NaN. This then implies that programs not using `f*::from_bits` (or unsafe type conversions) are guaranteed to only work with quiet NaNs. It would be awkward if people start to write `0.0 / 0.0` instead of using the constant just because they want to get a guaranteed-quiet NaN. This is a `@rust-lang/libs-api` change. The definition of this constant currently is `0.0 / 0.0`, which is already guaranteed to be a quiet NaN. So all this does is forward that guarantee to our users.
2025-04-17Merge pull request #4263 from geetanshjuneja/check_shim_abiRalf Jung-3/+3
Replace check_shim with check_shim_abi in unix/foreign_items shims
2025-04-17replaced check_shim with check_shim_abi for env, file, sockets and time ↵geetanshjuneja-3/+3
related shims Making type consistent in shims pread return type fix make clock_gettime shim type consistent
2025-04-16use std-declared intrinsics rather than copying the declarationRalf Jung-106/+50
2025-04-15Merge pull request #4260 from CraftSpider/windows-file-deleteOli Scherer-5/+22
Implement file deletion on Windows
2025-04-12fmtThe Miri Cronjob Bot-1/+1
2025-04-12Merge from rustcThe Miri Cronjob Bot-0/+30
2025-04-11Implement DeleteFileWRune Tynan-5/+22
2025-04-11sync::mpsc: prevent double free on `Drop`Petros Angelatos-1/+1
This PR is fixing a regression introduced by #121646 that can lead to a double free when dropping the channel. The details of the bug can be found in the corresponding crossbeam PR https://github.com/crossbeam-rs/crossbeam/pull/1187 Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2025-04-11sync::mpsc: add miri reproducer of double freePetros Angelatos-0/+45
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2025-04-10Stabilize `slice_as_chunks` library featureScott McMurray-2/+1
2025-04-10Auto merge of #137412 - scottmcm:redo-swap, r=cuviperbors-0/+30
Ensure `swap_nonoverlapping` is really always untyped This replaces #134954, which was arguably overcomplicated. ## Fixes #134713 Actually using the type passed to `ptr::swap_nonoverlapping` for anything other than its size + align turns out to not work, so this goes back to always erasing the types down to just bytes. (Except in `const`, which keeps doing the same thing as before to preserve `@RalfJung's` fix from #134689) ## Fixes #134946 I'd previously moved the swapping to use auto-vectorization *on bytes*, but someone pointed out on Discord that the tail loop handling from that left a whole bunch of byte-by-byte swapping around. This goes back to manual tail handling to avoid that, then still triggers auto-vectorization on pointer-width values. (So you'll see `<4 x i64>` on `x86-64-v3` for example.)
2025-04-10Merge pull request #4261 from CraftSpider/windows-rtl-to-dosRalf Jung-1/+10
Implement RtlNtStatusToDosError and shim test for it
2025-04-10Implement RtlNtStatusToDosError and shim test for itRune Tynan-1/+10
2025-04-10Merge pull request #4262 from RalfJung/win-pathRalf Jung-2/+23
path: add more Windows tests
2025-04-10make GetFullPathNameW more correct on non-Windows hostsRalf Jung-4/+20
2025-04-10Merge pull request #4209 from LorrensP-2158466/freebsd_futexRalf Jung-0/+260
Implement FreeBSD syscall _umtx_op for futex support
2025-04-10feature: implement WAIT & WAKE operations of FreeBSD _umtx_op syscall for ↵LorrensP-2158466-0/+260
Futex support
2025-04-10path: add more Windows testsRalf Jung-1/+6
2025-04-09Add a Miri test for 134713Scott McMurray-0/+30