fix: 添加 vm 循环次数上限以避免测试死循环

This commit is contained in:
2026-06-06 23:43:05 +08:00
parent d12bb0b776
commit 74d5edf5b0
+6
View File
@@ -176,7 +176,13 @@ impl Vm {
}
fn dispatch(&mut self) -> Result<JsValue, String> {
let mut steps: u64 = 0;
const MAX_STEPS: u64 = 100_000_000;
loop {
steps += 1;
if steps > MAX_STEPS {
return Err(format!("VM step limit exceeded at pc={}", self.pc));
}
if self.pc >= self.bytecode.len() {
return Err("program counter out of bounds".into());
}