Skip to content

Commit

Permalink
fix the size passed to grow_heap_segment (#103998)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Maoni0 authored and pull[bot] committed Jul 15, 2024
1 parent 7d83631 commit 7025697
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30812,10 +30812,7 @@ uint8_t* gc_heap::loh_allocate_in_condemned (size_t size)
else
{
if (loh_size_fit_p (size, generation_allocation_pointer (gen), heap_segment_reserved (seg), true) &&
// We are overestimating here by padding with 2 loh_padding_obj_size objects which we shouldn't need
// to do if it's at the end of the region. However, grow_heap_segment is already overestimating by
// a lot more - it would be worth fixing when we are in extreme low memory situations.
(grow_heap_segment (seg, (generation_allocation_pointer (gen) + size + 2* AlignQword (loh_padding_obj_size)))))
(grow_heap_segment (seg, (generation_allocation_pointer (gen) + size + AlignQword (loh_padding_obj_size)))))
{
dprintf (1235, ("growing seg from %p to %p\n", heap_segment_committed (seg),
(generation_allocation_pointer (gen) + size)));
Expand Down

0 comments on commit 7025697

Please sign in to comment.