Skip to content

Commit

Permalink
Fix corner-case accounting bug in new codeheap allocation (#107492)
Browse files Browse the repository at this point in the history
The size of internal CodeHeap structures was not included in
codeheap memory reservation. It caused false OOM exception to
be thrown when JITed method code size was near 64kB multiple
  • Loading branch information
jkotas authored Sep 8, 2024
1 parent 10f6c4c commit 39c84a3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2376,6 +2376,16 @@ HeapList* LoaderCodeHeap::CreateCodeHeap(CodeHeapRequestInfo *pInfo, LoaderHeap
}
else
{
// Include internal CodeHeap structures in the reserve
allocationSize = ALIGN_UP(allocationSize, VIRTUAL_ALLOC_RESERVE_GRANULARITY);
reserveSize = max(reserveSize, allocationSize);

if (reserveSize != (DWORD) reserveSize)
{
_ASSERTE(!"reserveSize does not fit in a DWORD");
EEPOLICY_HANDLE_FATAL_ERROR(COR_E_EXECUTIONENGINE);
}

if (loAddr != NULL || hiAddr != NULL)
{
#ifdef _DEBUG
Expand Down

0 comments on commit 39c84a3

Please sign in to comment.