Repository navigation
[release/10.0] Fix intermittent NRE in ETW listener tests by using GUID overload of EnableProvider - #138098
Merged
Conversation
…EnableProvider (#125908) `BasicEventSourceTests` ETW tests intermittently fail with `NullReferenceException` in `TraceEventProviders.GetProviderGuidByName` under CI stress (PGO, jitstress). The string overload of `EnableProvider` resolves the name via `TdhEnumerateProviders` (Win32), which intermittently returns `ERROR_INSUFFICIENT_BUFFER`, yielding a null provider dictionary. ## Description **Root cause:** `EtwListener.ApplyEventSourceCommand` called `_session.EnableProvider(string, ...)`, which internally calls `TdhEnumerateProviders` — a Windows API that transiently fails under load. **Fix:** Switch the `Enable` path to use the GUID overload, consistent with how `DisableProvider` already works in the same method: ```csharp // Before _session.EnableProvider(eventSourceName, (TraceEventLevel)options.Level, (ulong)options.Keywords, ...); // After — GUID is computed deterministically; no TdhEnumerateProviders call var providerGuid = TraceEventProviders.GetEventSourceGuidFromName(eventSourceName); _session.EnableProvider(providerGuid, (TraceEventLevel)options.Level, (ulong)options.Keywords, ...); ``` `GetEventSourceGuidFromName` computes the EventSource GUID algorithmically from the name (same as the runtime itself), so no registry/ETW enumeration is needed. > [!NOTE] > This content was generated with AI assistance (GitHub Copilot). <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> ---- *This section details on the original issue you should resolve* <issue_title>Test failure BasicEventSourceTests.TestsUserErrors.Test_BadEventSource_MismatchedIds_WithEtwListener</issue_title> <issue_description>## Build Information Build: https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=762567 Build error leg or test failing: BasicEventSourceTests.TestsUserErrors.Test_BadEventSource_MismatchedIds_WithEtwListener Pull request: #105777 <!-- Error message template --> ## Error Message Fill the error message using [step by step known issues guidance](https://github.com/dotnet/arcade/blob/main/Documentation/Projects/Build%20Analysis/KnownIssueJsonStepByStep.md). <!-- Use ErrorMessage for String.Contains matches. Use ErrorPattern for regex matches (single line/no backtracking). Set BuildRetry to `true` to retry builds with this error. Set ExcludeConsoleLog to `true` to skip helix logs analysis. --> ```json { "ErrorMessage": "BasicEventSourceTests.TestsUserErrors.Test_BadEventSource_MismatchedIds_WithEtwListener [FAIL]", "ErrorPattern": "", "BuildRetry": false, "ExcludeConsoleLog": false } ``` **Failed in:** [runtime-coreclr libraries-pgo 20240114.1](https://dev.azure.com/dnceng-public/public/_build/results?buildId=526820&view=ms.vss-test-web.build-test-results-tab&runId=12404250&resultId=136092&paneView=debug) **Failed tests:** ``` net9.0-windows-Release-x86-CoreCLR_checked-fullpgo_methodprofiling-Windows.10.Amd64.Open - BasicEventSourceTests.TestsUserErrors.Test_BadEventSource_MismatchedIds_WithEtwListener ``` **Error message:** ``` System.NullReferenceException : Object reference not set to an instance of an object. ``` **Stack trace:** ``` at Microsoft.Diagnostics.Tracing.Session.TraceEventProviders.GetProviderGuidByName(String name) at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableProvider(String providerName, TraceEventLevel providerLevel, UInt64 matchAnyKeywords, TraceEventProviderOptions options) at BasicEventSourceTests.EtwListener.EventSourceCommand(String eventSourceName, EventCommand command, FilteringOptions options) in /_/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/Harness/EtwListener.cs:line 77 at BasicEventSourceTests.TestsUserErrors.Test_Bad_EventSource_Startup(Boolean onStartup, Listener listener, EventSourceSettings settings) in /_/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsUserErrors.cs:line 115 at BasicEventSourceTests.TestsUserErrors.Test_BadEventSource_MismatchedIds_WithEtwListener() in /_/src/libraries/System.Diagnostics.Tracing/tests/BasicEventSourceTest/TestsUserErrors.Etw.cs:line 48 at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) in /_/src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.CoreCLR.cs:line 36 at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) in /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs:line 57 ``` <!-- Known issue validation start --> ### Known issue validation **Build: 🔎** https://dev.azure.com/dnceng-public/public/_build/results?buildId=762567 **Error message validated:** `[BasicEventSourceTests.TestsUserErrors.Test_BadEventSource_MismatchedIds_WithEtwListener [FAIL]`] **Result validation:** ✅ Known issue matched with the provided build. **Validation performed at:** 8/4/2024 3:24:07 AM UTC <!-- Known issue validation end --> <!--Known issue error report start --> ### Report |Build|Definition|Test|Pull Request| |---|---|---|---| |[1346041](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1346041)|dotnet/runtime|[BasicEventSourceTests.TestsWrite.Test_Write_T_ETW](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1346041&view=ms.vss-test-web.build-test-results-tab&runId=37594902&resultId=131497)|dotnet/runtime#125010| |[1342233](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1342233)|dotnet/runtime|[BasicEventSourceTests.TestsWriteEvent.Test_WriteEvent_SelfDescribing_ETW](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1342233&view=ms.vss-test-web.build-test-results-tab&runId=37485304&resultId=123634)|dotnet/runtime#124738| |[1335226](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1335226)|dotnet/runtime|[BasicEventSourceTests.TestsWrite.Test_Write_T_ETW](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1335226&view=ms.vss-test-web.build-test-results-tab&runId=37296014&resultId=136917)|| |[1311626](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1311626)|dotnet/runtime|[BasicEventSourceTests.TestsW... </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #96968 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: danmoseley <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
lewing
approved these changes
Nov 23, 2026
lewing
enabled auto-merge (squash)
November 23, 2026 01:10
Contributor
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
Member
|
/ba-g failures have active prs for servicing |
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.
Backport of #125908 to release/10.0
Spotted on release/10.0 in #138054 (build 1693559,
net10.0-windows-Release-x64-coreclr_checked):Test_BadEventSource_MismatchedIds_WithEtwListenerfailed with the sameNullReferenceExceptioninTraceEventProviders.GetProviderGuidByName./cc @lewing @copilot
Customer Impact
[Select one or both of the boxes. Describe how this issue impacts customers, citing the expected and actual behaviors and scope of the issue. If customer-reported, provide the issue number.]
Regression
[If yes, specify when the regression was introduced. Provide the PR or commit if known.]
Testing
[How was the fix verified? How was the issue missed previously? What tests were added?]
Risk
[High/Medium/Low. Justify the indication by mentioning how risks were measured and addressed.]
Note
The release/10.0 failure link was added with GitHub Copilot assistance.