-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Regions] pCorProfilerInfo->GetObjectGeneration may fail when running under USE_REGIONS #55965
Comments
Tagging subscribers to this area: @dotnet/gc Issue DetailsThis is a bug found when working on the filtering issue. Problem: The crux of the issue is that under USE_REGIONS, the GC may use some unseen memory address since the last GC during allocation. In particular, in Repro:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "gcallocateprofiler.h"
GUID GCAllocateProfiler::GetClsid()
{
// {55b9554d-6115-45a2-be1e-c80f7fa35369}
GUID clsid = { 0x55b9554d, 0x6115, 0x45a2,{ 0xbe, 0x1e, 0xc8, 0x0f, 0x7f, 0xa3, 0x53, 0x69 } };
return clsid;
}
HRESULT GCAllocateProfiler::Initialize(IUnknown* pICorProfilerInfoUnk)
{
Profiler::Initialize(pICorProfilerInfoUnk);
HRESULT hr = S_OK;
if (FAILED(hr = pCorProfilerInfo->SetEventMask2(COR_PRF_ENABLE_OBJECT_ALLOCATED | COR_PRF_MONITOR_OBJECT_ALLOCATED, COR_PRF_HIGH_BASIC_GC)))
{
printf("FAIL: ICorProfilerInfo::SetEventMask2() failed hr=0x%x", hr);
return hr;
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE GCAllocateProfiler::ObjectAllocated(ObjectID objectId, ClassID classId)
{
COR_PRF_GC_GENERATION_RANGE gen;
HRESULT hr = pCorProfilerInfo->GetObjectGeneration(objectId, &gen);
if (FAILED(hr))
{
assert (false);
printf("GetObjectGeneration failed hr=0x%x\n", hr);
_failures++;
}
else if (gen.generation == COR_PRF_GC_LARGE_OBJECT_HEAP)
{
_gcLOHAllocations++;
}
else if (gen.generation == COR_PRF_GC_PINNED_OBJECT_HEAP)
{
_gcPOHAllocations++;
}
else
{
_failures++;
}
return S_OK;
}
HRESULT GCAllocateProfiler::Shutdown()
{
Profiler::Shutdown();
if (_gcPOHAllocations == 0)
{
printf("There is no POH allocations\n");
}
else if (_gcLOHAllocations == 0)
{
printf("There is no LOH allocations\n");
}
else if (_failures == 0)
{
printf("%d LOH objects allocated\n", (int)_gcLOHAllocations);
printf("%d POH objects allocated\n", (int)_gcPOHAllocations);
printf("PROFILER TEST PASSES\n");
}
fflush(stdout);
return S_OK;
} The bug can then be reproduced by setting these environment,
and run GCPerfSim with these parameters:
|
This is a bug found when working on the filtering issue.
Problem:
The crux of the issue is that under USE_REGIONS, the GC may use some unseen memory address since the last GC during allocation. In particular, in
soh_try_fit
, it may use theget_new_region
method to acquire a new region, chain it to the end of gen0 and allocate the object there. At that point of time, thes_currentGenerationTable
maintained by the profiler is unaware of those new addresses, therefore during theObjectAllocated
callback,GetObjectGeneration
for that newly allocated object would fail.Repro:
The profiler authored for the
gcallocate
test can be repurposed to reproduce this bug. Here is the modified code. It does 3 different things:The bug can then be reproduced by setting these environment,
and run GCPerfSim with these parameters:
The text was updated successfully, but these errors were encountered: