From 9742679ebed966c62bf457df8353b9a5c6c22d29 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 13 Jan 2023 11:45:34 +0100 Subject: [PATCH 01/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index cf6d9c2808048..d42c0367b77d4 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -c54c8cbac882e149e04a9e1f2d146fd548ae30ae +279f1c9d8c26a8d227ae8ab806d262bb784b251b From 4aa07c921abafcc43fc9d545d8ec86b80103ec4e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 13 Jan 2023 14:01:33 +0100 Subject: [PATCH 02/39] clippy --- src/tools/miri/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 7024927b20561..84b64b0391323 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -21,7 +21,7 @@ clippy::single_match, clippy::useless_format, clippy::derive_partial_eq_without_eq, - clippy::derive_hash_xor_eq, + clippy::derived_hash_with_manual_eq, clippy::too_many_arguments, clippy::type_complexity, clippy::single_element_loop, From ec5f8253e28a660034a3936a171f93a3c063a0cc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 15 Jan 2023 16:45:54 -0500 Subject: [PATCH 03/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index d42c0367b77d4..c0dbb2e644c11 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -279f1c9d8c26a8d227ae8ab806d262bb784b251b +9e75dddf609c0201d03f9792e850f95d6a283d11 From cb7770736c15488ec816d24ed41928d513f56b4c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 22 Jan 2023 20:39:33 -0500 Subject: [PATCH 04/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index c0dbb2e644c11..7a5e8b789da33 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -9e75dddf609c0201d03f9792e850f95d6a283d11 +a5fa99eed20a46a88c0c85eed6552a94b6656634 From f055ad385f0f5a684f2658385dd47cf4df834af0 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 23 Jan 2023 08:54:47 +0000 Subject: [PATCH 05/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 7a5e8b789da33..0f7f4851c7a3e 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -a5fa99eed20a46a88c0c85eed6552a94b6656634 +ad48c109815a2e9441a7ad7796e55b8771fe01a5 From ff5132e2fc2e2bc5a6669c67c9c2d2fa208fd5f0 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 25 Jan 2023 18:46:20 +0100 Subject: [PATCH 06/39] add scfix test --- .../tests/pass/0weak_memory_consistency.rs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/tools/miri/tests/pass/0weak_memory_consistency.rs b/src/tools/miri/tests/pass/0weak_memory_consistency.rs index f3820bd660d28..7861acd4ef794 100644 --- a/src/tools/miri/tests/pass/0weak_memory_consistency.rs +++ b/src/tools/miri/tests/pass/0weak_memory_consistency.rs @@ -286,6 +286,40 @@ fn test_iriw_sc_rlx() { assert!(c || d); } +// Another test for C++20 SCfix. +fn scfix() { + let x = static_atomic_bool(false); + let y = static_atomic_bool(false); + + let thread1 = spawn(move || { + let a = x.load(Relaxed); + fence(SeqCst); + let b = y.load(Relaxed); + (a, b) + }); + + let thread2 = spawn(move || { + x.store(true, Relaxed); + }); + let thread3 = spawn(move || { + x.store(true, Relaxed); + }); + + let thread4 = spawn(move || { + let c = y.load(Relaxed); + fence(SeqCst); + let d = x.load(Relaxed); + (c, d) + }); + + let (a, b) = thread1.join().unwrap(); + thread2.join().unwrap(); + thread3.join().unwrap(); + let (c, d) = thread4.join().unwrap(); + let bad = a == true && b == false && c == true && d == false; + assert!(!bad); +} + pub fn main() { for _ in 0..50 { test_single_thread(); @@ -297,5 +331,6 @@ pub fn main() { test_sc_store_buffering(); test_sync_through_rmw_and_fences(); test_iriw_sc_rlx(); + scfix(); } } From 523325aec5ca0a4e56aef96d4e4537d706cca671 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 29 Jan 2023 22:04:43 +0100 Subject: [PATCH 07/39] remove scfix test It was broken, and the fixed version actually fails... --- .../tests/pass/0weak_memory_consistency.rs | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/src/tools/miri/tests/pass/0weak_memory_consistency.rs b/src/tools/miri/tests/pass/0weak_memory_consistency.rs index 7861acd4ef794..f3820bd660d28 100644 --- a/src/tools/miri/tests/pass/0weak_memory_consistency.rs +++ b/src/tools/miri/tests/pass/0weak_memory_consistency.rs @@ -286,40 +286,6 @@ fn test_iriw_sc_rlx() { assert!(c || d); } -// Another test for C++20 SCfix. -fn scfix() { - let x = static_atomic_bool(false); - let y = static_atomic_bool(false); - - let thread1 = spawn(move || { - let a = x.load(Relaxed); - fence(SeqCst); - let b = y.load(Relaxed); - (a, b) - }); - - let thread2 = spawn(move || { - x.store(true, Relaxed); - }); - let thread3 = spawn(move || { - x.store(true, Relaxed); - }); - - let thread4 = spawn(move || { - let c = y.load(Relaxed); - fence(SeqCst); - let d = x.load(Relaxed); - (c, d) - }); - - let (a, b) = thread1.join().unwrap(); - thread2.join().unwrap(); - thread3.join().unwrap(); - let (c, d) = thread4.join().unwrap(); - let bad = a == true && b == false && c == true && d == false; - assert!(!bad); -} - pub fn main() { for _ in 0..50 { test_single_thread(); @@ -331,6 +297,5 @@ pub fn main() { test_sc_store_buffering(); test_sync_through_rmw_and_fences(); test_iriw_sc_rlx(); - scfix(); } } From 8a10a4f79ef818897755b8daf52315c013604d4e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 30 Jan 2023 09:35:05 +0000 Subject: [PATCH 08/39] Add a note for using ssh login with josh --- src/tools/miri/CONTRIBUTING.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/miri/CONTRIBUTING.md b/src/tools/miri/CONTRIBUTING.md index 5b538691de183..f1bbf16fc7ad4 100644 --- a/src/tools/miri/CONTRIBUTING.md +++ b/src/tools/miri/CONTRIBUTING.md @@ -242,6 +242,14 @@ josh-proxy --local=$HOME/.cache/josh --remote=https://github.com --no-background This uses a directory `$HOME/.cache/josh` as a cache, to speed up repeated pulling/pushing. +Note that josh is unable to handle ssh auth natively, but you can force it to use ssh auth +by adding the following to your `.gitconfig`: + +```toml +[url "git@github.com:"] + pushInsteadOf = https://github.com/ +``` + ### Importing changes from the rustc repo Josh needs to be running, as described above. From 6e7ef5a919977eb7a000f1c2cee19bd0b4e43e8c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 30 Jan 2023 20:50:39 +0100 Subject: [PATCH 09/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 0f7f4851c7a3e..f1f26e4e31044 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -ad48c109815a2e9441a7ad7796e55b8771fe01a5 +a322848c6b0e037c1f0209387558ecb6ab763714 From 247a5f3acaee6cdd38476d7d558de2ac0f11489d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 31 Jan 2023 11:27:08 +0100 Subject: [PATCH 10/39] Update CONTRIBUTING.md Co-authored-by: Ralf Jung --- src/tools/miri/CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/miri/CONTRIBUTING.md b/src/tools/miri/CONTRIBUTING.md index f1bbf16fc7ad4..476075e9c914d 100644 --- a/src/tools/miri/CONTRIBUTING.md +++ b/src/tools/miri/CONTRIBUTING.md @@ -242,8 +242,7 @@ josh-proxy --local=$HOME/.cache/josh --remote=https://github.com --no-background This uses a directory `$HOME/.cache/josh` as a cache, to speed up repeated pulling/pushing. -Note that josh is unable to handle ssh auth natively, but you can force it to use ssh auth -by adding the following to your `.gitconfig`: +To make josh push via ssh instead of https, you can add the following to your `.gitconfig`: ```toml [url "git@github.com:"] From a78e178b659dc1cf29b0482c97006f2e84af8419 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 31 Jan 2023 12:04:08 +0100 Subject: [PATCH 11/39] dont run optimized MIR for now, it is broken --- src/tools/miri/ci.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh index e01bfbc74d98a..db9f180a5e572 100755 --- a/src/tools/miri/ci.sh +++ b/src/tools/miri/ci.sh @@ -43,7 +43,8 @@ function run_tests { # optimizations up all the way, too). # Optimizations change diagnostics (mostly backtraces), so we don't check # them. Also error locations change so we don't run the failing tests. - MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic} + #FIXME: temporarily disabled due to . + #MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic} # Also run some many-seeds tests. 64 seeds means this takes around a minute per test. for FILE in tests/many-seeds/*.rs; do From 15b9f45cca87abf30415daefaa85218756e994ed Mon Sep 17 00:00:00 2001 From: DebugSteven Date: Sat, 17 Dec 2022 13:41:30 -0700 Subject: [PATCH 12/39] busy waiting implementation for sleep --- src/tools/miri/src/shims/unix/linux/fd.rs | 58 ++++++++++++++++++- .../miri/src/shims/unix/linux/fd/event.rs | 35 ++++++++++- .../src/shims/unix/linux/foreign_items.rs | 6 ++ src/tools/miri/tests/pass-dep/tokio/sleep.rs | 14 +++++ .../tests/pass-dep/{ => tokio}/tokio_mvp.rs | 2 +- 5 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 src/tools/miri/tests/pass-dep/tokio/sleep.rs rename src/tools/miri/tests/pass-dep/{ => tokio}/tokio_mvp.rs (88%) diff --git a/src/tools/miri/src/shims/unix/linux/fd.rs b/src/tools/miri/src/shims/unix/linux/fd.rs index 212b7936341a7..fd4927fa10ce3 100644 --- a/src/tools/miri/src/shims/unix/linux/fd.rs +++ b/src/tools/miri/src/shims/unix/linux/fd.rs @@ -7,6 +7,8 @@ use socketpair::SocketPair; use shims::unix::fs::EvalContextExt as _; +use std::cell::Cell; + pub mod epoll; pub mod event; pub mod socketpair; @@ -101,6 +103,60 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } } + /// The `epoll_wait()` system call waits for events on the `Epoll` + /// instance referred to by the file descriptor `epfd`. The buffer + /// pointed to by `events` is used to return information from the ready + /// list about file descriptors in the interest list that have some + /// events available. Up to `maxevents` are returned by `epoll_wait()`. + /// The `maxevents` argument must be greater than zero. + + /// The `timeout` argument specifies the number of milliseconds that + /// `epoll_wait()` will block. Time is measured against the + /// CLOCK_MONOTONIC clock. + + /// A call to `epoll_wait()` will block until either: + /// • a file descriptor delivers an event; + /// • the call is interrupted by a signal handler; or + /// • the timeout expires. + + /// Note that the timeout interval will be rounded up to the system + /// clock granularity, and kernel scheduling delays mean that the + /// blocking interval may overrun by a small amount. Specifying a + /// timeout of -1 causes `epoll_wait()` to block indefinitely, while + /// specifying a timeout equal to zero cause `epoll_wait()` to return + /// immediately, even if no events are available. + /// + /// On success, `epoll_wait()` returns the number of file descriptors + /// ready for the requested I/O, or zero if no file descriptor became + /// ready during the requested timeout milliseconds. On failure, + /// `epoll_wait()` returns -1 and errno is set to indicate the error. + /// + /// + fn epoll_wait( + &mut self, + epfd: &OpTy<'tcx, Provenance>, + events: &OpTy<'tcx, Provenance>, + maxevents: &OpTy<'tcx, Provenance>, + timeout: &OpTy<'tcx, Provenance>, + ) -> InterpResult<'tcx, Scalar> { + let this = self.eval_context_mut(); + + let epfd = this.read_scalar(epfd)?.to_i32()?; + let _events = this.read_scalar(events)?.to_pointer(this)?; + let _maxevents = this.read_scalar(maxevents)?.to_i32()?; + let _timeout = this.read_scalar(timeout)?.to_i32()?; + + let numevents = 0; + if let Some(epfd) = this.machine.file_handler.handles.get_mut(&epfd) { + let _epfd = epfd.as_epoll_handle()?; + + // FIXME return number of events ready when scheme for marking events ready exists + Ok(Scalar::from_i32(numevents)) + } else { + Ok(Scalar::from_i32(this.handle_not_found()?)) + } + } + /// This function creates an `Event` that is used as an event wait/notify mechanism by /// user-space applications, and by the kernel to notify user-space applications of events. /// The `Event` contains an `u64` counter maintained by the kernel. The counter is initialized @@ -142,7 +198,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } let fh = &mut this.machine.file_handler; - let fd = fh.insert_fd(Box::new(Event { val })); + let fd = fh.insert_fd(Box::new(Event { val: Cell::new(val.into()) })); Ok(Scalar::from_i32(fd)) } diff --git a/src/tools/miri/src/shims/unix/linux/fd/event.rs b/src/tools/miri/src/shims/unix/linux/fd/event.rs index 239eb462a1d23..b28a6e0c56eca 100644 --- a/src/tools/miri/src/shims/unix/linux/fd/event.rs +++ b/src/tools/miri/src/shims/unix/linux/fd/event.rs @@ -2,6 +2,7 @@ use crate::shims::unix::fs::FileDescriptor; use rustc_const_eval::interpret::InterpResult; +use std::cell::Cell; use std::io; /// A kind of file descriptor created by `eventfd`. @@ -13,7 +14,9 @@ use std::io; /// #[derive(Debug)] pub struct Event { - pub val: u32, + /// The object contains an unsigned 64-bit integer (uint64_t) counter that is maintained by the + /// kernel. This counter is initialized with the value specified in the argument initval. + pub val: Cell, } impl FileDescriptor for Event { @@ -22,7 +25,7 @@ impl FileDescriptor for Event { } fn dup(&mut self) -> io::Result> { - Ok(Box::new(Event { val: self.val })) + Ok(Box::new(Event { val: self.val.clone() })) } fn is_tty(&self) -> bool { @@ -35,4 +38,32 @@ impl FileDescriptor for Event { ) -> InterpResult<'tcx, io::Result> { Ok(Ok(0)) } + + /// A write call adds the 8-byte integer value supplied in + /// its buffer to the counter. The maximum value that may be + /// stored in the counter is the largest unsigned 64-bit value + /// minus 1 (i.e., 0xfffffffffffffffe). If the addition would + /// cause the counter's value to exceed the maximum, then the + /// write either blocks until a read is performed on the + /// file descriptor, or fails with the error EAGAIN if the + /// file descriptor has been made nonblocking. + + /// A write fails with the error EINVAL if the size of the + /// supplied buffer is less than 8 bytes, or if an attempt is + /// made to write the value 0xffffffffffffffff. + /// + /// FIXME: use endianness + fn write<'tcx>( + &self, + _communicate_allowed: bool, + bytes: &[u8], + ) -> InterpResult<'tcx, io::Result> { + let v1 = self.val.get(); + // FIXME handle blocking when addition results in exceeding the max u64 value + // or fail with EAGAIN if the file descriptor is nonblocking. + let v2 = v1.checked_add(u64::from_be_bytes(bytes.try_into().unwrap())).unwrap(); + self.val.set(v2); + assert_eq!(8, bytes.len()); + Ok(Ok(8)) + } } diff --git a/src/tools/miri/src/shims/unix/linux/foreign_items.rs b/src/tools/miri/src/shims/unix/linux/foreign_items.rs index 82cb21c124a26..56d8d428210e2 100644 --- a/src/tools/miri/src/shims/unix/linux/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/linux/foreign_items.rs @@ -55,6 +55,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let result = this.epoll_ctl(epfd, op, fd, event)?; this.write_scalar(result, dest)?; } + "epoll_wait" => { + let [epfd, events, maxevents, timeout] = + this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; + let result = this.epoll_wait(epfd, events, maxevents, timeout)?; + this.write_scalar(result, dest)?; + } "eventfd" => { let [val, flag] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?; diff --git a/src/tools/miri/tests/pass-dep/tokio/sleep.rs b/src/tools/miri/tests/pass-dep/tokio/sleep.rs new file mode 100644 index 0000000000000..1341484dda475 --- /dev/null +++ b/src/tools/miri/tests/pass-dep/tokio/sleep.rs @@ -0,0 +1,14 @@ +//@compile-flags: -Zmiri-disable-isolation -Zmiri-permissive-provenance -Zmiri-backtrace=full +//@only-target-x86_64-unknown-linux: support for tokio only on linux and x86 + +use tokio::time::{sleep, Duration, Instant}; + +#[tokio::main] +async fn main() { + let start = Instant::now(); + sleep(Duration::from_secs(1)).await; + // It takes 96 millisecond to sleep for 1 millisecond + // It takes 1025 millisecond to sleep for 1 second + let time_elapsed = &start.elapsed().as_millis(); + assert!(time_elapsed > &1000, "{}", time_elapsed); +} diff --git a/src/tools/miri/tests/pass-dep/tokio_mvp.rs b/src/tools/miri/tests/pass-dep/tokio/tokio_mvp.rs similarity index 88% rename from src/tools/miri/tests/pass-dep/tokio_mvp.rs rename to src/tools/miri/tests/pass-dep/tokio/tokio_mvp.rs index 642168253c2fa..0bca7cc069a78 100644 --- a/src/tools/miri/tests/pass-dep/tokio_mvp.rs +++ b/src/tools/miri/tests/pass-dep/tokio/tokio_mvp.rs @@ -1,5 +1,5 @@ // Need to disable preemption to stay on the supported MVP codepath in mio. -//@compile-flags: -Zmiri-disable-isolation -Zmiri-permissive-provenance -Zmiri-preemption-rate=0 +//@compile-flags: -Zmiri-disable-isolation -Zmiri-permissive-provenance //@only-target-x86_64-unknown-linux: support for tokio exists only on linux and x86 #[tokio::main] From 6b3e49694d55e803aba4344e70e9d69e17b1f3e3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 1 Feb 2023 11:10:15 +0100 Subject: [PATCH 13/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index f1f26e4e31044..d7de41435aa9d 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -a322848c6b0e037c1f0209387558ecb6ab763714 +0d32c8f2ce10710b6560dcb75f32f79c378410d0 From 40cbe491f4e780f20f1e2cba4b8af2ecc8dabb13 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 1 Feb 2023 11:51:32 +0100 Subject: [PATCH 14/39] fmt --- .../miri/tests/fail/unaligned_pointers/reference_to_packed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/tests/fail/unaligned_pointers/reference_to_packed.rs b/src/tools/miri/tests/fail/unaligned_pointers/reference_to_packed.rs index 816b6ab9fb32f..4a43db0aac50a 100644 --- a/src/tools/miri/tests/fail/unaligned_pointers/reference_to_packed.rs +++ b/src/tools/miri/tests/fail/unaligned_pointers/reference_to_packed.rs @@ -3,7 +3,7 @@ #![allow(dead_code, unused_variables)] -use std::{ptr, mem}; +use std::{mem, ptr}; #[repr(packed)] struct Foo { From ff6fb4c33e8bd94b17a4715046b8266a1d42e793 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 2 Feb 2023 22:59:23 +0100 Subject: [PATCH 15/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index d7de41435aa9d..e0abc4bc93189 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -0d32c8f2ce10710b6560dcb75f32f79c378410d0 +f3126500f25114ba4e0ac3e76694dd45a22de56d From 072d5cd87353b0287a3f0fe2e36d51d4917d9522 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 3 Feb 2023 18:06:00 +0100 Subject: [PATCH 16/39] re-enable mir-opt tests --- src/tools/miri/ci.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh index db9f180a5e572..e01bfbc74d98a 100755 --- a/src/tools/miri/ci.sh +++ b/src/tools/miri/ci.sh @@ -43,8 +43,7 @@ function run_tests { # optimizations up all the way, too). # Optimizations change diagnostics (mostly backtraces), so we don't check # them. Also error locations change so we don't run the failing tests. - #FIXME: temporarily disabled due to . - #MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic} + MIRIFLAGS="${MIRIFLAGS:-} -O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test -- tests/{pass,panic} # Also run some many-seeds tests. 64 seeds means this takes around a minute per test. for FILE in tests/many-seeds/*.rs; do From a0dcb9d4824157295e823ce5feec926d104bd823 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 4 Feb 2023 00:55:01 +0000 Subject: [PATCH 17/39] Bump tokio from 1.23.1 to 1.24.2 in /test_dependencies Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.23.1 to 1.24.2. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/commits) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/tools/miri/test_dependencies/Cargo.lock | 4 ++-- src/tools/miri/test_dependencies/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/miri/test_dependencies/Cargo.lock b/src/tools/miri/test_dependencies/Cargo.lock index a84ed85976367..8be1ee54672d8 100644 --- a/src/tools/miri/test_dependencies/Cargo.lock +++ b/src/tools/miri/test_dependencies/Cargo.lock @@ -292,9 +292,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.23.1" +version = "1.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a54aca0c15d014013256222ba0ebed095673f89345dd79119d912eb561b7a8" +checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb" dependencies = [ "autocfg", "bytes", diff --git a/src/tools/miri/test_dependencies/Cargo.toml b/src/tools/miri/test_dependencies/Cargo.toml index f5ab6acf008c5..d1ff33379e40a 100644 --- a/src/tools/miri/test_dependencies/Cargo.toml +++ b/src/tools/miri/test_dependencies/Cargo.toml @@ -18,6 +18,6 @@ rand = { version = "0.8", features = ["small_rng"] } [target.'cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))'.dependencies] page_size = "0.5" -tokio = { version = "1.23", features = ["full"] } +tokio = { version = "1.24", features = ["full"] } [workspace] From f70f526eb10e530a3dd5593dc390570b2bd70066 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 7 Feb 2023 09:10:39 +0100 Subject: [PATCH 18/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index e0abc4bc93189..7bea079bb84ba 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -f3126500f25114ba4e0ac3e76694dd45a22de56d +dffea43fc1102bdfe16d88ed412c23d4f0f08d9d From 8461c0eb673e769cae656ce52dd662829437e200 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 7 Feb 2023 10:33:19 +0100 Subject: [PATCH 19/39] fmt --- src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs index 106e93751d219..4e6ff28d6ec73 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -148,8 +148,7 @@ impl NewPermission { NewPermission::Uniform { perm: Permission::Unique, access: Some(AccessKind::Write), - protector: (kind == RetagKind::FnEntry) - .then_some(ProtectorKind::WeakProtector), + protector: (kind == RetagKind::FnEntry).then_some(ProtectorKind::WeakProtector), } } else { // `!Unpin` boxes do not get `noalias` nor `dereferenceable`. From 185156280f8e952a864c5f4f4c4daa03bc04d46c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 9 Feb 2023 10:01:36 +0100 Subject: [PATCH 20/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 7bea079bb84ba..1be5752242ed0 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -dffea43fc1102bdfe16d88ed412c23d4f0f08d9d +e7acd078f443156b95cee11759a735db1cfc796e From 73a366673f3cbf12df912bedba4a2a56cc00e793 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 9 Feb 2023 10:58:48 +0100 Subject: [PATCH 21/39] don't waste half the address space on AVR targets --- src/tools/miri/src/machine.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 8e44d4d7adec8..269b441c5045c 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -477,7 +477,8 @@ pub struct MiriMachine<'mir, 'tcx> { impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { pub(crate) fn new(config: &MiriConfig, layout_cx: LayoutCx<'tcx, TyCtxt<'tcx>>) -> Self { - let local_crates = helpers::get_local_crates(layout_cx.tcx); + let tcx = layout_cx.tcx; + let local_crates = helpers::get_local_crates(tcx); let layouts = PrimitiveLayouts::new(layout_cx).expect("Couldn't get layouts of primitive types"); let profiler = config.measureme_out.as_ref().map(|out| { @@ -486,10 +487,13 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { let rng = StdRng::seed_from_u64(config.seed.unwrap_or(0)); let borrow_tracker = config.borrow_tracker.map(|bt| bt.instanciate_global_state(config)); let data_race = config.data_race_detector.then(|| data_race::GlobalState::new(config)); + // Determinine page size, stack address, and stack size. + // These values are mostly meaningless, but the stack address is also where we start + // allocating physical integer addresses for all allocations. let page_size = if let Some(page_size) = config.page_size { page_size } else { - let target = &layout_cx.tcx.sess.target; + let target = &tcx.sess.target; match target.arch.as_ref() { "wasm32" | "wasm64" => 64 * 1024, // https://webassembly.github.io/spec/core/exec/runtime.html#memory-instances "aarch64" => @@ -504,10 +508,12 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { _ => 4 * 1024, } }; - let stack_addr = page_size * 32; - let stack_size = page_size * 16; + // On 16bit targets, 32 pages is more than the entire address space! + let stack_addr = if tcx.pointer_size().bits() < 32 { page_size } else { page_size * 32 }; + let stack_size = + if tcx.pointer_size().bits() < 32 { page_size * 4 } else { page_size * 16 }; MiriMachine { - tcx: layout_cx.tcx, + tcx, borrow_tracker, data_race, intptrcast: RefCell::new(intptrcast::GlobalStateInner::new(config, stack_addr)), From f407e96b263e5ce71cde4bf93ad1865119ea45ad Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 15 Feb 2023 10:43:35 +0100 Subject: [PATCH 22/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 1be5752242ed0..b8bfb1b6e5cc3 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -e7acd078f443156b95cee11759a735db1cfc796e +068161ea483b1a80a959476cb3e31e6619a72737 From f0ab39b60ef631da86a5069935fdc9ba2e5d0def Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 16 Feb 2023 10:54:19 +0100 Subject: [PATCH 23/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index b8bfb1b6e5cc3..8afb8e9823566 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -068161ea483b1a80a959476cb3e31e6619a72737 +639377ed737b25830ec44dc6acf93467c980316a From 3fcbd1ccf92daa18d460731b89606edeb56fb8d0 Mon Sep 17 00:00:00 2001 From: Bryan Garza <1396101+bryangarza@users.noreply.github.com> Date: Sat, 11 Feb 2023 03:05:05 +0000 Subject: [PATCH 24/39] Add tests for moving data across await point This patch adds a few tests to assert the current behavior when passing data across an await point. This will help to test out an upcoming fix for the issue of arguments in async functions growing in size because of the generator upvar that is generated when we desugar the async function. See https://github.com/rust-lang/rust/issues/62958 Also relates to https://github.com/rust-lang/rust/pull/107500 Co-authored-by: Ralf Jung --- .../pass/move-data-across-await-point.rs | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/tools/miri/tests/pass/move-data-across-await-point.rs diff --git a/src/tools/miri/tests/pass/move-data-across-await-point.rs b/src/tools/miri/tests/pass/move-data-across-await-point.rs new file mode 100644 index 0000000000000..489fae66ffb2b --- /dev/null +++ b/src/tools/miri/tests/pass/move-data-across-await-point.rs @@ -0,0 +1,81 @@ +use std::future::Future; +use std::ptr; + +// This test: +// - Compares addresses of non-Copy data before and after moving it +// - Writes to the pointer after it has moved across the await point +// +// This is only meant to assert current behavior, not guarantee that this is +// how it should work in the future. In fact, upcoming changes to rustc +// *should* break these tests. +// See: https://github.com/rust-lang/rust/issues/62958 +async fn data_moved_async() { + async fn helper(mut data: Vec, raw_pointer: *mut Vec) { + let raw_pointer2 = ptr::addr_of_mut!(data); + // `raw_pointer` points to the original location where the Vec was stored in the caller. + // `data` is where that Vec (to be precise, its ptr+capacity+len on-stack data) + // got moved to. Those will usually not be the same since the Vec got moved twice + // (into the function call, and then into the generator upvar). + assert_ne!(raw_pointer, raw_pointer2); + unsafe { + // This writes into the `x` in `data_moved_async`, re-initializing it. + std::ptr::write(raw_pointer, vec![3]); + } + } + // Vec is not Copy + let mut x: Vec = vec![2]; + let raw_pointer = ptr::addr_of_mut!(x); + helper(x, raw_pointer).await; + unsafe { + assert_eq!(*raw_pointer, vec![3]); + // Drop to prevent leak. + std::ptr::drop_in_place(raw_pointer); + } +} + +// Same thing as above, but non-async. +fn data_moved() { + fn helper(mut data: Vec, raw_pointer: *mut Vec) { + let raw_pointer2 = ptr::addr_of_mut!(data); + assert_ne!(raw_pointer, raw_pointer2); + unsafe { + std::ptr::write(raw_pointer, vec![3]); + } + } + + let mut x: Vec = vec![2]; + let raw_pointer = ptr::addr_of_mut!(x); + helper(x, raw_pointer); + unsafe { + assert_eq!(*raw_pointer, vec![3]); + std::ptr::drop_in_place(raw_pointer); + } +} + +fn run_fut(fut: impl Future) -> T { + use std::sync::Arc; + use std::task::{Context, Poll, Wake, Waker}; + + struct MyWaker; + impl Wake for MyWaker { + fn wake(self: Arc) { + unimplemented!() + } + } + + let waker = Waker::from(Arc::new(MyWaker)); + let mut context = Context::from_waker(&waker); + + let mut pinned = Box::pin(fut); + loop { + match pinned.as_mut().poll(&mut context) { + Poll::Pending => continue, + Poll::Ready(v) => return v, + } + } +} + +fn main() { + run_fut(data_moved_async()); + data_moved(); +} From aed3b3f38c58714a037c2af47f5c276c135c226f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 18 Feb 2023 19:28:38 +0100 Subject: [PATCH 25/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 8afb8e9823566..3930fa0e94005 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -639377ed737b25830ec44dc6acf93467c980316a +3eb5c4581a386b13c414e8c8bd73846ef37236d1 From b76b26ee1aff1cb1bf4ea5c66da3b938ddd3bdcc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 18 Feb 2023 20:38:08 +0100 Subject: [PATCH 26/39] fmt --- src/tools/miri/src/machine.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 95b912d92c0c4..f9a6ef34c2f21 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -908,8 +908,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> { }; let (shim_size, shim_align, _kind) = ecx.get_alloc_info(alloc_id); let def_ty = ecx.tcx.type_of(def_id).subst_identity(); - let extern_decl_layout = - ecx.tcx.layout_of(ty::ParamEnv::empty().and(def_ty)).unwrap(); + let extern_decl_layout = ecx.tcx.layout_of(ty::ParamEnv::empty().and(def_ty)).unwrap(); if extern_decl_layout.size != shim_size || extern_decl_layout.align.abi != shim_align { throw_unsup_format!( "`extern` static `{name}` from crate `{krate}` has been declared \ From a52c7507327eb6a4459a93f6f04653380471dedf Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 20 Feb 2023 13:35:48 +0100 Subject: [PATCH 27/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 3930fa0e94005..0b18e5a426103 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -3eb5c4581a386b13c414e8c8bd73846ef37236d1 +7e253a7fb2e2e050021fed32da6fa2ec7bcea0fb From d46d6bdd658a1711cd92eaf5b77e1699fde582ec Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 21 Feb 2023 10:48:07 +0100 Subject: [PATCH 28/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 0b18e5a426103..461add9f50853 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -7e253a7fb2e2e050021fed32da6fa2ec7bcea0fb +f715e430aac0de131e2ad21804013ea405722a66 From 9005c774d63437b52c4e72e49f7716b549003422 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 21 Feb 2023 12:28:17 +0100 Subject: [PATCH 29/39] silence clippy --- src/tools/miri/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index 84b64b0391323..f64f216520f00 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -13,6 +13,7 @@ #![allow( clippy::collapsible_else_if, clippy::collapsible_if, + clippy::if_same_then_else, clippy::comparison_chain, clippy::enum_variant_names, clippy::field_reassign_with_default, From 4e0cb32311e3e3924ba7d9f93f519ae53ef21bfa Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 21 Feb 2023 11:36:49 +0000 Subject: [PATCH 30/39] Avoid formatting dyn* test as rustftm doesn't understand it yet and just deletes code --- src/tools/miri/tests/pass/dyn-star.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tools/miri/tests/pass/dyn-star.rs b/src/tools/miri/tests/pass/dyn-star.rs index 16a8cec6cdae1..1fac16352a448 100644 --- a/src/tools/miri/tests/pass/dyn-star.rs +++ b/src/tools/miri/tests/pass/dyn-star.rs @@ -1,5 +1,8 @@ #![feature(dyn_star)] #![allow(incomplete_features)] +#![feature(custom_inner_attributes)] +// rustfmt destroys `dyn* Trait` syntax +#![rustfmt::skip] use std::fmt::{Debug, Display}; From a80f5272c6b4a29f4f6479d63a5753ed9b697d8c Mon Sep 17 00:00:00 2001 From: LevitatingLion Date: Fri, 24 Feb 2023 02:59:58 +0100 Subject: [PATCH 31/39] Add shim for `llvm.arm.hint` This shim is required for `core::hint::spin_loop` on `arm` targets --- src/tools/miri/src/shims/foreign_items.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 2d9eb37a25806..03275ed4ed163 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -885,6 +885,19 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { } } } + "llvm.arm.hint" if this.tcx.sess.target.arch == "arm" => { + let [arg] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?; + let arg = this.read_scalar(arg)?.to_i32()?; + match arg { + // YIELD + 1 => { + this.yield_active_thread(); + } + _ => { + throw_unsup_format!("unsupported llvm.arm.hint argument {}", arg); + } + } + } // Platform-specific shims _ => From d4d7edfdf3d5b53e33546ea0793fd76bebfb4ff9 Mon Sep 17 00:00:00 2001 From: LevitatingLion Date: Fri, 24 Feb 2023 03:13:24 +0100 Subject: [PATCH 32/39] Use pointers to `c_char` instead of `i8` in `miri_host_to_target_path` This makes sure that the interface of `miri_host_to_target_path` is compatible with `CStr` for targets where `c_char` is unsigned (such as ARM). This commit changes the signature of `miri_host_to_target_path` in the README and in all test cases. --- src/tools/miri/README.md | 2 +- src/tools/miri/test-cargo-miri/src/main.rs | 6 +++--- src/tools/miri/test-cargo-miri/subcrate/main.rs | 6 +++--- src/tools/miri/test-cargo-miri/subcrate/test.rs | 6 +++--- src/tools/miri/tests/pass-dep/shims/libc-fs.rs | 8 ++++++-- src/tools/miri/tests/pass-dep/shims/libc-misc.rs | 8 ++++++-- src/tools/miri/tests/pass/shims/fs.rs | 8 ++++++-- 7 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index 48581f6bbff1a..9bd8ed1c4997e 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -590,7 +590,7 @@ extern "Rust" { /// `out` must point to at least `out_size` many bytes, and the result will be stored there /// with a null terminator. /// Returns 0 if the `out` buffer was large enough, and the required size otherwise. - fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize; + fn miri_host_to_target_path(path: *const c_char, out: *mut c_char, out_size: usize) -> usize; } ``` diff --git a/src/tools/miri/test-cargo-miri/src/main.rs b/src/tools/miri/test-cargo-miri/src/main.rs index 048dbbbaa0f06..048577ef15a61 100644 --- a/src/tools/miri/test-cargo-miri/src/main.rs +++ b/src/tools/miri/test-cargo-miri/src/main.rs @@ -23,7 +23,7 @@ fn main() { // (We rely on the test runner to always disable isolation when passing no arguments.) if std::env::args().len() <= 1 { fn host_to_target_path(path: String) -> PathBuf { - use std::ffi::{CStr, CString}; + use std::ffi::{c_char, CStr, CString}; let path = CString::new(path).unwrap(); let mut out = Vec::with_capacity(1024); @@ -31,8 +31,8 @@ fn main() { unsafe { extern "Rust" { fn miri_host_to_target_path( - path: *const i8, - out: *mut i8, + path: *const c_char, + out: *mut c_char, out_size: usize, ) -> usize; } diff --git a/src/tools/miri/test-cargo-miri/subcrate/main.rs b/src/tools/miri/test-cargo-miri/subcrate/main.rs index 1cb8091f87750..52161098788b5 100644 --- a/src/tools/miri/test-cargo-miri/subcrate/main.rs +++ b/src/tools/miri/test-cargo-miri/subcrate/main.rs @@ -5,7 +5,7 @@ fn main() { println!("subcrate running"); fn host_to_target_path(path: String) -> PathBuf { - use std::ffi::{CStr, CString}; + use std::ffi::{c_char, CStr, CString}; let path = CString::new(path).unwrap(); let mut out = Vec::with_capacity(1024); @@ -13,8 +13,8 @@ fn main() { unsafe { extern "Rust" { fn miri_host_to_target_path( - path: *const i8, - out: *mut i8, + path: *const c_char, + out: *mut c_char, out_size: usize, ) -> usize; } diff --git a/src/tools/miri/test-cargo-miri/subcrate/test.rs b/src/tools/miri/test-cargo-miri/subcrate/test.rs index 619d8c72fd0a7..1681c721dc2e2 100644 --- a/src/tools/miri/test-cargo-miri/subcrate/test.rs +++ b/src/tools/miri/test-cargo-miri/subcrate/test.rs @@ -8,7 +8,7 @@ fn main() { println!("subcrate testing"); fn host_to_target_path(path: String) -> PathBuf { - use std::ffi::{CStr, CString}; + use std::ffi::{c_char, CStr, CString}; let path = CString::new(path).unwrap(); let mut out = Vec::with_capacity(1024); @@ -16,8 +16,8 @@ fn main() { unsafe { extern "Rust" { fn miri_host_to_target_path( - path: *const i8, - out: *mut i8, + path: *const c_char, + out: *mut c_char, out_size: usize, ) -> usize; } diff --git a/src/tools/miri/tests/pass-dep/shims/libc-fs.rs b/src/tools/miri/tests/pass-dep/shims/libc-fs.rs index ba5b269f65242..cd071a7f32ac1 100644 --- a/src/tools/miri/tests/pass-dep/shims/libc-fs.rs +++ b/src/tools/miri/tests/pass-dep/shims/libc-fs.rs @@ -5,7 +5,7 @@ #![feature(io_error_uncategorized)] use std::convert::TryInto; -use std::ffi::{CStr, CString}; +use std::ffi::{c_char, CStr, CString}; use std::fs::{canonicalize, remove_dir_all, remove_file, File}; use std::io::{Error, ErrorKind, Write}; use std::os::unix::ffi::OsStrExt; @@ -31,7 +31,11 @@ fn tmp() -> PathBuf { unsafe { extern "Rust" { - fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize; + fn miri_host_to_target_path( + path: *const c_char, + out: *mut c_char, + out_size: usize, + ) -> usize; } let ret = miri_host_to_target_path(path.as_ptr(), out.as_mut_ptr(), out.capacity()); assert_eq!(ret, 0); diff --git a/src/tools/miri/tests/pass-dep/shims/libc-misc.rs b/src/tools/miri/tests/pass-dep/shims/libc-misc.rs index 20e96a92c7c5f..98e1c3a0adb2e 100644 --- a/src/tools/miri/tests/pass-dep/shims/libc-misc.rs +++ b/src/tools/miri/tests/pass-dep/shims/libc-misc.rs @@ -7,7 +7,7 @@ use std::os::unix::io::AsRawFd; use std::path::PathBuf; fn tmp() -> PathBuf { - use std::ffi::{CStr, CString}; + use std::ffi::{c_char, CStr, CString}; let path = std::env::var("MIRI_TEMP") .unwrap_or_else(|_| std::env::temp_dir().into_os_string().into_string().unwrap()); @@ -17,7 +17,11 @@ fn tmp() -> PathBuf { unsafe { extern "Rust" { - fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize; + fn miri_host_to_target_path( + path: *const c_char, + out: *mut c_char, + out_size: usize, + ) -> usize; } let ret = miri_host_to_target_path(path.as_ptr(), out.as_mut_ptr(), out.capacity()); assert_eq!(ret, 0); diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs index a7d4800faecc4..7a9974f393895 100644 --- a/src/tools/miri/tests/pass/shims/fs.rs +++ b/src/tools/miri/tests/pass/shims/fs.rs @@ -6,7 +6,7 @@ #![feature(is_terminal)] use std::collections::HashMap; -use std::ffi::OsString; +use std::ffi::{c_char, OsString}; use std::fs::{ canonicalize, create_dir, read_dir, read_link, remove_dir, remove_dir_all, remove_file, rename, File, OpenOptions, @@ -39,7 +39,11 @@ fn host_to_target_path(path: String) -> PathBuf { unsafe { extern "Rust" { - fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize; + fn miri_host_to_target_path( + path: *const c_char, + out: *mut c_char, + out_size: usize, + ) -> usize; } let ret = miri_host_to_target_path(path.as_ptr(), out.as_mut_ptr(), out.capacity()); assert_eq!(ret, 0); From 04b2aab141a51de0497a1a6751427e5a0ad86822 Mon Sep 17 00:00:00 2001 From: LevitatingLion Date: Fri, 24 Feb 2023 03:37:57 +0100 Subject: [PATCH 33/39] Add ARM targets to CI Specifically `aarch64-unknown-linux-gnu` and `arm-unknown-linux-gnueabi` --- src/tools/miri/README.md | 4 +++- src/tools/miri/ci.sh | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index 9bd8ed1c4997e..c60d6593bdcef 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -213,7 +213,9 @@ degree documented below): - The best-supported target is `x86_64-unknown-linux-gnu`. Miri releases are blocked on things working with this target. Most other Linux targets should also work well; we do run the test suite on `i686-unknown-linux-gnu` as a - 32bit target and `mips64-unknown-linux-gnuabi64` as a big-endian target. + 32bit target and `mips64-unknown-linux-gnuabi64` as a big-endian target, as + well as the ARM targets `aarch64-unknown-linux-gnu` and + `arm-unknown-linux-gnueabi`. - `x86_64-apple-darwin` should work basically as well as Linux. We also test `aarch64-apple-darwin`. However, we might ship Miri with a nightly even when some features on these targets regress. diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh index e01bfbc74d98a..4b7e8254a84c5 100755 --- a/src/tools/miri/ci.sh +++ b/src/tools/miri/ci.sh @@ -104,6 +104,8 @@ run_tests case $HOST_TARGET in x86_64-unknown-linux-gnu) MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests + MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests + MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests MIRI_TEST_TARGET=aarch64-apple-darwin run_tests MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var From 47aeaba8b3f92f001423047b268409503a188c05 Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 24 Feb 2023 16:05:50 +0300 Subject: [PATCH 34/39] bump rustc_tools_util --- src/tools/miri/cargo-miri/Cargo.lock | 4 ++-- src/tools/miri/cargo-miri/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/miri/cargo-miri/Cargo.lock b/src/tools/miri/cargo-miri/Cargo.lock index 37926db0166b7..76badcf94afb3 100644 --- a/src/tools/miri/cargo-miri/Cargo.lock +++ b/src/tools/miri/cargo-miri/Cargo.lock @@ -193,9 +193,9 @@ checksum = "fc71d2faa173b74b232dedc235e3ee1696581bb132fc116fa3626d6151a1a8fb" [[package]] name = "rustc_tools_util" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598f48ce2a421542b3e64828aa742b687cc1b91d2f96591cfdb7ac5988cd6366" +checksum = "8ba09476327c4b70ccefb6180f046ef588c26a24cf5d269a9feba316eb4f029f" [[package]] name = "rustc_version" diff --git a/src/tools/miri/cargo-miri/Cargo.toml b/src/tools/miri/cargo-miri/Cargo.toml index 2197160bc9d44..09079dbb818be 100644 --- a/src/tools/miri/cargo-miri/Cargo.toml +++ b/src/tools/miri/cargo-miri/Cargo.toml @@ -30,4 +30,4 @@ rustc-workspace-hack = "1.0.0" serde = { version = "*", features = ["derive"] } [build-dependencies] -rustc_tools_util = "0.2" +rustc_tools_util = "0.3" From 9a32db7e17c60d14aff19311d20bb54846239416 Mon Sep 17 00:00:00 2001 From: klensy Date: Fri, 24 Feb 2023 16:14:49 +0300 Subject: [PATCH 35/39] use setup_version_info! --- src/tools/miri/cargo-miri/build.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/tools/miri/cargo-miri/build.rs b/src/tools/miri/cargo-miri/build.rs index c111011545590..52e2a083512c4 100644 --- a/src/tools/miri/cargo-miri/build.rs +++ b/src/tools/miri/cargo-miri/build.rs @@ -2,12 +2,5 @@ fn main() { // Don't rebuild miri when nothing changed. println!("cargo:rerun-if-changed=build.rs"); // gather version info - println!( - "cargo:rustc-env=GIT_HASH={}", - rustc_tools_util::get_commit_hash().unwrap_or_default() - ); - println!( - "cargo:rustc-env=COMMIT_DATE={}", - rustc_tools_util::get_commit_date().unwrap_or_default() - ); + rustc_tools_util::setup_version_info!(); } From e81ebb947c94d1147d4ea398b98e125b9eba2567 Mon Sep 17 00:00:00 2001 From: LevitatingLion Date: Fri, 24 Feb 2023 14:27:46 +0100 Subject: [PATCH 36/39] Use full path to `c_char` in README Co-authored-by: Ralf Jung --- src/tools/miri/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index c60d6593bdcef..1086d0481c835 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -592,7 +592,7 @@ extern "Rust" { /// `out` must point to at least `out_size` many bytes, and the result will be stored there /// with a null terminator. /// Returns 0 if the `out` buffer was large enough, and the required size otherwise. - fn miri_host_to_target_path(path: *const c_char, out: *mut c_char, out_size: usize) -> usize; + fn miri_host_to_target_path(path: *const std::ffi::c_char, out: *mut std::ffi::c_char, out_size: usize) -> usize; } ``` From 9cb27d260447c948ea4e5dd4a499722f07f7a36d Mon Sep 17 00:00:00 2001 From: LevitatingLion Date: Fri, 24 Feb 2023 14:30:11 +0100 Subject: [PATCH 37/39] CI: Move `arm-unknown-linux-gnueabi` tests to Windows host --- src/tools/miri/ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh index 4b7e8254a84c5..60450d0981545 100755 --- a/src/tools/miri/ci.sh +++ b/src/tools/miri/ci.sh @@ -105,7 +105,6 @@ case $HOST_TARGET in x86_64-unknown-linux-gnu) MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests - MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests MIRI_TEST_TARGET=aarch64-apple-darwin run_tests MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var @@ -120,6 +119,7 @@ case $HOST_TARGET in MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests ;; i686-pc-windows-msvc) + MIRI_TEST_TARGET=arm-unknown-linux-gnueabi run_tests MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests MIRI_TEST_TARGET=x86_64-pc-windows-gnu run_tests ;; From 9fb185210eaa9d2de7e8ab1161897edf2eaae758 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 26 Feb 2023 18:13:46 +0100 Subject: [PATCH 38/39] Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 461add9f50853..53ec1ba0821b0 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -f715e430aac0de131e2ad21804013ea405722a66 +c4e0cd966062ca67daed20775f4e8a60c28e57df From 3f88f4ce9b8f38e3bfc5c07e14a4bb55999b6827 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 26 Feb 2023 19:09:17 +0100 Subject: [PATCH 39/39] update lockfile --- Cargo.lock | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e5deedb66fff..f8268cbc46f7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -444,7 +444,7 @@ dependencies = [ "directories", "rustc-build-sysroot", "rustc-workspace-hack", - "rustc_tools_util 0.2.1", + "rustc_tools_util", "rustc_version", "serde", "serde_json", @@ -738,7 +738,7 @@ dependencies = [ "regex", "rustc-semver", "rustc-workspace-hack", - "rustc_tools_util 0.3.0", + "rustc_tools_util", "semver", "serde", "syn", @@ -4725,12 +4725,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "rustc_tools_util" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598f48ce2a421542b3e64828aa742b687cc1b91d2f96591cfdb7ac5988cd6366" - [[package]] name = "rustc_tools_util" version = "0.3.0"