Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
[x86/Linux] Adds Dummy Exception Handler (#8613)
Browse files Browse the repository at this point in the history
This commit adds a dummy exeption handler to enable x86/Linux build.

This commit also reverts 7b92136 to make it easy to enable
WIN64EXCEPTIONS in x86/Linux.
  • Loading branch information
parjong authored and janvorli committed Dec 14, 2016
1 parent 3019808 commit 676216a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/vm/exceptmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ VOID DECLSPEC_NORETURN RaiseTheExceptionInternalOnly(OBJECTREF throwable, BOOL r
void UnwindAndContinueRethrowHelperInsideCatch(Frame* pEntryFrame, Exception* pException);
VOID DECLSPEC_NORETURN UnwindAndContinueRethrowHelperAfterCatch(Frame* pEntryFrame, Exception* pException);

#if defined(FEATURE_PAL) && defined(WIN64EXCEPTIONS)
#ifdef FEATURE_PAL
VOID DECLSPEC_NORETURN DispatchManagedException(PAL_SEHException& ex, bool isHardwareException);

#define INSTALL_MANAGED_EXCEPTION_DISPATCHER \
Expand Down Expand Up @@ -334,14 +334,14 @@ VOID DECLSPEC_NORETURN DispatchManagedException(PAL_SEHException& ex, bool isHar
UNREACHABLE(); \
}

#else // FEATURE_PAL && WIN64EXCEPTIONS
#else // FEATURE_PAL

#define INSTALL_MANAGED_EXCEPTION_DISPATCHER
#define UNINSTALL_MANAGED_EXCEPTION_DISPATCHER
#define INSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP
#define UNINSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP

#endif // FEATURE_PAL && WIN64EXCEPTIONS
#endif // FEATURE_PAL

#define INSTALL_UNWIND_AND_CONTINUE_HANDLER_NO_PROBE \
{ \
Expand Down
31 changes: 28 additions & 3 deletions src/vm/i386/excepcpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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); \
}

//
Expand All @@ -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
Expand Down
29 changes: 28 additions & 1 deletion src/vm/i386/excepx86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -3748,4 +3769,10 @@ AdjustContextForVirtualStub(
return TRUE;
}

#ifdef FEATURE_PAL
VOID DECLSPEC_NORETURN DispatchManagedException(PAL_SEHException& ex, bool isHardwareException)
{
UNREACHABLE();
}
#endif
#endif // !DACCESS_COMPILE

0 comments on commit 676216a

Please sign in to comment.