From e4d9fcb60271d94529bdd065d4590208d2ab1bf5 Mon Sep 17 00:00:00 2001 From: Leandro Pacheco Date: Thu, 9 Jan 2025 15:13:34 -0300 Subject: [PATCH] bugfix in identifying a chunk's accessed memory (#2316) --- riscv/src/continuations.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/riscv/src/continuations.rs b/riscv/src/continuations.rs index 0f764be77b..d6b8a68072 100644 --- a/riscv/src/continuations.rs +++ b/riscv/src/continuations.rs @@ -368,10 +368,16 @@ pub fn rust_continuations_dry_run( let mut accessed_pages = BTreeSet::new(); let mut accessed_addresses = BTreeSet::new(); - let start_idx = full_exec + let mut start_idx = full_exec .memory_accesses .binary_search_by_key(&proven_trace, |a| a.row) .unwrap_or_else(|v| v); + // We may have multiple memory accesses in the same row and binary + // search may return any match in case of multiple: ensure idx points to + // first match + while start_idx > 0 && full_exec.memory_accesses[start_idx - 1].row == proven_trace { + start_idx -= 1; + } for access in &full_exec.memory_accesses[start_idx..] { // proven_trace + length is an upper bound for the last row index we'll reach in the next chunk.