Skip to content

Commit 9f1cab7

Browse files
authored
Remove obsolete NativeExceptionHolder (#121315)
This holder was used for the old EH on Unix. Now that the old EH has been removed from the runtime quite some time ago, it is of no use anymore. This change removes it.
1 parent 38154f0 commit 9f1cab7

File tree

5 files changed

+1
-193
lines changed

5 files changed

+1
-193
lines changed

src/coreclr/dlls/mscordac/mscordac_unixexports.src

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ nativeStringResourceTable_mscorrc
3030
#PAL_GetTransportName
3131
#PAL_GetCurrentThread
3232
#PAL_GetCpuLimit
33-
#PAL_GetNativeExceptionHolderHead
3433
#PAL_GetPalHostModule
3534
#PAL_GetSymbolModuleBase
3635
#PAL_GetTransportPipeName

src/coreclr/inc/ex.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
#ifdef HOST_UNIX
99
#define EX_TRY_HOLDER \
10-
HardwareExceptionHolder \
11-
NativeExceptionHolderCatchAll __exceptionHolder; \
12-
__exceptionHolder.Push(); \
10+
HardwareExceptionHolder
1311

1412
#else // HOST_UNIX
1513
#define EX_TRY_HOLDER

src/coreclr/pal/inc/pal.h

Lines changed: 0 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -3916,141 +3916,6 @@ class CatchHardwareExceptionHolder
39163916
#define HardwareExceptionHolder
39173917
#endif // FEATURE_ENABLE_HARDWARE_EXCEPTIONS
39183918

3919-
class NativeExceptionHolderBase;
3920-
3921-
PALIMPORT
3922-
PALAPI
3923-
NativeExceptionHolderBase **
3924-
PAL_GetNativeExceptionHolderHead();
3925-
3926-
extern "C++" {
3927-
3928-
//
3929-
// This is the base class of native exception holder used to provide
3930-
// the filter function to the exception dispatcher. This allows the
3931-
// filter to be called during the first pass to better emulate SEH
3932-
// the xplat platforms that only have C++ exception support.
3933-
//
3934-
class NativeExceptionHolderBase
3935-
{
3936-
// Save the address of the holder head so the destructor
3937-
// doesn't have access the slow (on Linux) TLS value again.
3938-
NativeExceptionHolderBase **m_head;
3939-
3940-
// The next holder on the stack
3941-
NativeExceptionHolderBase *m_next;
3942-
3943-
protected:
3944-
NativeExceptionHolderBase()
3945-
{
3946-
m_head = nullptr;
3947-
m_next = nullptr;
3948-
}
3949-
3950-
~NativeExceptionHolderBase()
3951-
{
3952-
// Only destroy if Push was called
3953-
if (m_head != nullptr)
3954-
{
3955-
*m_head = m_next;
3956-
m_head = nullptr;
3957-
m_next = nullptr;
3958-
}
3959-
}
3960-
3961-
public:
3962-
// Calls the holder's filter handler.
3963-
virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex) = 0;
3964-
3965-
// Adds the holder to the "stack" of holders. This is done explicitly instead
3966-
// of in the constructor was to avoid the mess of move constructors combined
3967-
// with return value optimization (in CreateHolder).
3968-
void Push()
3969-
{
3970-
NativeExceptionHolderBase **head = PAL_GetNativeExceptionHolderHead();
3971-
m_head = head;
3972-
m_next = *head;
3973-
*head = this;
3974-
}
3975-
3976-
// Given the currentHolder and locals stack range find the next holder starting with this one
3977-
// To find the first holder, pass nullptr as the currentHolder.
3978-
static NativeExceptionHolderBase *FindNextHolder(NativeExceptionHolderBase *currentHolder, PVOID frameLowAddress, PVOID frameHighAddress);
3979-
};
3980-
3981-
//
3982-
// This is the second part of the native exception filter holder. It is
3983-
// templated because the lambda used to wrap the exception filter is a
3984-
// unknown type.
3985-
//
3986-
template<class FilterType>
3987-
class NativeExceptionHolder : public NativeExceptionHolderBase
3988-
{
3989-
FilterType* m_exceptionFilter;
3990-
3991-
public:
3992-
NativeExceptionHolder(FilterType* exceptionFilter)
3993-
: NativeExceptionHolderBase()
3994-
{
3995-
m_exceptionFilter = exceptionFilter;
3996-
}
3997-
3998-
virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex)
3999-
{
4000-
return (*m_exceptionFilter)(ex);
4001-
}
4002-
};
4003-
4004-
//
4005-
// This is a native exception holder that is used when the catch catches
4006-
// all exceptions.
4007-
//
4008-
class NativeExceptionHolderCatchAll : public NativeExceptionHolderBase
4009-
{
4010-
4011-
public:
4012-
NativeExceptionHolderCatchAll()
4013-
: NativeExceptionHolderBase()
4014-
{
4015-
}
4016-
4017-
virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex)
4018-
{
4019-
return EXCEPTION_EXECUTE_HANDLER;
4020-
}
4021-
};
4022-
4023-
// This is a native exception holder that doesn't catch any exceptions.
4024-
class NativeExceptionHolderNoCatch : public NativeExceptionHolderBase
4025-
{
4026-
4027-
public:
4028-
NativeExceptionHolderNoCatch()
4029-
: NativeExceptionHolderBase()
4030-
{
4031-
}
4032-
4033-
virtual EXCEPTION_DISPOSITION InvokeFilter(PAL_SEHException& ex)
4034-
{
4035-
return EXCEPTION_CONTINUE_SEARCH;
4036-
}
4037-
};
4038-
4039-
//
4040-
// This factory class for the native exception holder is necessary because
4041-
// templated functions don't need the explicit type parameter and can infer
4042-
// the template type from the parameter.
4043-
//
4044-
class NativeExceptionHolderFactory
4045-
{
4046-
public:
4047-
template<class FilterType>
4048-
static NativeExceptionHolder<FilterType> CreateHolder(FilterType* exceptionFilter)
4049-
{
4050-
return NativeExceptionHolder<FilterType>(exceptionFilter);
4051-
}
4052-
};
4053-
40543919
// Start of a try block for exceptions raised by RaiseException
40553920
#define PAL_TRY(__ParamType, __paramDef, __paramRef) \
40563921
{ \
@@ -4078,8 +3943,6 @@ class NativeExceptionHolderFactory
40783943
try \
40793944
{ \
40803945
HardwareExceptionHolder \
4081-
auto __exceptionHolder = NativeExceptionHolderFactory::CreateHolder(&exceptionFilter); \
4082-
__exceptionHolder.Push(); \
40833946
tryBlock(__param); \
40843947
} \
40853948
catch (PAL_SEHException& ex) \
@@ -4268,10 +4131,6 @@ class NativeExceptionHolderFactory
42684131

42694132
#define HRESULT_FROM_NT(x) ((HRESULT) ((x) | FACILITY_NT_BIT))
42704133

4271-
#ifdef __cplusplus
4272-
}
4273-
#endif
4274-
42754134
#ifndef TARGET_WASM
42764135
#define _ReturnAddress() __builtin_return_address(0)
42774136
#else

src/coreclr/pal/src/exception/seh.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -365,37 +365,4 @@ bool CatchHardwareExceptionHolder::IsEnabled()
365365
return pThread ? pThread->IsHardwareExceptionsEnabled() : false;
366366
}
367367

368-
/*++
369-
370-
NativeExceptionHolderBase implementation
371-
372-
--*/
373-
374-
static thread_local NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr;
375-
376-
extern "C"
377-
NativeExceptionHolderBase **
378-
PAL_GetNativeExceptionHolderHead()
379-
{
380-
return &t_nativeExceptionHolderHead;
381-
}
382-
383-
NativeExceptionHolderBase *
384-
NativeExceptionHolderBase::FindNextHolder(NativeExceptionHolderBase *currentHolder, PVOID stackLowAddress, PVOID stackHighAddress)
385-
{
386-
NativeExceptionHolderBase *holder = (currentHolder == nullptr) ? t_nativeExceptionHolderHead : currentHolder->m_next;
387-
388-
while (holder != nullptr)
389-
{
390-
if (((void *)holder >= stackLowAddress) && ((void *)holder < stackHighAddress))
391-
{
392-
return holder;
393-
}
394-
// Get next holder
395-
holder = holder->m_next;
396-
}
397-
398-
return nullptr;
399-
}
400-
401368
#include "seh-unwind.cpp"

src/coreclr/vm/callhelpers.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -468,20 +468,6 @@ void FillInRegTypeMap(int argOffset, CorElementType typ, BYTE * pMap);
468468
/* Macros used to indicate a call to managed code is starting/ending */
469469
/***********************************************************************/
470470

471-
#ifdef TARGET_UNIX
472-
// Install a native exception holder that doesn't catch any exceptions but its presence
473-
// in a stack range of native frames indicates that there was a call from native to
474-
// managed code. It is used by the DispatchManagedException to detect the case when
475-
// the INSTALL_MANAGED_EXCEPTION_DISPATCHER was not at the managed to native boundary.
476-
// For example in the PreStubWorker, which can be called from both native and managed
477-
// code.
478-
#define INSTALL_CALL_TO_MANAGED_EXCEPTION_HOLDER() \
479-
NativeExceptionHolderNoCatch __exceptionHolder; \
480-
__exceptionHolder.Push();
481-
#else // TARGET_UNIX
482-
#define INSTALL_CALL_TO_MANAGED_EXCEPTION_HOLDER()
483-
#endif // TARGET_UNIX
484-
485471
enum EEToManagedCallFlags
486472
{
487473
EEToManagedDefault = 0x0000,
@@ -509,7 +495,6 @@ enum EEToManagedCallFlags
509495
CURRENT_THREAD->HandleThreadAbort(); \
510496
} \
511497
} \
512-
INSTALL_CALL_TO_MANAGED_EXCEPTION_HOLDER(); \
513498
INSTALL_COMPLUS_EXCEPTION_HANDLER_NO_DECLARE();
514499

515500
#define END_CALL_TO_MANAGED() \

0 commit comments

Comments
 (0)