Skip to content

Commit a2ac13c

Browse files
committed
fix(executor): back all memory with a uniform page map, not just private input
store_byte used infallible allocation while every other private-input write path was fallible, and store_private_inputs could write 4 bytes past MAX_PRIVATE_INPUT_SIZE (the length prefix wasn't accounted for in the accepted payload size), corrupting the tail of a maximal-size input on readback. Rather than patch the private-input-only paged HashMap, drop the special case entirely: back the whole address space with one HashMap<page_idx, Box<page>>, so private input is just memory written at a fixed address like anything else. This removes the page/region alignment invariant the split design depended on, and every write (private or not) now goes through the same fallible page allocator.
1 parent e17edc9 commit a2ac13c

3 files changed

Lines changed: 192 additions & 263 deletions

File tree

executor/src/tests/memory_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::vm::memory::{Memory, MemoryError};
55
#[test]
66
fn test_commit_public_output_single() {
77
let mut memory = Memory::default();
8-
memory.store_byte(0x100, b'a');
9-
memory.store_byte(0x101, b'b');
8+
memory.store_byte(0x100, b'a').unwrap();
9+
memory.store_byte(0x101, b'b').unwrap();
1010

1111
memory
1212
.commit_public_output(0x100, 2)
@@ -23,10 +23,10 @@ fn test_commit_public_output_single() {
2323
#[test]
2424
fn test_commit_public_output_appends() {
2525
let mut memory = Memory::default();
26-
memory.store_byte(0x100, b'a');
27-
memory.store_byte(0x101, b'b');
28-
memory.store_byte(0x104, b'c');
29-
memory.store_byte(0x105, b'd');
26+
memory.store_byte(0x100, b'a').unwrap();
27+
memory.store_byte(0x101, b'b').unwrap();
28+
memory.store_byte(0x104, b'c').unwrap();
29+
memory.store_byte(0x105, b'd').unwrap();
3030

3131
memory
3232
.commit_public_output(0x100, 2)

executor/src/vm/instruction/execution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl Instruction {
189189
match width {
190190
LoadStoreWidth::Byte => {
191191
let value = read_value & 0xFF;
192-
memory.store_byte(addr, value as u8);
192+
memory.store_byte(addr, value as u8)?;
193193
}
194194
LoadStoreWidth::Half => {
195195
let value = read_value & 0xFFFF;

0 commit comments

Comments
 (0)