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/8.0-rc2] Do not call SignalSession on invalid session IDs #92444

Merged
merged 2 commits into from
Sep 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,15 @@ private void SetStopDispatchTask()
{
Debug.Assert(Monitor.IsEntered(m_dispatchControlLock));

if (m_dispatchTask != null)
if (m_dispatchTaskCancellationSource?.IsCancellationRequested ?? true)
{
Debug.Assert(m_dispatchTaskCancellationSource != null);
m_dispatchTaskCancellationSource?.Cancel();
EventPipeInternal.SignalSession(m_sessionID);
return;
}

Debug.Assert(m_sessionID != 0);
m_dispatchTaskCancellationSource.Cancel();
EventPipeInternal.SignalSession(m_sessionID);
m_sessionID = 0;
}

private unsafe void DispatchEventsToEventListeners(ulong sessionID, DateTime syncTimeUtc, long syncTimeQPC, long timeQPCFrequency, Task? previousDispatchTask, CancellationToken token)
Expand Down Expand Up @@ -187,8 +190,12 @@ private unsafe void DispatchEventsToEventListeners(ulong sessionID, DateTime syn
}
}

// Disable the old session. This can happen asynchronously since we aren't using the old session anymore
EventPipeInternal.Disable(sessionID);
lock (m_dispatchControlLock)
{
// Disable the old session. This can happen asynchronously since we aren't using the old session
// anymore. We take the lock to make sure we don't call SignalSession on an invalid session ID.
EventPipeInternal.Disable(sessionID);
}
}

/// <summary>
Expand Down