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

Collected delegate diagnostic #15809

Merged
merged 4 commits into from
Jan 12, 2018
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
17 changes: 5 additions & 12 deletions src/inc/loaderheap.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ class UnlockedLoaderHeap
SIZE_T dwReservedRegionSize,
size_t *pPrivatePerfCounter_LoaderBytes = NULL,
RangeList *pRangeList = NULL,
BOOL fMakeExecutable = FALSE,
BOOL fZeroInit = TRUE);
BOOL fMakeExecutable = FALSE);

~UnlockedLoaderHeap();
#endif
Expand Down Expand Up @@ -400,8 +399,6 @@ class UnlockedLoaderHeap
}

BOOL IsExecutable();
BOOL IsZeroInit();


public:
#ifdef _DEBUG
Expand Down Expand Up @@ -446,16 +443,14 @@ class LoaderHeap : public UnlockedLoaderHeap, public ILoaderHeapBackout
DWORD dwCommitBlockSize,
size_t *pPrivatePerfCounter_LoaderBytes = NULL,
RangeList *pRangeList = NULL,
BOOL fMakeExecutable = FALSE,
BOOL fZeroInit = TRUE
BOOL fMakeExecutable = FALSE
)
: UnlockedLoaderHeap(dwReserveBlockSize,
dwCommitBlockSize,
NULL, 0,
pPrivatePerfCounter_LoaderBytes,
pRangeList,
fMakeExecutable,
fZeroInit)
fMakeExecutable)
{
WRAPPER_NO_CONTRACT;
m_CriticalSection = NULL;
Expand All @@ -470,17 +465,15 @@ class LoaderHeap : public UnlockedLoaderHeap, public ILoaderHeapBackout
SIZE_T dwReservedRegionSize,
size_t *pPrivatePerfCounter_LoaderBytes = NULL,
RangeList *pRangeList = NULL,
BOOL fMakeExecutable = FALSE,
BOOL fZeroInit = TRUE
BOOL fMakeExecutable = FALSE
)
: UnlockedLoaderHeap(dwReserveBlockSize,
dwCommitBlockSize,
dwReservedRegionAddress,
dwReservedRegionSize,
pPrivatePerfCounter_LoaderBytes,
pRangeList,
fMakeExecutable,
fZeroInit)
fMakeExecutable)
{
WRAPPER_NO_CONTRACT;
m_CriticalSection = NULL;
Expand Down
19 changes: 4 additions & 15 deletions src/utilcode/loaderheap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "eventtracebase.h"

#define LHF_EXECUTABLE 0x1
#define LHF_ZEROINIT 0x2

#ifndef DACCESS_COMPILE

Expand Down Expand Up @@ -906,8 +905,7 @@ UnlockedLoaderHeap::UnlockedLoaderHeap(DWORD dwReserveBlockSize,
SIZE_T dwReservedRegionSize,
size_t *pPrivatePerfCounter_LoaderBytes,
RangeList *pRangeList,
BOOL fMakeExecutable,
BOOL fZeroInit)
BOOL fMakeExecutable)
{
CONTRACTL
{
Expand Down Expand Up @@ -950,9 +948,6 @@ UnlockedLoaderHeap::UnlockedLoaderHeap(DWORD dwReserveBlockSize,
m_Options |= LHF_EXECUTABLE;
#endif // CROSSGEN_COMPILE

if (fZeroInit)
m_Options |= LHF_ZEROINIT;

m_pFirstFreeBlock = NULL;

if (dwReservedRegionAddress != NULL && dwReservedRegionSize > 0)
Expand Down Expand Up @@ -1360,7 +1355,7 @@ void *UnlockedLoaderHeap::UnlockedAllocMem_NoThrow(size_t dwSize
// Don't fill the memory we allocated - it is assumed to be zeroed - fill the memory after it
memset(pAllocatedBytes + dwRequestedSize, 0xEE, LOADER_HEAP_DEBUG_BOUNDARY);
#endif
if ((dwRequestedSize > 0) && (m_Options & LHF_ZEROINIT))
if (dwRequestedSize > 0)
{
_ASSERTE_MSG(pAllocatedBytes[0] == 0 && memcmp(pAllocatedBytes, pAllocatedBytes + 1, dwRequestedSize - 1) == 0,
"LoaderHeap must return zero-initialized memory");
Expand Down Expand Up @@ -1538,8 +1533,7 @@ void UnlockedLoaderHeap::UnlockedBackoutMem(void *pMem,
{
// Cool. This was the last block allocated. We can just undo the allocation instead
// of going to the freelist.
if (m_Options & LHF_ZEROINIT)
memset(pMem, 0x00, dwSize); // Fill freed region with 0
memset(pMem, 0x00, dwSize); // Fill freed region with 0
m_pAllocPtr = (BYTE*)pMem;
}
else
Expand Down Expand Up @@ -1657,7 +1651,7 @@ void *UnlockedLoaderHeap::UnlockedAllocAlignedMem_NoThrow(size_t dwRequestedSiz
memset(pAllocatedBytes + dwRequestedSize, 0xee, LOADER_HEAP_DEBUG_BOUNDARY);
#endif

if ((dwRequestedSize != 0) && (m_Options & LHF_ZEROINIT))
if (dwRequestedSize != 0)
{
_ASSERTE_MSG(pAllocatedBytes[0] == 0 && memcmp(pAllocatedBytes, pAllocatedBytes + 1, dwRequestedSize - 1) == 0,
"LoaderHeap must return zero-initialized memory");
Expand Down Expand Up @@ -1782,11 +1776,6 @@ BOOL UnlockedLoaderHeap::IsExecutable()
return (m_Options & LHF_EXECUTABLE);
}

BOOL UnlockedLoaderHeap::IsZeroInit()
{
return (m_Options & LHF_ZEROINIT);
}

#ifdef DACCESS_COMPILE

void UnlockedLoaderHeap::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
Expand Down
13 changes: 12 additions & 1 deletion src/vm/amd64/cgenamd64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,18 @@ void UMEntryThunkCode::Poison()
}
CONTRACTL_END;

m_movR10[0] = X86_INSTR_INT3;
m_execstub = (BYTE *)UMEntryThunk::ReportViolation;

m_movR10[0] = REX_PREFIX_BASE | REX_OPERAND_SIZE_64BIT;
#ifdef _WIN32
// mov rcx, pUMEntryThunk // 48 b9 xx xx xx xx xx xx xx xx
m_movR10[1] = 0xB9;
#else
// mov rdi, pUMEntryThunk // 48 bf xx xx xx xx xx xx xx xx
m_movR10[1] = 0xBF;
#endif

ClrFlushInstructionCache(&m_movR10[0], &m_jmpRAX[3]-&m_movR10[0]);
}

UMEntryThunk* UMEntryThunk::Decode(LPVOID pCallback)
Expand Down
14 changes: 12 additions & 2 deletions src/vm/arm/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2483,12 +2483,22 @@ void UMEntryThunkCode::Encode(BYTE* pTargetCode, void* pvSecretParam)
FlushInstructionCache(GetCurrentProcess(),&m_code,sizeof(m_code));
}

#ifndef DACCESS_COMPILE

void UMEntryThunkCode::Poison()
{
// Insert 'udf 0xff' at the entry point
m_code[0] = 0xdeff;
m_pTargetCode = (TADDR)UMEntryThunk::ReportViolation;

// ldr r0, [pc + 8]
m_code[0] = 0x4802;
// nop
m_code[1] = 0xbf00;

ClrFlushInstructionCache(&m_code,sizeof(m_code));
}

#endif // DACCESS_COMPILE

///////////////////////////// UNIMPLEMENTED //////////////////////////////////

#ifndef DACCESS_COMPILE
Expand Down
12 changes: 10 additions & 2 deletions src/vm/arm64/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,12 +1268,20 @@ void UMEntryThunkCode::Encode(BYTE* pTargetCode, void* pvSecretParam)
FlushInstructionCache(GetCurrentProcess(),&m_code,sizeof(m_code));
}

#ifndef DACCESS_COMPILE

void UMEntryThunkCode::Poison()
{
// Insert 'brk 0xbe' at the entry point
m_code[0] = 0xd42017c0;
m_pTargetCode = (TADDR)UMEntryThunk::ReportViolation;

// ldp x16, x0, [x12]
m_code[1] = 0xd42017c0;

ClrFlushInstructionCache(&m_code,sizeof(m_code));
}

#endif // DACCESS_COMPILE

#ifdef PROFILING_SUPPORTED
#include "proftoeeinterfaceimpl.h"

Expand Down
Loading