diff --git a/.github/workflows/miri.yml b/.github/workflows/miri.yml index b5889e1..5c80d23 100644 --- a/.github/workflows/miri.yml +++ b/.github/workflows/miri.yml @@ -5,17 +5,17 @@ on: [push, pull_request] env: CARGO_TERM_COLOR: always CARGO_NET_GIT_FETCH_WITH_CLI: true + DEFAULT_MIRI_FLAGS: -Zmiri-ignore-leaks -Zmiri-symbolic-alignment-check -Zmiri-retag-fields=all -Zmiri-symbolic-alignment-check -Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-tree-borrows -Zmiri-track-raw-pointers jobs: miri: runs-on: ubuntu-latest env: - RUSTFLAGS: ${{ matrix.rustflags }} + RUSTFLAGS: --cfg tokio_unstable strategy: matrix: toolchain: ["nightly-2023-09-01"] seed: [1, 2, 3, 4, 5, 6, 7, 8] - rustflags: ["--cfg mfio_assume_linear_types --cfg tokio_unstable", "--cfg tokio_unstable"] steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 @@ -25,4 +25,23 @@ jobs: - run: rustup component add miri - name: Run miri run: | - MIRIFLAGS="-Zmiri-seed=${{ matrix.seed }} -Zmiri-ignore-leaks -Zmiri-symbolic-alignment-check -Zmiri-retag-fields=all -Zmiri-symbolic-alignment-check -Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-tree-borrows" cargo miri test + MIRIFLAGS="-Zmiri-seed=${{matrix.seed}} ${{env.DEFAULT_MIRI_FLAGS}}" cargo miri test + + miri-linear-types: + runs-on: ubuntu-latest + env: + RUSTFLAGS: --cfg mfio_assume_linear_types --cfg tokio_unstable + strategy: + matrix: + toolchain: ["nightly-2023-09-01"] + seed: [1, 2, 3, 4, 5, 6, 7, 8] + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + - run: rustup component add miri + - name: Run miri + run: | + MIRIFLAGS="-Zmiri-seed=${{matrix.seed}} ${{env.DEFAULT_MIRI_FLAGS}} -Zmiri-track-raw-pointers" cargo miri test diff --git a/mfio-rt/src/native/impls/mod.rs b/mfio-rt/src/native/impls/mod.rs index 6b06406..d8402c9 100644 --- a/mfio-rt/src/native/impls/mod.rs +++ b/mfio-rt/src/native/impls/mod.rs @@ -14,21 +14,3 @@ pub mod iocp; #[cfg(all(not(miri), unix, feature = "mio"))] pub mod mio; - -cfg_if::cfg_if! { - if #[cfg(miri)] { - // Force use thread impl if on miri - pub use thread::*; - } else if #[cfg(all(target_os = "linux", feature = "io-uring"))] { - // io-uring provides true completion I/O, however, it's Linux-only. - pub use self::io_uring::*; - } else if #[cfg(all(unix, feature = "mio"))] { - // mio allows for true async io - // however, we are relying on file descriptors here, so we can't expose it on non-unix - // platforms. - pub use self::mio::*; - } else { - // Fallback to thread on any unmatched cases - pub use thread::*; - } -} diff --git a/mfio-rt/src/native/mod.rs b/mfio-rt/src/native/mod.rs index 88f7012..6b3cdbc 100644 --- a/mfio-rt/src/native/mod.rs +++ b/mfio-rt/src/native/mod.rs @@ -494,10 +494,6 @@ impl NativeRt { self.block_on(func(self)) } - fn register_file(&self, file: std::fs::File) -> NativeFile { - self.cwd.instance.register_file(file) - } - /// Registers a non-seekable I/O stream pub fn register_stream(&self, stream: TcpStream) -> NativeTcpStream { self.cwd.instance.register_stream(stream) diff --git a/mfio/src/io/mod.rs b/mfio/src/io/mod.rs index b6f3be8..ade4671 100644 --- a/mfio/src/io/mod.rs +++ b/mfio/src/io/mod.rs @@ -187,7 +187,7 @@ impl<'a, T: PacketIo, Perms: PacketPerms, Param, Pkt: PacketStore< type Output = Pkt::StackReq<'a>; fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { - let state: &Self = unsafe { core::mem::transmute(self) }; + let state = self.into_ref().get_ref(); loop { match unsafe { (*state.initial_state.get()).take() } { @@ -244,7 +244,7 @@ impl< > IoToFut<'a, T, Perms, Param, Pkt, Out> { pub fn submit(self: Pin<&mut Self>) -> &Out::StackReq<'a> { - let state: &Self = unsafe { core::mem::transmute(self) }; + let state = unsafe { self.get_unchecked_mut() }; if let Some((io, param)) = unsafe { (*state.initial_state.get()).take() } { // SAFETY: this packet's existence is tied to 'a lifetime, meaning it will be valid diff --git a/mfio/src/io/packet/mod.rs b/mfio/src/io/packet/mod.rs index e11d7c2..c14309f 100644 --- a/mfio/src/io/packet/mod.rs +++ b/mfio/src/io/packet/mod.rs @@ -103,13 +103,6 @@ impl RcAndWaker { } pub fn wait_finalize(&self) { - // FIXME: in theory, wait_finalize should only wait for the FINALIZED_BIT, but not deal - // with the locking and the waker. However, something is making us have to take the waker, - // to make these atomic ops sound (however, even then I doubt this is fully sound, but is - // merely moving probability of desync lower). - // Either way, we should be able to have this waker mechanism be way more optimized, - // without atomic locks. - self.take(); while (self.rc_and_flags.load(Ordering::Acquire) & FINALIZED_BIT) == 0 { core::hint::spin_loop(); }