From dd5277321bd31c06724e14dd1ea7dec3c0d575b2 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 14 Apr 2021 19:02:11 +1000 Subject: [PATCH] CPU/CachedInterpreter: Fix infinite loop when block compile fails --- src/core/cpu_code_cache.cpp | 1 + src/core/cpu_core.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/cpu_code_cache.cpp b/src/core/cpu_code_cache.cpp index 9ca527e27..3cdc55a67 100644 --- a/src/core/cpu_code_cache.cpp +++ b/src/core/cpu_code_cache.cpp @@ -194,6 +194,7 @@ static void ExecuteImpl() if (!block) { InterpretUncachedBlock(); + next_block_key = GetNextBlockKey(); continue; } diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index 05fab21ab..72a63138e 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -1918,7 +1918,8 @@ template void InterpretUncachedBlock() { g_state.regs.npc = g_state.regs.pc; - FetchInstruction(); + if (!FetchInstruction()) + return; // At this point, pc contains the last address executed (in the previous block). The instruction has not been fetched // yet. pc shouldn't be updated until the fetch occurs, that way the exception occurs in the delay slot.