Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 41311 - Assert failure ephemeral_heap_segment->saved_committed == heap_segment_committed #41441

Merged
merged 6 commits into from
Aug 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/coreclr/src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5705,6 +5705,7 @@ void gc_heap::gc_thread_function ()
END_TIMING(suspend_ee_during_log);

proceed_with_gc_p = TRUE;
gradual_decommit_in_progress_p = FALSE;

if (!should_proceed_with_gc())
{
Expand Down Expand Up @@ -11506,6 +11507,15 @@ BOOL gc_heap::grow_heap_segment (heap_segment* seg, uint8_t* high_address, bool*

assert (heap_segment_committed (seg) <= heap_segment_reserved (seg));
assert (high_address <= heap_segment_committed (seg));

#ifdef MULTIPLE_HEAPS
// we should never increase committed beyond decommit target when gradual
// decommit is in progress - if we do, this means commit and decommit are
// going on at the same time.
assert (!gradual_decommit_in_progress_p ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must be missing something - isn't decommit_target smaller than committed? we keep shrinking committed till we reach decommit_tagert when we do the decommit steps.

also when gradual_decommit_in_progress_p is TRUE, shouldn't decommit_target always be non NULL?

nit -

        assert (!gradual_decommit_in_progress_p ||
                 (heap_segment_decommit_target (seg) == nullptr) ||
                 (heap_segment_committed (seg) <= heap_segment_decommit_target (seg)));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some heaps, decommit_target may be bigger than committed, and that's fine - it just means that we won't decommit.

When gradual_decommit_in_progress_p is TRUE, decommit_target will be non NULL for the ephemeral_heap_segment, but may be NULL for other segments - the condition was meant to filter out the other segments. Now that I think about it, I realize this isn't a good test - I should compare against ephemeral_heap_segment directly. So I fixed the assert as follows:

    // we should never increase committed beyond decommit target when gradual
    // decommit is in progress - if we do, this means commit and decommit are
    // going on at the same time.
    assert (!gradual_decommit_in_progress_p ||
            (seg != ephemeral_heap_segment) ||
            (heap_segment_committed (seg) <= heap_segment_decommit_target (seg)));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, I was only thinking about eph seg. and yes the point is if we actually need to commit more, the decommit target had better be bigger otherwise we have a problem. thanks! I agree the new assert looks better.

(seg != ephemeral_heap_segment) ||
(heap_segment_committed (seg) <= heap_segment_decommit_target (seg)));
#endif // MULTIPLE_HEAPS
}

return !!ret;
Expand Down Expand Up @@ -32458,7 +32468,7 @@ void gc_heap::trim_youngest_desired_low_memory()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (settings.concurrent || use_large_pages_p || settings.pause_mode == pause_no_gc) [](start = 4, length = 83)

nit

if (settings.concurrent || use_large_pages_p || (settings.pause_mode == pause_no_gc))

void gc_heap::decommit_ephemeral_segment_pages()
{
if (settings.concurrent || use_large_pages_p)
if (settings.concurrent || use_large_pages_p || (settings.pause_mode == pause_no_gc))
{
return;
}
Expand Down Expand Up @@ -32497,7 +32507,7 @@ void gc_heap::decommit_ephemeral_segment_pages()
decommit_target += target_decrease * 2 / 3;
}

heap_segment_decommit_target(ephemeral_heap_segment) = decommit_target;
heap_segment_decommit_target (ephemeral_heap_segment) = decommit_target;

#ifdef MULTIPLE_HEAPS
if (decommit_target < heap_segment_committed (ephemeral_heap_segment))
Expand Down