Skip to content

Commit

Permalink
Merge pull request #3538 from pmatos/OffsetofOoB
Browse files Browse the repository at this point in the history
Fix reference to out of bounds address in offsetof
  • Loading branch information
Sonicadvance1 authored Apr 2, 2024
2 parents cd9ffd2 + 96087a6 commit 4214d9b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Source/Tools/CommonTools/HarnessHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace FEX::HarnessHelper {
}

if (BaseConfig.OptionRegDataCount > 0) {
static constexpr std::array<uint64_t, 44> OffsetArrayAVX = {{
static constexpr std::array<uint64_t, 43> OffsetArrayAVX = {{
offsetof(FEXCore::Core::CPUState, rip),
offsetof(FEXCore::Core::CPUState, gregs[FEXCore::X86State::REG_RAX]),
offsetof(FEXCore::Core::CPUState, gregs[FEXCore::X86State::REG_RBX]),
Expand Down Expand Up @@ -169,9 +169,8 @@ namespace FEX::HarnessHelper {
offsetof(FEXCore::Core::CPUState, mm[5][0]),
offsetof(FEXCore::Core::CPUState, mm[6][0]),
offsetof(FEXCore::Core::CPUState, mm[7][0]),
offsetof(FEXCore::Core::CPUState, mm[8][0]),
}};
static constexpr std::array<uint64_t, 44> OffsetArraySSE = {{
static constexpr std::array<uint64_t, 43> OffsetArraySSE = {{
offsetof(FEXCore::Core::CPUState, rip),
offsetof(FEXCore::Core::CPUState, gregs[FEXCore::X86State::REG_RAX]),
offsetof(FEXCore::Core::CPUState, gregs[FEXCore::X86State::REG_RBX]),
Expand Down Expand Up @@ -215,7 +214,6 @@ namespace FEX::HarnessHelper {
offsetof(FEXCore::Core::CPUState, mm[5][0]),
offsetof(FEXCore::Core::CPUState, mm[6][0]),
offsetof(FEXCore::Core::CPUState, mm[7][0]),
offsetof(FEXCore::Core::CPUState, mm[8][0]),
}};

uintptr_t DataOffset = BaseConfig.OptionRegDataOffset;
Expand Down Expand Up @@ -254,10 +252,9 @@ namespace FEX::HarnessHelper {
Name = "gs";
else if (NameIndex == 34)
Name ="fs";
else if (NameIndex == 35)
Name = "rflags";
else if (NameIndex >= 36 && NameIndex < 45)
Name = fextl::fmt::format("MM[{}][{}]", NameIndex - 36, j);
else if (NameIndex >= 35 && NameIndex < 43) {
Name = fextl::fmt::format("MM[{}][{}]", NameIndex - 35, j);
}

if (State1) {
CheckGPRs(fextl::fmt::format("Core1: {}: ", Name), State1Data[j], RegData->RegValues[j]);
Expand Down

0 comments on commit 4214d9b

Please sign in to comment.