Skip to content

Commit 8b1975c

Browse files
committed
Check memory page flag
1 parent 01dd20d commit 8b1975c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fuzz/fuzz_targets/snapshot2.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use ckb_vm::{
44
machine::VERSION2,
55
memory::{round_page_down, round_page_up, FLAG_EXECUTABLE, FLAG_FREEZED},
66
snapshot2::{DataSource, Snapshot2Context},
7-
Bytes, CoreMachine, DefaultMachine, DefaultMachineBuilder, Error, Memory, DEFAULT_MEMORY_SIZE,
8-
ISA_A, ISA_B, ISA_IMC, ISA_MOP, RISCV_PAGESIZE,
7+
Bytes, CoreMachine, DefaultMachine, DefaultMachineBuilder, Error, Memory, SupportMachine,
8+
DEFAULT_MEMORY_SIZE, ISA_A, ISA_B, ISA_IMC, ISA_MOP, RISCV_PAGESIZE,
99
};
1010
use ckb_vm_definitions::asm::AsmCoreMachine;
1111
use libfuzzer_sys::fuzz_target;
@@ -183,6 +183,7 @@ fuzz_target!(|data: [u8; 96]| {
183183
.memory_mut()
184184
.load_bytes((i * RISCV_PAGESIZE) as u64, RISCV_PAGESIZE as u64)
185185
.unwrap();
186+
186187
if mem1 != mem2 {
187188
eprintln!("mem1[0..32] = {:?}", &mem1[0..32]);
188189
eprintln!("mem2[0..32] = {:?}", &mem2[0..32]);
@@ -196,5 +197,12 @@ fuzz_target!(|data: [u8; 96]| {
196197
}
197198
panic!("The memory restored by operation resume is not same as snapshot operation at page {}", i);
198199
}
200+
201+
let flag1 = machine1.memory_mut().fetch_flag(i as u64);
202+
let flag2 = machine2.memory_mut().fetch_flag(i as u64);
203+
204+
if flag1 != flag2 {
205+
panic!("Flag at page {}", i);
206+
}
199207
}
200208
});

0 commit comments

Comments
 (0)