Skip to content

Disable EventSource for Apple mobile NativeAOT test libraries - #130675

Merged
kotlarmilos merged 3 commits into
dotnet:mainfrom
kotlarmilos:pr/tvos-nativeaot-eventsource
Jul 16, 2026
Merged

Disable EventSource for Apple mobile NativeAOT test libraries#130675
kotlarmilos merged 3 commits into
dotnet:mainfrom
kotlarmilos:pr/tvos-nativeaot-eventsource

Conversation

@kotlarmilos

@kotlarmilos kotlarmilos commented Jul 14, 2026

Copy link
Copy Markdown
Member

Description

This disables EventSource support for the System.Net.Primitives and System.Runtime.Caching test libraries when Apple mobile NativeAOT assigns TestNativeAot after project evaluation. EventSource registration in a static NativeAOT library can recurse through EventPipe exception handling and exhaust the stack during startup, as seen in https://dev.azure.com/dnceng-public/public/_build/results?buildId=1507526. Desktop NativeAOT builds still enable EventSource because they set TestNativeAot before project evaluation. The EventSource metadata assertion is skipped only when both NativeAOT and Apple mobile are active, consistent with #91762.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b951d28-c99d-4820-9a3d-dbd6fa51fc74
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts how library test projects opt into EventSourceSupport so that Apple mobile NativeAOT scenarios don’t end up enabling EventSource/EventPipe support in a way that can cause problematic startup behavior, and it scopes a NetEventSource metadata assertion to avoid known NativeAOT+Apple mobile limitations.

Changes:

  • Gate EventSourceSupport in System.Runtime.Caching and System.Net.Primitives test csprojs behind $(TestNativeAot).
  • Skip LoggingTest.EventSource_ExistsWithCorrectId under NativeAOT + Apple mobile via ActiveIssue.
Show a summary per file
File Description
src/libraries/System.Runtime.Caching/tests/System.Runtime.Caching.Tests.csproj Makes EventSourceSupport conditional on TestNativeAot for the test project.
src/libraries/System.Net.Primitives/tests/FunctionalTests/System.Net.Primitives.Functional.Tests.csproj Makes EventSourceSupport conditional on TestNativeAot for the functional tests project.
src/libraries/System.Net.Primitives/tests/FunctionalTests/LoggingTest.cs Skips the EventSource metadata assertion on NativeAOT + Apple mobile via ActiveIssue.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread src/libraries/System.Runtime.Caching/tests/System.Runtime.Caching.Tests.csproj Outdated

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The EventSource metadata assertion is skipped only when both NativeAOT and Apple mobile are active, consistent with #91762.

This does not sound right. #91762 is about dealing with multiple event pipe instances in the same process that occurs with shared libraries. It is not the case here. These Apple mobile tests should only ever load a single instance of the runtime in given process.

EventSource registration in a static NativeAOT library can recurse through EventPipe exception handling and exhaust the stack during startup

What is the stacktrace of this recursion? This recursion is likely a product bug that should be fixed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2b951d28-c99d-4820-9a3d-dbd6fa51fc74
Copilot AI review requested due to automatic review settings July 14, 2026 13:50
@kotlarmilos
kotlarmilos marked this pull request as draft July 14, 2026 13:50
@kotlarmilos

Copy link
Copy Markdown
Member Author

The EventSource metadata assertion is skipped only when both NativeAOT and Apple mobile are active, consistent with #91762.

This does not sound right. #91762 is about dealing with multiple event pipe instances in the same process that occurs with shared libraries. It is not the case here. These Apple mobile tests should only ever load a single instance of the runtime in given process.

EventSource registration in a static NativeAOT library can recurse through EventPipe exception handling and exhaust the stack during startup

What is the stacktrace of this recursion? This recursion is likely a product bug that should be fixed.

You are right, based on the .binlog the host build compiled the NativeAOT test library with EventSourceSupport=true, but ProxyProjectForAOTOnHelix.proj evaluated it as false and linked libeventpipe-disabled.a. Then EventPipeInternal_CreateProvider returned zero, and EventPipeEventProvider.Register threw OutOfMemoryException

I removed the test-level EventSource changes. The revised fix passes EventSourceSupport and _SuppressNativeLibEventSourceWarning into the helix proxy.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

@kotlarmilos

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f5c7bdbc-1820-4b8b-bd95-fa27a6781103
Copilot AI review requested due to automatic review settings July 15, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread src/mono/msbuild/apple/data/ProxyProjectForAOTOnHelix.proj
Comment thread eng/testing/tests.ioslike.targets
@kotlarmilos

Copy link
Copy Markdown
Member Author

/azp run runtime-ioslike

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
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.

@kotlarmilos

Copy link
Copy Markdown
Member Author

The System.Net.Primitives startup crash is fixed

@kotlarmilos
kotlarmilos requested a review from jkotas July 15, 2026 14:25
@kotlarmilos
kotlarmilos merged commit 70786a5 into dotnet:main Jul 16, 2026
161 of 164 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants