Skip to content

Commit

Permalink
Fix WER handler on Windows (#106217)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikem8361 authored Aug 10, 2024
1 parent 46c0166 commit bcca12c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extern "C" bool TryGetSymbol(ICorDebugDataTarget* dataTarget, uint64_t baseAddre
#define CAN_USE_CDAC
#endif

extern TADDR g_ClrModuleBase;

#include "dwbucketmanager.hpp"
#include "gcinterface.dac.h"

Expand Down Expand Up @@ -5531,6 +5533,15 @@ ClrDataAccess::Initialize(void)
// Do some validation
IfFailRet(VerifyDlls());

// To support EH SxS, utilcode requires the base address of the runtime as part of its initialization
// so that functions like "WasThrownByUs" work correctly since they use the CLR base address to check
// if an exception was raised by a given instance of the runtime or not.
//
// Thus, when DAC is initialized, initialize utilcode with the base address of the runtime loaded in the
// target process. This is similar to work done in CorDB::SetTargetCLR for mscordbi.

g_ClrModuleBase = m_globalBase; // Base address of the runtime in the target process

return S_OK;
}

Expand Down
13 changes: 13 additions & 0 deletions src/coreclr/utilcode/clrhost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
static void* pImageBase = NULL;
#endif

#ifdef DACCESS_COMPILE

TADDR g_ClrModuleBase;

void* GetClrModuleBase()
{
return (void*)g_ClrModuleBase;
}

#else // DACCESS_COMPILE

void* GetClrModuleBase()
{
LIMITED_METHOD_CONTRACT;
Expand All @@ -37,6 +48,8 @@ void* GetClrModuleBase()
#endif // HOST_WINDOWS
}

#endif // DACCESS_COMPILE

thread_local int t_CantAllocCount;

DWORD GetClrModulePathName(SString& buffer)
Expand Down

0 comments on commit bcca12c

Please sign in to comment.