Skip to content

Enable EventSource in System.Threading.Tasks.Tests#127744

Merged
MichalStrehovsky merged 2 commits intomainfrom
MichalStrehovsky-patch-1
May 5, 2026
Merged

Enable EventSource in System.Threading.Tasks.Tests#127744
MichalStrehovsky merged 2 commits intomainfrom
MichalStrehovsky-patch-1

Conversation

@MichalStrehovsky
Copy link
Copy Markdown
Member

Might fix native AOT outerloops:

[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CallstackSimulation_HandledException
Expected at least one ResumeAsyncCallstack event
   at System.Threading.Tasks.Tests.AsyncProfilerTests.AssertCallstackSimulationReachesZero(ConcurrentQueue`1 events) in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 653
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_WrapperIndexMatchesCallstack
Assert.All() Failure: 3 out of 3 items in the collection did not pass.
[0]: Item:  Tuple ("WrapperTestC", -1)
     Error: WrapperTestC did not find Continuation_Wrapper_N on stack (slot=-1)
[1]: Item:  Tuple ("WrapperTestB", -1)
     Error: WrapperTestB did not find Continuation_Wrapper_N on stack (slot=-1)
[2]: Item:  Tuple ("WrapperTestA", -1)
     Error: WrapperTestA did not find Continuation_Wrapper_N on stack (slot=-1)
   at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_WrapperIndexMatchesCallstack() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1281
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_UnhandledExceptionUnwind
Assert.Contains() Failure: Item not found in collection
Collection: []
Not found:  ResumeAsyncContext
   at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_UnhandledExceptionUnwind() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1217
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_PeriodicTimerFlush_PreservesOwnerThreadId
Expected periodic timer to flush core lifecycle events within timeout
   at System.Threading.Tasks.Tests.AsyncProfilerTests.<>c__DisplayClass102_0.<RuntimeAsync_PeriodicTimerFlush_PreservesOwnerThreadId>b__1() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1439
   at System.Diagnostics.Tracing.TestEventListener.RunWithCallback(Action`1 handler, Action body) in /_/src/libraries/Common/tests/System/Diagnostics/Tracing/TestEventListener.cs:line 116
   at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_PeriodicTimerFlush_PreservesOwnerThreadId() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1396
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_ResetAsyncThreadContextEvent
Assert.Contains() Failure: Item not found in collection
Collection: []
Not found:  ResetAsyncThreadContext
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
Unhandled exception. Xunit.Sdk.TrueException: Expected first flush of core lifecycle events within timeout
   at Xunit.Assert.True(Nullable`1, String) in /_/src/arcade/src/Microsoft.DotNet.XUnitAssert/src/BooleanAsserts.cs:line 135
   at System.Threading.Tasks.Tests.AsyncProfilerTests.<>c__DisplayClass102_0.<RuntimeAsync_PeriodicTimerFlush_PreservesOwnerThreadId>b__2() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1425
   at System.Threading.Thread.StartThread(IntPtr) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.cs:line 443
   at System.Threading.Thread.ThreadEntryPoint(IntPtr) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Unix.cs:line 92
DOTNET_DbgEnableMiniDump is set and the createdump binary does not exist: ./createdump
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CallstackNativeIPDeltaRoundtrip
Assert.NotEmpty() Failure: Collection was empty
   at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CallstackNativeIPDeltaRoundtrip() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1715
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CreateAndFirstResumeCallstacksMatch
Assert.NotEmpty() Failure: Collection was empty
   at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CreateAndFirstResumeCallstacksMatch() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 1071
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_CallstackSimulation_UnhandledException
Expected at least one ResumeAsyncCallstack event
   at System.Threading.Tasks.Tests.AsyncProfilerTests.AssertCallstackSimulationReachesZero(ConcurrentQueue`1 events) in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 653
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
[FAIL] System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_ContextEventIdLifecycle
Expected at least one CreateAsyncContext with id
   at System.Threading.Tasks.Tests.AsyncProfilerTests.RuntimeAsync_ContextEventIdLifecycle() in /_/src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncProfilerTests.cs:line 781
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) in /_/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs:line 230
./RunTests.sh: line 173:    18 Aborted                 (core dumped) ./System.Threading.Tasks.Tests -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing -xml testResults.xml $RSP_FILE
/root/helix/work/workitem/e
----- end Mon May 4 11:48:57 AM UTC 2026 ----- exit code 134 ----------------------------------------------------------
exit code 134 means SIGABRT Abort. Managed or native assert, or runtime check such as heap corruption, caused call to abort(). Core dumped.

@MichalStrehovsky
Copy link
Copy Markdown
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-threading-tasks
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables EventSource/EventPipe support when System.Threading.Tasks.Tests is built and run under NativeAOT, addressing failures in AsyncProfilerTests that expect runtime async EventSource events to be emitted.

Changes:

  • Set EventSourceSupport to true conditionally when $(TestNativeAot) == true for System.Threading.Tasks.Tests.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🤖 Copilot Code Review — PR #127744

Note

This review was generated by GitHub Copilot.

Holistic Assessment

Motivation: The test project uses TestEventListener and EventSource APIs (in AsyncProfilerTests.cs, RuntimeAsyncTests.cs, AsyncTaskMethodBuilderTests.cs) which require EventSource infrastructure to function. Without EventSourceSupport=true, these tests fail under NativeAOT because the trimmer removes EventSource by default. The problem is real and the fix is justified.

Approach: Adding <EventSourceSupport Condition="'$(TestNativeAot)' == 'true'">true</EventSourceSupport> is the exact pattern used in 10+ other test projects (System.Net.Sockets, System.Net.Http, Microsoft.Extensions.Hosting, Microsoft.Extensions.Logging.EventSource, System.Net.Mail, System.Net.NameResolution, etc.). This is the minimal, correct fix.

Summary: ✅ LGTM. Single-line csproj change follows an established convention. The condition is correctly scoped to NativeAOT only, avoiding any impact on CoreCLR/Mono test runs. No concerns.


Detailed Findings

✅ Correctness — Pattern matches established convention

The EventSourceSupport property with the TestNativeAot condition is identical to what's used across many sibling test projects. Verified that the condition value and placement within the PropertyGroup are consistent with existing usage (e.g., System.Net.Sockets.Tests.csproj:7, Microsoft.Extensions.Hosting.Unit.Tests.csproj:9).

✅ Necessity — Tests genuinely require EventSource

The test project includes files that directly use EventSource.GetSources(), TestEventListener, and TplEventSource listeners:

  • AsyncProfilerTests.cs:198-212 — creates TestEventListener, calls EventSource.GetSources()
  • RuntimeAsyncTests.cs:514,547 — creates TestEventListener("System.Threading.Tasks.TplEventSource")
  • AsyncTaskMethodBuilderTests.cs:587 — creates TestEventListener("System.Threading.Tasks.TplEventSource")

These APIs are trimmed away without EventSourceSupport, causing test failures under NativeAOT.

✅ Scope — No collateral impact

The condition '$(TestNativeAot)' == 'true' ensures this only affects NativeAOT test runs. Regular CoreCLR and Mono test runs are unaffected.

Generated by Code Review for issue #127744 ·

@jkotas jkotas requested a review from lateralusX May 4, 2026 13:47
@lateralusX
Copy link
Copy Markdown
Member

lateralusX commented May 4, 2026

A subset of tests need GetMethodFromNativeIP to work and I suspect that doesn't work for NativeAOT. I have another test PR coming up where I could exclude this and run the outerloop tests as well to make sure they pass on NativeAOT. We could temporarily disable the tests on NativeAOT in this PR and I can fix it in another PR I'm about to submit (enabling single threaded WASM as well). Could that be an option?

@lateralusX
Copy link
Copy Markdown
Member

@copilot, can you temporary disable the async profiler tests on native aot in this PR?

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/c72d785e-5eef-4214-b199-32b053971928

Co-authored-by: lateralusX <11529140+lateralusX@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

@copilot, can you temporary disable the async profiler tests on native aot in this PR?

Done in commit 577cdd2. Added PlatformDetection.IsNotNativeAot to the IsRuntimeAsyncAndThreadingSupported condition, which gates all async profiler tests. This will skip all the tests on NativeAOT until the GetMethodFromNativeIP support is properly addressed.

Copilot AI requested a review from lateralusX May 4, 2026 15:05
@lateralusX
Copy link
Copy Markdown
Member

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@lateralusX
Copy link
Copy Markdown
Member

#127762

@MichalStrehovsky
Copy link
Copy Markdown
Member Author

/ba-g failures are what I'm trying to fix elsewhere

@MichalStrehovsky MichalStrehovsky merged commit 5761661 into main May 5, 2026
110 of 114 checks passed
@MichalStrehovsky MichalStrehovsky deleted the MichalStrehovsky-patch-1 branch May 5, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants