Skip to content

Commit d9a0f34

Browse files
committed
[MERGE chakra-core#4412 @MSLaguana] Fixes an issue with x86 stack walking in the presence of doubly aligned frames
Merge pull request chakra-core#4412 from MSLaguana:fixStackWalk This was in particular hitting the JSRT interface which had a doubly aligned frame and caused crashes on stack walks.
2 parents 39d16c3 + 706a951 commit d9a0f34

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/Runtime/Language/JavascriptStackWalker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ namespace Js
737737
}
738738

739739
// If we're at the entry from a host frame, hop to the frame from which we left the script.
740-
if (this->currentFrame.GetAddressOfInstructionPointer() == this->entryExitRecord->addrOfReturnAddrOfScriptEntryFunction)
740+
if (AlignAndCheckAddressOfReturnAddressMatch(this->currentFrame.GetAddressOfInstructionPointer(), this->entryExitRecord->addrOfReturnAddrOfScriptEntryFunction))
741741
{
742742
BOOL hasCaller = this->entryExitRecord->hasCaller || this->forceFullWalk;
743743

@@ -874,7 +874,7 @@ namespace Js
874874
return false;
875875
}
876876

877-
bool AlignAndCheckAddressOfReturnAddressMatch(void* addressOfReturnAddress, void* nativeLibraryEntryAddress)
877+
bool JavascriptStackWalker::AlignAndCheckAddressOfReturnAddressMatch(void* addressOfReturnAddress, void* nativeLibraryEntryAddress)
878878
{
879879
return addressOfReturnAddress == nativeLibraryEntryAddress
880880
#if defined(_M_IX86)
@@ -883,7 +883,7 @@ namespace Js
883883
// return address offset by 4, 8, or 12.
884884
|| (((uint)nativeLibraryEntryAddress - (uint)addressOfReturnAddress < 0x10) &&
885885
*(void**)addressOfReturnAddress == *(void**)nativeLibraryEntryAddress
886-
)
886+
)
887887
#endif
888888
;
889889
}

lib/Runtime/Language/JavascriptStackWalker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ namespace Js
231231
bool GetSourcePosition(const WCHAR** sourceFileName, ULONG* line, LONG* column);
232232

233233
static bool TryIsTopJavaScriptFrameNative(ScriptContext* scriptContext, bool* istopFrameNative, bool ignoreLibraryCode = false);
234+
static bool AlignAndCheckAddressOfReturnAddressMatch(void* addressOfReturnAddress, void* nativeLibraryEntryAddress);
234235

235236
#if ENABLE_NATIVE_CODEGEN
236237
void ClearCachedInternalFrameInfo();

0 commit comments

Comments
 (0)