Skip to content

Commit 33204f6

Browse files
authored
Fix code heap reservation size (#59883)
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
1 parent aef2040 commit 33204f6

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/coreclr/vm/codeman.cpp

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

24082408
size_t reserveSize = initialRequestSize;
2409+
2410+
#if defined(TARGET_AMD64) || defined(TARGET_ARM64)
2411+
reserveSize += JUMP_ALLOCATE_SIZE;
2412+
#endif
2413+
24092414
if (reserveSize < minReserveSize)
24102415
reserveSize = minReserveSize;
24112416
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)