Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/coreclr/dlls/mscoree/exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@

#define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS((expr))

#ifdef TARGET_UNIX
#define NO_HOSTING_API_FRAME_ADDRESS ((void*)ULONG_PTR_MAX)
void* g_hostingApiFrameAddress = NO_HOSTING_API_FRAME_ADDRESS;

class HostingApiFrameHolder
{
public:
HostingApiFrameHolder(void* frameAddress)
{
g_hostingApiFrameAddress = frameAddress;
}

~HostingApiFrameHolder()
{
g_hostingApiFrameAddress = NO_HOSTING_API_FRAME_ADDRESS;
}
};
#endif // TARGET_UNIX

// Holder for const wide strings
typedef NewArrayHolder<const WCHAR> ConstWStringHolder;

Expand Down Expand Up @@ -236,6 +255,10 @@ int coreclr_initialize(
PInvokeOverrideFn* pinvokeOverride = nullptr;
host_runtime_contract* hostContract = nullptr;

#ifdef TARGET_UNIX
HostingApiFrameHolder apiFrameHolder(__builtin_frame_address(0));
#endif

ConvertConfigPropertiesToUnicode(
propertyKeys,
propertyValues,
Expand Down Expand Up @@ -465,6 +488,10 @@ int coreclr_execute_assembly(
}
*exitCode = -1;

#ifdef TARGET_UNIX
HostingApiFrameHolder apiFrameHolder(__builtin_frame_address(0));
#endif

ICLRRuntimeHost4* host = reinterpret_cast<ICLRRuntimeHost4*>(hostHandle);

ConstWStringArrayHolder argvW;
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/vm/exceptionhandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4537,6 +4537,8 @@ VOID UnwindManagedExceptionPass2(PAL_SEHException& ex, CONTEXT* unwindStartConte
EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE);
}

extern void* g_hostingApiFrameAddress;

//---------------------------------------------------------------------------------------
//
// This functions performs dispatching of a managed exception.
Expand Down Expand Up @@ -4738,7 +4740,8 @@ VOID DECLSPEC_NORETURN UnwindManagedExceptionPass1(PAL_SEHException& ex, CONTEXT

STRESS_LOG2(LF_EH, LL_INFO100, "Processing exception at native frame: IP = %p, SP = %p \n", controlPc, sp);

if (controlPc == 0)
// Consider the exception unhandled if the unwinding cannot proceed further or if it went past the coreclr_initialize or coreclr_execute_assembly
if ((controlPc == 0) || (sp > (UINT_PTR)g_hostingApiFrameAddress))
{
if (!GetThread()->HasThreadStateNC(Thread::TSNC_ProcessedUnhandledException))
{
Expand Down