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

fixing an assert in GetGCMemoryInfo #87848

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
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
29 changes: 16 additions & 13 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50271,22 +50271,25 @@ void GCHeap::GetMemoryInfo(uint64_t* highMemLoadThresholdBytes,
}

#ifdef _DEBUG
if ((gc_kind)kind == gc_kind_ephemeral)
{
assert (last_gc_info->condemned_generation < max_generation);
}
else if ((gc_kind)kind == gc_kind_full_blocking)
if (VolatileLoadWithoutBarrier (&last_gc_info->index) != 0)
{
assert (last_gc_info->condemned_generation == max_generation);
assert (last_gc_info->concurrent == false);
}
if ((gc_kind)kind == gc_kind_ephemeral)
{
assert (last_gc_info->condemned_generation < max_generation);
}
else if ((gc_kind)kind == gc_kind_full_blocking)
{
assert (last_gc_info->condemned_generation == max_generation);
assert (last_gc_info->concurrent == false);
}
#ifdef BACKGROUND_GC
else if ((gc_kind)kind == gc_kind_background)
{
assert (last_gc_info->condemned_generation == max_generation);
assert (last_gc_info->concurrent == true);
}
else if ((gc_kind)kind == gc_kind_background)
{
assert (last_gc_info->condemned_generation == max_generation);
assert (last_gc_info->concurrent == true);
}
#endif //BACKGROUND_GC
}
#endif //_DEBUG
}

Expand Down
4 changes: 4 additions & 0 deletions src/tests/GC/API/GC/GetGCMemoryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public static int Main()
// We will keep executing the test in case of a failure to see if we have multiple failures.
bool isTestSucceeded = true;

// Before any GCs happen, this should not assert
GCMemoryInfo memoryInfoNoGC = GC.GetGCMemoryInfo(GCKind.Background);
Console.WriteLine("BGC index is {0}", memoryInfoNoGC.Index);

try
{
GCMemoryInfo memoryInfoInvalid = GC.GetGCMemoryInfo((GCKind)(-1));
Expand Down