From 643750817a984473b701195ec53e37a8cb39c7de Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 12 Jan 2025 21:18:36 +0000 Subject: [PATCH] Frontend: End multiblocks early after hitting 2 consecutive null bytes 'add [rax], al' is almost never seen in actual code so the assumption can be made that we are most likely trying to explore garbage code and that this will never be hit. If it is then code will be generated at that point (where Entrypoint == true). --- FEXCore/Source/Interface/Core/Frontend.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/FEXCore/Source/Interface/Core/Frontend.cpp b/FEXCore/Source/Interface/Core/Frontend.cpp index c85e780011..566583165f 100644 --- a/FEXCore/Source/Interface/Core/Frontend.cpp +++ b/FEXCore/Source/Interface/Core/Frontend.cpp @@ -1103,6 +1103,12 @@ void Decoder::DecodeInstructionsAtEntry(const uint8_t* _InstStream, uint64_t PC, auto OpMinPage = OpMinAddress & FEXCore::Utils::FEX_PAGE_MASK; auto OpMaxPage = OpMaxAddress & FEXCore::Utils::FEX_PAGE_MASK; + if (!EntryBlock && OpMinPage == OpMaxPage && PeekByte(0) == 0 && PeekByte(1) == 0) [[unlikely]] { + // End the multiblock early if we hit 2 consecutive null bytes (add [rax], al) in the same page with the + // assumption we are most likely trying to explore garbage code. + break; + } + if (OpMinPage != CurrentCodePage) { CurrentCodePage = OpMinPage; CodePages.insert(CurrentCodePage);