Draft
Fix EventPipe keyword/level filter recomputation after session close#130491
Conversation
Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com>
Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix EventPipe keyword and level filters update on session close
Fix EventPipe keyword/level filter recomputation after session close
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EventPipe maintains aggregate keyword/level filters per EventSource across all active sessions. When a session stops while others remain active, two bugs caused stale filter values —
IsEnabled(level, keyword)would returntrueeven when no remaining session matched.Fixes
Bug 1 — Native (
ep-config.c)config_compute_keyword_and_levelincluded the session being disabled in its keyword/level aggregation. Added asession_to_excludeparameter; callers passNULLwhen enabling (no exclusion) and the session pointer when disabling, so the computed values reflect only the remaining active sessions.Bug 2 — Managed (
EventSource.cs,DoCommand)When a session stops with others still active, the provider callback fires
ENABLE_PROVIDER(source still enabled) withbSessionEnable=false. The existing code only handled two cases — first enable (copy) and new session starting (expand via max/OR). It never narrowed the filter when a session stopped. Added a third branch:!m_eventSourceEnabled→ first enable: copy valuesbSessionEnable→ new session: expand (max/OR)m_level/m_matchAnyKeywordwith the recomputed values from native (which now correctly exclude the stopping session)Test
Added
KeywordLevelFilterValidationtoenabledisable.cs: starts two sessions (Informational+keyword=0x2, Error+keyword=0x1), stops the broader one first, and assertsIsEnabled(Informational, 0x2)isfalseonce only the Error session remains.