Skip to content

Commit 44e68e8

Browse files
Make sure s_currentGenerationTable is safe for profiler attach (#78937)
Co-authored-by: Andrew Au <[email protected]>
1 parent 6f164d1 commit 44e68e8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/coreclr/vm/proftoeeinterfaceimpl.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ void GenerationTable::Refresh()
901901

902902
// This is the table of generation bounds updated by the gc
903903
// and read by the profiler.
904-
static GenerationTable *s_currentGenerationTable;
904+
static GenerationTable *s_currentGenerationTable = nullptr;
905905

906906
// This is just so we can assert there's a single writer
907907
#ifdef ENABLE_CONTRACTS
@@ -931,7 +931,6 @@ void __stdcall UpdateGenerationBounds()
931931
// Notify the profiler of start of the collection
932932
if (CORProfilerTrackGC() || CORProfilerTrackBasicGC())
933933
{
934-
935934
if (s_currentGenerationTable == nullptr)
936935
{
937936
EX_TRY
@@ -965,7 +964,10 @@ void __stdcall ProfilerAddNewRegion(int generation, uint8_t* rangeStart, uint8_t
965964
#ifdef PROFILING_SUPPORTED
966965
if (CORProfilerTrackGC() || CORProfilerTrackBasicGC())
967966
{
968-
s_currentGenerationTable->AddRecord(generation, rangeStart, rangeEnd, rangeEndReserved);
967+
if (s_currentGenerationTable != nullptr)
968+
{
969+
s_currentGenerationTable->AddRecord(generation, rangeStart, rangeEnd, rangeEndReserved);
970+
}
969971
}
970972
#endif // PROFILING_SUPPORTED
971973
RETURN;

0 commit comments

Comments
 (0)