Skip to content

Commit 6bfd058

Browse files
authored
fix the size passed to grow_heap_segment (#103998)
in loh_allocate_in_condemned we call grow_heap_segment with 2x loh_padding_obj_size while in loh_size_fit_p it specifically says one padding if it's at the end of the segment. while going from the amount of 1 padding to 2 isn't a big deal from grow_heap_segments POV it introduces an inconsistency between loh_size_fit_p and grow_heap_segment because the former will say fit but the latter will give it a size that does not fit. this triggers the assert - assert (high_address <= heap_segment_reserved (seg)); because high_address is 0x20 (pad size) higher than reserved. in retail builds this would just return FALSE if we are right at the end of the segment which is also a problem.
1 parent f696eb3 commit 6bfd058

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30812,10 +30812,7 @@ uint8_t* gc_heap::loh_allocate_in_condemned (size_t size)
3081230812
else
3081330813
{
3081430814
if (loh_size_fit_p (size, generation_allocation_pointer (gen), heap_segment_reserved (seg), true) &&
30815-
// We are overestimating here by padding with 2 loh_padding_obj_size objects which we shouldn't need
30816-
// to do if it's at the end of the region. However, grow_heap_segment is already overestimating by
30817-
// a lot more - it would be worth fixing when we are in extreme low memory situations.
30818-
(grow_heap_segment (seg, (generation_allocation_pointer (gen) + size + 2* AlignQword (loh_padding_obj_size)))))
30815+
(grow_heap_segment (seg, (generation_allocation_pointer (gen) + size + AlignQword (loh_padding_obj_size)))))
3081930816
{
3082030817
dprintf (1235, ("growing seg from %p to %p\n", heap_segment_committed (seg),
3082130818
(generation_allocation_pointer (gen) + size)));

0 commit comments

Comments
 (0)