-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix AsyncInstrumentation to honor s_asyncDebuggingEnabled #127233
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,15 @@ private static Flags InitializeFlags() | |
| { | ||
| if (IsUninitialized(s_activeFlags)) | ||
| { | ||
| // The debugger may have set Task.s_asyncDebuggingEnabled directly via ICorDebug | ||
| // before any ETW session is established. In that case, s_asyncDebuggerActiveFlags | ||
| // will still be Disabled because OnEventCommand was never called. Honor the | ||
| // debugger's request by enabling default flags when s_asyncDebuggingEnabled is set. | ||
| if (s_asyncDebuggerActiveFlags == Flags.Disabled && Task.s_asyncDebuggingEnabled) | ||
| { | ||
| s_asyncDebuggerActiveFlags = DefaultFlags | Flags.AsyncDebugger; | ||
| } | ||
|
Comment on lines
+114
to
+117
|
||
|
|
||
| s_activeFlags = s_asyncProfilerActiveFlags | s_asyncDebuggerActiveFlags; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new fallback behavior (enabling AsyncInstrumentation when only Task.s_asyncDebuggingEnabled is set, without an ETW session) doesn’t appear to be covered by existing runtime-async tests. Consider adding a test that sets Task.s_asyncDebuggingEnabled via reflection without creating a TplEventSource listener, then triggers flag initialization (e.g., via a RuntimeAsyncMethodGeneration async method) and asserts AsyncInstrumentation.s_activeFlags becomes enabled (and that the relevant runtime-async collections are initialized as expected).