Skip to content

Commit 48c03d7

Browse files
Merge pull request #4273 from bylaws/earlyend
Frontend: End multiblocks early after hitting 2 consecutive null bytes
2 parents a52dd71 + 6437508 commit 48c03d7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

FEXCore/Source/Interface/Core/Frontend.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,12 @@ void Decoder::DecodeInstructionsAtEntry(const uint8_t* _InstStream, uint64_t PC,
11041104
auto OpMinPage = OpMinAddress & FEXCore::Utils::FEX_PAGE_MASK;
11051105
auto OpMaxPage = OpMaxAddress & FEXCore::Utils::FEX_PAGE_MASK;
11061106

1107+
if (!EntryBlock && OpMinPage == OpMaxPage && PeekByte(0) == 0 && PeekByte(1) == 0) [[unlikely]] {
1108+
// End the multiblock early if we hit 2 consecutive null bytes (add [rax], al) in the same page with the
1109+
// assumption we are most likely trying to explore garbage code.
1110+
break;
1111+
}
1112+
11071113
if (OpMinPage != CurrentCodePage) {
11081114
CurrentCodePage = OpMinPage;
11091115
CodePages.insert(CurrentCodePage);

0 commit comments

Comments
 (0)