decommit_table_pages should zero-fill some memory address.
But I add some test.
#[test]
fn test_decommit_table_pages() {
use super::Mmap;
let num = 3;
let mut memory = Mmap::accessible_reserved(4 * 1024, 4 * 1024).unwrap();
for i in 0..num {
memory.as_mut_slice()[i] = i as u8;
}
let s = unsafe { std::slice::from_raw_parts_mut(memory.as_mut_ptr(), num) };
println!("memory:{:?}", s);
imp::decommit_table_pages(memory.as_mut_ptr(), num).unwrap();
println!("memory:{:?}", s);
assert_eq!(s, &[0, 0, 0]);
}
Running `qemu-riscv64-static -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib -E WASMTIME_TEST_NO_HOG_MEMORY=1 /home/yuyang/projects/wasmtime/target/riscv64gc-unknown-linux-gnu/debug/deps/wasmtime_runtime-3e341cc661b6ff0e 'instance::allocator::pooling::test::test_decommit_table_pages' -Z unstable-options --show-output`
running 1 test
test instance::allocator::pooling::test::test_decommit_table_pages ... FAILED
successes:
successes:
failures:
---- instance::allocator::pooling::test::test_decommit_table_pages stdout ----
memory:[0, 1, 2]
memory:[0, 1, 2]
thread 'instance::allocator::pooling::test::test_decommit_table_pages' panicked at 'assertion failed: `(left == right)`
left: `[0, 1, 2]`,
right: `[0, 0, 0]`', crates/runtime/src/instance/allocator/pooling.rs:1509:9
stack backtrace:
0: rust_begin_unwind
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:181:5
4: wasmtime_runtime::instance::allocator::pooling::test::test_decommit_table_pages
at ./src/instance/allocator/pooling.rs:1509:9
5: wasmtime_runtime::instance::allocator::pooling::test::test_decommit_table_pages::{{closure}}
at ./src/instance/allocator/pooling.rs:1498:5
6: core::ops::function::FnOnce::call_once
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
7: core::ops::function::FnOnce::call_once
at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
instance::allocator::pooling::test::test_decommit_table_pages
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 34 filtered out; finished in 0.11s
error: test failed, to rerun pass '-p wasmtime-runtime --lib'
this cause table_limit
test failed.
https://github.com/bytecodealliance/wasmtime/blob/46782b18c2fb0dd5d2b931bb6ec7f9ead4bc809b/tests/all/pooling_allocator.rs#L242
https://man7.org/linux/man-pages/man2/madvise.2.html
yuyang@yuyang-Inspiron-7590:~/projects/wasmtime/crates/runtime$ RUST_BACKTRACE=1 /home/yuyang/.cargo/bin/cargo test --features pooling-allocator --color=always --package wasmtime-runtime --lib instance::allocator::pooling::test::test_decommit_table_pages --target x86_64-unknown-linux-gnu --no-fail-fast -- -Z unstable-options --show-output --test-threads=1
Finished test [unoptimized + debuginfo] target(s) in 0.07s
Running unittests src/lib.rs (/home/yuyang/projects/wasmtime/target/x86_64-unknown-linux-gnu/debug/deps/wasmtime_runtime-ea0da4b5057bbc63)
running 1 test
test instance::allocator::pooling::test::test_decommit_table_pages ... ok
successes:
successes:
instance::allocator::pooling::test::test_decommit_table_pages
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 34 filtered out; finished in 0.00s
x86_64-unknown-linux-gnu
can pass test.
@yang yu this is a known issue with qemu: its implementation of the madvise
system call is incomplete. Apparently the very newest qemu supports it properly (main
branch from their git repo), or you can build from source with the ci/qemu-madvise.patch
patch from our repository.
@Chris Fallin ok, thanks.
yang yu has marked this topic as resolved.
Last updated: Nov 22 2024 at 17:03 UTC