Skip to content

Commit

Permalink
Check memory page flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Mar 20, 2024
1 parent 01dd20d commit 8b1975c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fuzz/fuzz_targets/snapshot2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use ckb_vm::{
machine::VERSION2,
memory::{round_page_down, round_page_up, FLAG_EXECUTABLE, FLAG_FREEZED},
snapshot2::{DataSource, Snapshot2Context},
Bytes, CoreMachine, DefaultMachine, DefaultMachineBuilder, Error, Memory, DEFAULT_MEMORY_SIZE,
ISA_A, ISA_B, ISA_IMC, ISA_MOP, RISCV_PAGESIZE,
Bytes, CoreMachine, DefaultMachine, DefaultMachineBuilder, Error, Memory, SupportMachine,
DEFAULT_MEMORY_SIZE, ISA_A, ISA_B, ISA_IMC, ISA_MOP, RISCV_PAGESIZE,
};
use ckb_vm_definitions::asm::AsmCoreMachine;
use libfuzzer_sys::fuzz_target;
Expand Down Expand Up @@ -183,6 +183,7 @@ fuzz_target!(|data: [u8; 96]| {
.memory_mut()
.load_bytes((i * RISCV_PAGESIZE) as u64, RISCV_PAGESIZE as u64)
.unwrap();

if mem1 != mem2 {
eprintln!("mem1[0..32] = {:?}", &mem1[0..32]);
eprintln!("mem2[0..32] = {:?}", &mem2[0..32]);
Expand All @@ -196,5 +197,12 @@ fuzz_target!(|data: [u8; 96]| {
}
panic!("The memory restored by operation resume is not same as snapshot operation at page {}", i);
}

let flag1 = machine1.memory_mut().fetch_flag(i as u64);
let flag2 = machine2.memory_mut().fetch_flag(i as u64);

if flag1 != flag2 {
panic!("Flag at page {}", i);
}
}
});

0 comments on commit 8b1975c

Please sign in to comment.