-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[x86/Linux] Add Dummy Exception Handler #8613
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,37 @@ class Thread; | |
// Actually, the handler getting set is properly registered | ||
#endif | ||
|
||
#ifdef FEATURE_PAL | ||
|
||
extern VOID SetSEHRecord(PEXCEPTION_REGISTRATION_RECORD record); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder - what if we just defined implemented __writefsdword and __readfsdword for FEATURE_PAL and put the implementation to the unixstubs.cpp? Then the change in this file could be minimalized to just adding declaration of the two functions if FEATURE_PAL is defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I once tried that, but failed. Clang recognizes The implementation of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I haven't realized that these functions are defined. Let's leave it as it is then. |
||
extern VOID ResetSEHRecord(PEXCEPTION_REGISTRATION_RECORD record); | ||
|
||
#define INSTALL_SEH_RECORD(record) \ | ||
SetSEHRecord(record); \ | ||
|
||
#define UNINSTALL_SEH_RECORD(record) \ | ||
ResetSEHRecord(record); | ||
|
||
#else // FEATURE_PAL | ||
|
||
#define INSTALL_SEH_RECORD(record) \ | ||
{ \ | ||
(record)->Next = (PEXCEPTION_REGISTRATION_RECORD)__readfsdword(0); \ | ||
__writefsdword(0, (DWORD) (record)); \ | ||
} | ||
|
||
#define UNINSTALL_SEH_RECORD(record) \ | ||
{ \ | ||
__writefsdword(0, (DWORD) ((record)->Next)); \ | ||
} | ||
|
||
#endif // FEATURE_PAL | ||
|
||
#define INSTALL_EXCEPTION_HANDLING_RECORD(record) \ | ||
{ \ | ||
PEXCEPTION_REGISTRATION_RECORD __record = (record); \ | ||
_ASSERTE(__record < GetCurrentSEHRecord()); \ | ||
__record->Next = (PEXCEPTION_REGISTRATION_RECORD)__readfsdword(0); \ | ||
__writefsdword(0, (DWORD)__record); \ | ||
INSTALL_SEH_RECORD(record); \ | ||
} | ||
|
||
// | ||
|
@@ -44,7 +69,7 @@ class Thread; | |
{ \ | ||
PEXCEPTION_REGISTRATION_RECORD __record = (record); \ | ||
_ASSERTE(__record == GetCurrentSEHRecord()); \ | ||
__writefsdword(0, (DWORD)__record->Next); \ | ||
UNINSTALL_SEH_RECORD(record); \ | ||
} | ||
|
||
// stackOverwriteBarrier is used to detect overwriting of stack which will mess up handler registration | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1971,11 +1971,17 @@ PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(CONTEXT * pContext) | |
} | ||
|
||
#if !defined(DACCESS_COMPILE) | ||
#ifdef FEATURE_PAL | ||
static PEXCEPTION_REGISTRATION_RECORD CurrentSEHRecord = EXCEPTION_CHAIN_END; | ||
#endif | ||
|
||
PEXCEPTION_REGISTRATION_RECORD GetCurrentSEHRecord() | ||
{ | ||
WRAPPER_NO_CONTRACT; | ||
|
||
#ifdef FEATURE_PAL | ||
LPVOID fs0 = CurrentSEHRecord; | ||
#else // FEATURE_PAL | ||
LPVOID fs0 = (LPVOID)__readfsdword(0); | ||
|
||
#if 0 // This walk is too expensive considering we hit it every time we a CONTRACT(NOTHROW) | ||
|
@@ -2006,11 +2012,26 @@ PEXCEPTION_REGISTRATION_RECORD GetCurrentSEHRecord() | |
pEHR = pEHR->Next; | ||
} | ||
#endif | ||
#endif | ||
#endif // 0 | ||
#endif // FEATURE_PAL | ||
|
||
return (EXCEPTION_REGISTRATION_RECORD*) fs0; | ||
} | ||
|
||
#ifdef FEATURE_PAL | ||
VOID SetSEHRecord(PEXCEPTION_REGISTRATION_RECORD record) | ||
{ | ||
WRAPPER_NO_CONTRACT; | ||
record->Next = CurrentSEHRecord; | ||
CurrentSEHRecord = record; | ||
} | ||
|
||
VOID ResetSEHRecord(PEXCEPTION_REGISTRATION_RECORD record) | ||
{ | ||
CurrentSEHRecord = record->Next; | ||
} | ||
#endif // FEATURE_PAL | ||
|
||
PEXCEPTION_REGISTRATION_RECORD GetFirstCOMPlusSEHRecord(Thread *pThread) { | ||
WRAPPER_NO_CONTRACT; | ||
#ifndef FEATURE_PAL | ||
|
@@ -3748,4 +3769,10 @@ AdjustContextForVirtualStub( | |
return TRUE; | ||
} | ||
|
||
#ifdef FEATURE_PAL | ||
VOID DECLSPEC_NORETURN DispatchManagedException(PAL_SEHException& ex, bool isHardwareException) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this function? It is only used for WIN64EXCEPTIONS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current definition of
For me, the use of Please let me know which one would be better: revise the macro or add a dummy dispatcher. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I guess the dummy dispatcher will be easier to remove once we move to WIN64EXCEPTIONS in the future. But I would recommend not to implement is as throw, but rather put in a DebugBreak();. The throw cannot work in most of the cases since it would hit managed frames where the C++ exception handling would get lost. So it would be better to break into the debugger or crash right on the spot if there is no debugger attached. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, please use that. |
||
{ | ||
UNREACHABLE(); | ||
} | ||
#endif | ||
#endif // !DACCESS_COMPILE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By mistake, I was working on a bit old branch. I reverted this macro to make it easy to move on WIN64EXCEPTIONS.