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

[release/7.0] Make sure s_currentGenerationTable is safe for profiler attach #78937

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/coreclr/vm/proftoeeinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ void GenerationTable::Refresh()

// This is the table of generation bounds updated by the gc
// and read by the profiler.
static GenerationTable *s_currentGenerationTable;
static GenerationTable *s_currentGenerationTable = nullptr;

// This is just so we can assert there's a single writer
#ifdef ENABLE_CONTRACTS
Expand Down Expand Up @@ -931,7 +931,6 @@ void __stdcall UpdateGenerationBounds()
// Notify the profiler of start of the collection
if (CORProfilerTrackGC() || CORProfilerTrackBasicGC())
{

if (s_currentGenerationTable == nullptr)
{
EX_TRY
Expand Down Expand Up @@ -965,7 +964,10 @@ void __stdcall ProfilerAddNewRegion(int generation, uint8_t* rangeStart, uint8_t
#ifdef PROFILING_SUPPORTED
if (CORProfilerTrackGC() || CORProfilerTrackBasicGC())
{
s_currentGenerationTable->AddRecord(generation, rangeStart, rangeEnd, rangeEndReserved);
if (s_currentGenerationTable != nullptr)
{
s_currentGenerationTable->AddRecord(generation, rangeStart, rangeEnd, rangeEndReserved);
}
}
#endif // PROFILING_SUPPORTED
RETURN;
Expand Down