Skip to content
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

Support EventSource/event pipe in shared libraries #91762

Open
2 tasks
MichalStrehovsky opened this issue Sep 7, 2023 · 1 comment
Open
2 tasks

Support EventSource/event pipe in shared libraries #91762

MichalStrehovsky opened this issue Sep 7, 2023 · 1 comment
Assignees
Milestone

Comments

@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Sep 7, 2023

When EventSourceSupport MSBuild property is set to true, the build currently errors out. It is possible to bypass this by setting _SuppressNativeLibEventSourceError property to true but there are known issues. It is not recommended to ship native libraries like this unless one can make sure no other native library (or a CoreCLR instance) with EventSourceSupport gets loaded into the process. Users might consider shipping two versions of their native library DLL and only use the one with EventSourceSupport enabled when troubleshooting a specific issue.

This is a tracking uber issue that groups the known existing problems:

Our guidance for EventSource/EventPipe with native AOT shared libraries is as follows,

  • Only use the EventSourceSupport enabled when troubleshooting a specific issue related to shared libraries.
  • Any native AOT console with EventSourceSupport enabled will always win even if the process has other native AOT shared libraries with EventSourceSupport enabled.
  • If there are multiple native AOT shared libraries present in a single process, then the first shared library that gets loaded will win to emit traces. Traces from other libraries will not be seen.
  • [Windows] When collecting tracing in a shared library, collection should stop earlier in the application (only collect for a specific time period or use the ctrl-C option with a tool like dotnet-trace when the interesting traces are collected). Specifically, in windows, the image unload event for a shared library (or at process exit), will not make a call to shut down the EventPipe in an orderly manner, causing a corrupted trace file.

Given these challenges, it's probably best to keep the current warnings we have for shared library around EventSource support.

@ghost
Copy link

ghost commented Sep 7, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

When EventSourceSupport MSBuild property is set to true, the build currently errors out. It is possible to bypass this by setting _SuppressNativeLibEventSourceError property to true but there are known issues. It is not recommended to ship native libraries like this unless one can make sure no other native library (or a CoreCLR instance) with EventSourceSupport gets loaded into the process. Users might consider shipping two versions of their native library DLL and only use the one with EventSourceSupport enabled when troubleshooting a specific issue.

This is a tracking uber issue that groups the known existing problems:

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: Future

agocke pushed a commit that referenced this issue Sep 14, 2023
Trying to enable EventSourceSupport in a shared library project on Native AOT currently results in a build failure since this is actively blocked in the targets. But EventSourceSupport/event pipe mostly work, with some issues (#91762).

The blocking makes it impossible for anyone to run diagnostics on their shared library. This is a regression from .NET 7, where it was at least possible to get GC ETW events in PerfView on Windows.

This changes the blocking to a suppressible warning, and fixes and issue that was causing a shutdown hang.
@LakshanF LakshanF self-assigned this May 28, 2024
@agocke agocke added this to AppModel Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants