From ee3429a0d9e06e43c4289a6f4ed7fec9cb949c01 Mon Sep 17 00:00:00 2001 From: Thomas Korrison Date: Tue, 27 Jan 2026 15:55:13 +0000 Subject: [PATCH 1/5] Fix Windows backend import condition to match cfg_if! logic When running under Miri on Windows, the cfg_if! block in backends/mod.rs selects the fallback backend (because miri is checked first), but the conditional import at line 178 was only checking #[cfg(windows)], causing a compilation error when the windows module wasn't compiled. This fix ensures the import condition matches the cfg_if! logic by using #[cfg(all(windows, not(miri)))] instead of #[cfg(windows)], so the windows backend is only imported when it's actually compiled. Fixes compilation error: could not find 'windows' in 'backends' --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 81d7e49..3a7c898 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,12 +169,12 @@ psm_stack_manipulation! { } no { - #[cfg(not(windows))] + #[cfg(not(all(windows, not(miri))))] fn _grow(stack_size: usize, callback: &mut dyn FnMut()) { let _ = stack_size; callback(); } - #[cfg(windows)] + #[cfg(all(windows, not(miri)))] use backends::windows::_grow; } } From 0c03d4a906d7df01fbcfe77459835821092fdc92 Mon Sep 17 00:00:00 2001 From: Thomas Korrison Date: Tue, 27 Jan 2026 16:00:29 +0000 Subject: [PATCH 2/5] Add Miri testing to CI workflow Adds a new miri-test job that runs Miri tests on Ubuntu, Windows, and macOS for both stacker and psm manifests. This will help catch conditional compilation issues like the one fixed in the previous commit. --- .github/workflows/test.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f40807a..35b17a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -386,3 +386,26 @@ jobs: echo "${{ runner.tool_cache }}/wasmtime-v24.0.0-x86_64-linux" >> $GITHUB_PATH echo "CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime run --" >> $GITHUB_ENV - run: cargo test --target wasm32-wasip1 --all -- --nocapture + + miri-test: + name: Test ${{ matrix.manifest }} with Miri on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + manifest: ["psm/Cargo.toml", "Cargo.toml"] + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - name: Install Rust nightly with Miri + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + profile: minimal + components: miri + default: true + - name: Setup Miri + run: cargo miri setup --manifest-path=${{ matrix.manifest }} + - name: Test with Miri + run: cargo miri test --manifest-path=${{ matrix.manifest }} -- --nocapture From 8b88bdffa6ae7cf103aee49e27ecd0fa71bbed31 Mon Sep 17 00:00:00 2001 From: Thomas Korrison Date: Tue, 27 Jan 2026 16:04:46 +0000 Subject: [PATCH 3/5] Limit Miri tests to stacker crate only The psm crate has test compilation issues unrelated to this fix. Focus Miri testing on the main stacker crate where the cfg condition fix applies. --- .github/workflows/test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35b17a5..df99803 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -388,13 +388,12 @@ jobs: - run: cargo test --target wasm32-wasip1 --all -- --nocapture miri-test: - name: Test ${{ matrix.manifest }} with Miri on ${{ matrix.os }} + name: Test stacker with Miri on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - manifest: ["psm/Cargo.toml", "Cargo.toml"] timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -406,6 +405,6 @@ jobs: components: miri default: true - name: Setup Miri - run: cargo miri setup --manifest-path=${{ matrix.manifest }} + run: cargo miri setup - name: Test with Miri - run: cargo miri test --manifest-path=${{ matrix.manifest }} -- --nocapture + run: cargo miri test -- --nocapture From aa4277bd70d3b403b9580a4a30c2ae62ad44d5c1 Mon Sep 17 00:00:00 2001 From: Thomas Korrison Date: Tue, 27 Jan 2026 16:08:19 +0000 Subject: [PATCH 4/5] Skip heavy recursion tests under Miri Deep recursion tests are too slow under Miri's interpreter. These tests are skipped under Miri while still validating that the code compiles correctly (which was the main goal - catching the cfg condition mismatch). --- tests/simple.rs | 1 + tests/smoke.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tests/simple.rs b/tests/simple.rs index bb10937..807cbf9 100644 --- a/tests/simple.rs +++ b/tests/simple.rs @@ -18,6 +18,7 @@ fn recurse(n: usize) { } #[test] +#[cfg_attr(miri, ignore)] // Too slow under Miri's interpreter fn foo() { let limit = if cfg!(target_arch = "wasm32") { 2000 diff --git a/tests/smoke.rs b/tests/smoke.rs index 2ec0de2..3303a1e 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -7,6 +7,7 @@ use std::thread; fn __stacker_black_box(_: *const u8) {} #[test] +#[cfg_attr(miri, ignore)] // Too slow under Miri's interpreter fn deep() { fn foo(n: usize, s: &mut [u8]) { __stacker_black_box(s.as_ptr()); @@ -31,6 +32,7 @@ fn deep() { #[test] #[cfg_attr(target_arch = "wasm32", ignore)] +#[cfg_attr(miri, ignore)] // Too slow under Miri's interpreter fn panic() { fn foo(n: usize, s: &mut [u8]) { __stacker_black_box(s.as_ptr()); From eb85cad04fa8b0617e0c07c7f4dd81a88b968185 Mon Sep 17 00:00:00 2001 From: Thomas Korrison Date: Wed, 28 Jan 2026 00:48:45 +0000 Subject: [PATCH 5/5] Update Miri test conditions in smoke.rs Modified the deep test to include Miri in the target architecture check, allowing for better handling of recursion limits under Miri. This change ensures that the test is appropriately limited when running in the Miri environment, addressing performance concerns. --- tests/smoke.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/smoke.rs b/tests/smoke.rs index 3303a1e..c9c6fb5 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -7,7 +7,6 @@ use std::thread; fn __stacker_black_box(_: *const u8) {} #[test] -#[cfg_attr(miri, ignore)] // Too slow under Miri's interpreter fn deep() { fn foo(n: usize, s: &mut [u8]) { __stacker_black_box(s.as_ptr()); @@ -22,7 +21,7 @@ fn deep() { } } - let limit = if cfg!(target_arch = "wasm32") { + let limit = if cfg!(target_arch = "wasm32") || cfg!(miri) { 2000 } else { 256 * 1024