Skip to content

Commit ac67ca2

Browse files
committed
change recent FailFasts to use ReportFatalException
1 parent 7266bf7 commit ac67ca2

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

lib/Common/Exceptions/ReportError.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,16 @@ __declspec(noinline) void FromDOM_NoScriptScope_fatal_error()
106106
ReportFatalException(NULL, E_UNEXPECTED, EnterScript_FromDOM_NoScriptScope, scenario);
107107
}
108108

109+
__declspec(noinline) void EntryExitRecord_Corrupted_fatal_error()
110+
{
111+
int scenario = 6;
112+
ReportFatalException(NULL, E_UNEXPECTED, Fatal_EntryExitRecordCorruption, scenario);
113+
}
114+
115+
__declspec(noinline) void UnexpectedExceptionHandling_fatal_error(EXCEPTION_POINTERS * originalException)
116+
{
117+
int scenario = 7;
118+
ReportFatalException(NULL, E_UNEXPECTED, Fatal_UnexpectedExceptionHandling, scenario);
119+
}
120+
109121
#pragma optimize("",on)

lib/Common/Exceptions/ReportError.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ enum ErrorReason
1919
MarkStack_OUTOFMEMORY = 11,
2020
EnterScript_FromDOM_NoScriptScope = 12,
2121
Fatal_FailedToBox_OUTOFMEMORY = 13,
22-
Fatal_Recycler_MemoryCorruption = 14
22+
Fatal_Recycler_MemoryCorruption = 14,
23+
Fatal_EntryExitRecordCorruption = 15,
24+
Fatal_UnexpectedExceptionHandling = 16
2325
};
2426

2527
extern "C" void ReportFatalException(
@@ -52,6 +54,8 @@ void MarkStack_OOM_fatal_error();
5254

5355
void Binary_Inconsistency_fatal_error();
5456
void Version_Inconsistency_fatal_error();
57+
void EntryExitRecord_Corrupted_fatal_error();
58+
void UnexpectedExceptionHandling_fatal_error(EXCEPTION_POINTERS * originalException);
5559

5660
#ifdef LARGEHEAPBLOCK_ENCODING
5761
void LargeHeapBlock_Metadata_Corrupted(

lib/Runtime/Base/ThreadContext.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,9 +1874,9 @@ ThreadContext::PushEntryExitRecord(Js::ScriptEntryExitRecord * record)
18741874
record->next = lastRecord;
18751875

18761876
// 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)
1877+
if (!IsOnStack(lastRecord) || (uintptr_t)record >= (uintptr_t)lastRecord)
18781878
{
1879-
RaiseFailFastException(nullptr, nullptr, 0);
1879+
EntryExitRecord_Corrupted_fatal_error();
18801880
}
18811881
}
18821882

@@ -1888,12 +1888,13 @@ void ThreadContext::PopEntryExitRecord(Js::ScriptEntryExitRecord * record)
18881888
AssertMsg(record && record == this->entryExitRecord, "Mismatch script entry/exit");
18891889

18901890
// 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)
1891+
Js::ScriptEntryExitRecord * next = this->entryExitRecord->next;
1892+
if (next && (!IsOnStack(next) || (uintptr_t)this->entryExitRecord >= (uintptr_t)next))
18921893
{
1893-
RaiseFailFastException(nullptr, nullptr, 0);
1894+
EntryExitRecord_Corrupted_fatal_error();
18941895
}
18951896

1896-
this->entryExitRecord = this->entryExitRecord->next;
1897+
this->entryExitRecord = next;
18971898
}
18981899

18991900
BOOL ThreadContext::ReserveStaticTypeIds(__in int first, __in int last)

lib/Runtime/Library/JavascriptFunction.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,8 @@ namespace Js
642642
// 0xE06D7363 is C++ exception code
643643
if (exceptionCode != 0 && !IsDebuggerPresent() && exceptionCode != 0xE06D7363 && exceptionAction != EXCEPTION_CONTINUE_EXECUTION)
644644
{
645-
exceptionInfo;
646-
647645
// 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(nullptr, nullptr, 0);
646+
UnexpectedExceptionHandling_fatal_error(&exceptionInfo);
649647
}
650648
}
651649
//ret should never be null here

0 commit comments

Comments
 (0)