Skip to content

Commit 7266bf7

Browse files
committed
add failfast if entryExitRecord list is messed up
1 parent 63febdb commit 7266bf7

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,12 @@ ThreadContext::PushEntryExitRecord(Js::ScriptEntryExitRecord * record)
18721872
Assert(lastRecord->leaveForHost || lastRecord->leaveForAsyncHostOperation);
18731873
lastRecord->hasReentered = true;
18741874
record->next = lastRecord;
1875+
1876+
// these are on stack, which grows down. if this condition doesn't hold, then the list somehow got messed up
1877+
if ((uintptr_t)record > (uintptr_t)lastRecord)
1878+
{
1879+
RaiseFailFastException(nullptr, nullptr, 0);
1880+
}
18751881
}
18761882

18771883
this->entryExitRecord = record;
@@ -1881,6 +1887,12 @@ void ThreadContext::PopEntryExitRecord(Js::ScriptEntryExitRecord * record)
18811887
{
18821888
AssertMsg(record && record == this->entryExitRecord, "Mismatch script entry/exit");
18831889

1890+
// these are on stack, which grows down. if this condition doesn't hold, then the list somehow got messed up
1891+
if (this->entryExitRecord->next && (uintptr_t)this->entryExitRecord > (uintptr_t)this->entryExitRecord->next)
1892+
{
1893+
RaiseFailFastException(nullptr, nullptr, 0);
1894+
}
1895+
18841896
this->entryExitRecord = this->entryExitRecord->next;
18851897
}
18861898

lib/Runtime/Library/JavascriptFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ namespace Js
645645
exceptionInfo;
646646

647647
// ensure that hosts are not doing SEH across Chakra frames, as that can lead to bad state (e.g. destructors not being called)
648-
RaiseFailFastException(NULL, NULL, NULL);
648+
RaiseFailFastException(nullptr, nullptr, 0);
649649
}
650650
}
651651
//ret should never be null here

0 commit comments

Comments
 (0)