-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fill freed loader heap chunk with non-zero value #12731
Changes from 4 commits
3384270
48e667b
87b2287
66939d1
0c13959
7c63a69
cd6d5ec
63dcb89
03e2ed1
4029d1c
c986ba4
9c97b74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1111,13 +1111,8 @@ UMEntryThunk* UMEntryThunk::CreateUMEntryThunk() | |
|
||
UMEntryThunk * p; | ||
|
||
#ifdef FEATURE_WINDOWSPHONE | ||
// On the phone, use loader heap to save memory commit of regular executable heap | ||
p = (UMEntryThunk *)(void *)SystemDomain::GetGlobalLoaderAllocator()->GetExecutableHeap()->AllocMem(S_SIZE_T(sizeof(UMEntryThunk))); | ||
#else | ||
p = new (executable) UMEntryThunk; | ||
memset (p, 0, sizeof(*p)); | ||
#endif | ||
|
||
RETURN p; | ||
} | ||
|
@@ -1126,11 +1121,10 @@ void UMEntryThunk::Terminate() | |
{ | ||
WRAPPER_NO_CONTRACT; | ||
|
||
#ifdef FEATURE_WINDOWSPHONE | ||
SystemDomain::GetGlobalLoaderAllocator()->GetExecutableHeap()->BackoutMem(this, sizeof(UMEntryThunk)); | ||
#else | ||
DeleteExecutable(this); | ||
#endif | ||
|
||
_ASSERTE(SystemDomain::GetGlobalLoaderAllocator()->GetExecutableHeap()->IsRelaxed()); | ||
FillMemory(&m_code, sizeof(m_code), 0xcc); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other thread can allocate the block at this point. This needs to be done before the call to BackoutMem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0xCC works well for x86 because of it is code for the breakpoint instruction. What does it do on arm? |
||
} | ||
|
||
VOID UMEntryThunk::FreeUMEntryThunk(UMEntryThunk* p) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -893,7 +893,7 @@ void LoaderAllocator::ActivateManagedTracking() | |
#define COLLECTIBLE_CODEHEAP_SIZE (7 * GetOsPageSize()) | ||
#define COLLECTIBLE_VIRTUALSTUBDISPATCH_HEAP_SPACE (5 * GetOsPageSize()) | ||
|
||
void LoaderAllocator::Init(BaseDomain *pDomain, BYTE *pExecutableHeapMemory) | ||
void LoaderAllocator::Init(BaseDomain *pDomain, BYTE *pExecutableHeapMemory, BOOL fRelaxed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method should not take the flag. |
||
{ | ||
STANDARD_VM_CONTRACT; | ||
|
||
|
@@ -1005,7 +1005,8 @@ void LoaderAllocator::Init(BaseDomain *pDomain, BYTE *pExecutableHeapMemory) | |
dwExecutableHeapReserveSize, | ||
LOADERHEAP_PROFILE_COUNTER, | ||
NULL, | ||
TRUE /* Make heap executable */); | ||
TRUE /* Make heap executable */, | ||
fRelaxed); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be false unconditionally. |
||
initReservedMem += dwExecutableHeapReserveSize; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this flag fZeroInit = TRUE to make it clear what it does.