miri: WinApi SYSTEM_INFO `dwPageSize` always returning 0
This is a rather weird issue I reported first in the page_size crate. When running Miri with any of the Tier 1 Windows targets the crate reports page size 0, which is a fatal error for my use, where I want to allocate aligned to the page boundary.
This is witnessed most easily by the GitHub Action run. My code panics when the page size is not a power of two, so in this case it crashes with:
thread 'main' panicked at 'detected page size 0 that is not a power of two, this is unsupported', src/alignment.rs:111:21
The page size query works perfectly well for Unix targets.
Replication
This can be confirmed by referencing page_size and asking for it like this:
fn main() {
println!("Page size: {}", page_size::get());
}
and running Miri:
cargo +nightly miri run --target x86_64-pc-windows-gnu
resulting in:
> Page size: 0
Whereas running it without Miri gives the correct result (on my PC it’s 4KB):
cargo run
> Page size: 4096
If it matters, the host OS seems to not affect this, the issue is the same running the command both from Unix and Windows.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (18 by maintainers)
Commits related to this issue
- Auto merge of #2140 - V0ldek:page_size, r=RalfJung Update GetSystemInfo to work with `page_size` (#2136) - Change logic in GetSystemInfo shim to take into account the two possible layouts of `SYSTEM... — committed to rust-lang/miri by bors 2 years ago
- Auto merge of #2661 - DrMeepster:deref_operand_as, r=oli-obk Dereference pointers in shims as correct types Currently, shims will dereference pointers as the type written by the user. This can cause... — committed to rust-lang/miri by bors a year ago
You can add it as a dep in test-cargo-miri/Cargo.toml, and then add a test in test-cargo-miri/tests/test.rs