Skip to content

Commit 7a751b0

Browse files
Fix code heap reservation size (#59918)
When I've moved the heap metadata out of the actual code heaps some time ago, I've forgotten to account for the personality routine slot allocated at the beginning of the heaps. This was exposed by an assert when executing under the JIT stress mode 2. This change fixes it by adding accounting for those. Close #59794 Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
1 parent 1b80b06 commit 7a751b0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/coreclr/vm/codeman.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,6 +2412,11 @@ HeapList* EEJitManager::NewCodeHeap(CodeHeapRequestInfo *pInfo, DomainCodeHeapLi
24122412
#endif
24132413

24142414
size_t reserveSize = initialRequestSize;
2415+
2416+
#if defined(TARGET_AMD64) || defined(TARGET_ARM64)
2417+
reserveSize += JUMP_ALLOCATE_SIZE;
2418+
#endif
2419+
24152420
if (reserveSize < minReserveSize)
24162421
reserveSize = minReserveSize;
24172422
reserveSize = ALIGN_UP(reserveSize, VIRTUAL_ALLOC_RESERVE_GRANULARITY);

src/coreclr/vm/dynamicmethod.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,11 @@ HeapList* HostCodeHeap::InitializeHeapList(CodeHeapRequestInfo *pInfo)
398398

399399
// Add TrackAllocation, HeapList and very conservative padding to make sure we have enough for the allocation
400400
ReserveBlockSize += sizeof(TrackAllocation) + HOST_CODEHEAP_SIZE_ALIGN + 0x100;
401+
402+
#if defined(TARGET_AMD64) || defined(TARGET_ARM64)
403+
ReserveBlockSize += JUMP_ALLOCATE_SIZE;
404+
#endif
405+
401406
// reserve ReserveBlockSize rounded-up to VIRTUAL_ALLOC_RESERVE_GRANULARITY of memory
402407
ReserveBlockSize = ALIGN_UP(ReserveBlockSize, VIRTUAL_ALLOC_RESERVE_GRANULARITY);
403408

0 commit comments

Comments
 (0)