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

[NativeAOT] IndexOutOfRangeException when running under perfview #75945

Closed
jkotas opened this issue Sep 21, 2022 · 6 comments · Fixed by #76109
Closed

[NativeAOT] IndexOutOfRangeException when running under perfview #75945

jkotas opened this issue Sep 21, 2022 · 6 comments · Fixed by #76109
Assignees
Labels
area-System.Diagnostics.Tracing in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@jkotas
Copy link
Member

jkotas commented Sep 21, 2022

Stacktrace:

---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
System.Diagnostic.Tracing.EventSource.WriteEventWithRelatedActivityIdCore
System.Diagnostic.Tracing.EventSource.WriteEvent
System.Diagnostic.DiagnosticSourceEventSource.FilterAndTransform
System.Diagnostic.DiagnostisListener.AllListenerObservable.OnNewDiagnosticListener
System.Diagnostic.Listener..ctor
System.Net.DiagnosticHandler..ctor
System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun

Repro: https://github.com/kshyju/Net7IsolatedHttpApp

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 21, 2022
@ghost
Copy link

ghost commented Sep 21, 2022

Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti
See info in area-owners.md if you want to be subscribed.

Issue Details
---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
System.Diagnostic.Tracing.EventSource.WriteEventWithRelatedActivityIdCore
System.Diagnostic.Tracing.EventSource.WriteEvent
System.Diagnostic.DiagnosticSourceEventSource.FilterAndTransform
System.Diagnostic.DiagnostisListener.AllListenerObservable.OnNewDiagnosticListener
System.Diagnostic.Listener..ctor
System.Net.DiagnosticHandler..ctor
System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun
Author: jkotas
Assignees: -
Labels:

area-System.Diagnostics.Tracing, untriaged

Milestone: -

@jkotas
Copy link
Member Author

jkotas commented Sep 21, 2022

cc @noahfalk @brianrob

@tommcdon
Copy link
Member

adding @vitek-karas
@jkotas do you know if this issue reproduces with a .net core trimmed app? I'm curious if this is a trimming safety issue, or if it is NativeAOT specific.

@tommcdon tommcdon added this to the 8.0.0 milestone Sep 21, 2022
@tommcdon tommcdon removed the untriaged New issue has not been triaged by the area owner label Sep 21, 2022
@jkotas
Copy link
Member Author

jkotas commented Sep 22, 2022

There are multiple issues actually, some are native AOT specific and some apply to trimmed apps in general.

@eerhardt
Copy link
Member

FYI - I've been hacking on DiagnosticSource to make it work with NativeAOT. I've got a change working with PerfView locally - eerhardt@5f27679.

I just need to figure out a way to test it now, so we can ensure it stays fixed.

@tommcdon
Copy link
Member

@eerhardt is it OK if I assign this issue to you since you are working on a fix?

@eerhardt eerhardt self-assigned this Sep 23, 2022
eerhardt added a commit to eerhardt/runtime that referenced this issue Sep 23, 2022
There were 2 problems:

1. The use of MakeGenericType doesn't work when a property is a ValueType.
An app will crash when a listener is enabled and DiagnosticSourceEventSource tries
writing values.
2. The properties on KeyValuePair were not being preserved correctly, so the Arguments
of the DiagnosticSourceEventSource methods were not being serialized correctly.

Add test (and infrastructure) to ensure DiagnosticSource works in a NativeAOT app

Fix dotnet#75945
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 23, 2022
eerhardt added a commit that referenced this issue Sep 28, 2022
* Fix DiagnosticSource to work with NativeAOT

There were 2 problems:

1. The use of MakeGenericType doesn't work when a property is a ValueType.
An app will crash when a listener is enabled and DiagnosticSourceEventSource tries
writing values.
2. The properties on KeyValuePair were not being preserved correctly, so the Arguments
of the DiagnosticSourceEventSource methods were not being serialized correctly.

Add test (and infrastructure) to ensure DiagnosticSource works in a NativeAOT app

Fix #75945

* Enable new NativeAotTests in CI

- Only run them in Release configuration
- Suppress IL2026 warning

* Don't run NativeAot published app tests on OSX since it isn't supported

Set EventSourceSupport only on the projects that need it.
@ghost ghost locked as resolved and limited conversation to collaborators Oct 29, 2022
MichalStrehovsky pushed a commit to MichalStrehovsky/runtime that referenced this issue Nov 15, 2022
* Fix DiagnosticSource to work with NativeAOT

There were 2 problems:

1. The use of MakeGenericType doesn't work when a property is a ValueType.
An app will crash when a listener is enabled and DiagnosticSourceEventSource tries
writing values.
2. The properties on KeyValuePair were not being preserved correctly, so the Arguments
of the DiagnosticSourceEventSource methods were not being serialized correctly.

Add test (and infrastructure) to ensure DiagnosticSource works in a NativeAOT app

Fix dotnet#75945

* Enable new NativeAotTests in CI

- Only run them in Release configuration
- Suppress IL2026 warning

* Don't run NativeAot published app tests on OSX since it isn't supported

Set EventSourceSupport only on the projects that need it.
github-actions bot pushed a commit that referenced this issue Nov 18, 2022
There were 2 problems:

1. The use of MakeGenericType doesn't work when a property is a ValueType.
An app will crash when a listener is enabled and DiagnosticSourceEventSource tries
writing values.
2. The properties on KeyValuePair were not being preserved correctly, so the Arguments
of the DiagnosticSourceEventSource methods were not being serialized correctly.

Add test (and infrastructure) to ensure DiagnosticSource works in a NativeAOT app

Fix #75945
carlossanlop pushed a commit that referenced this issue Jan 4, 2023
* Fix DiagnosticSource to work with NativeAOT

There were 2 problems:

1. The use of MakeGenericType doesn't work when a property is a ValueType.
An app will crash when a listener is enabled and DiagnosticSourceEventSource tries
writing values.
2. The properties on KeyValuePair were not being preserved correctly, so the Arguments
of the DiagnosticSourceEventSource methods were not being serialized correctly.

Add test (and infrastructure) to ensure DiagnosticSource works in a NativeAOT app

Fix #75945

* Enable new NativeAotTests in CI

* Fix NativeAOT tests

- Only run them in Release configuration
- Suppress IL2026 warning

* Fix test CI leg

* Set IlcFrameworkNativePath correctly

* Don't run NativeAot published app tests on OSX since it isn't supported

* Respond to PR feedback

Set EventSourceSupport only on the projects that need it.

* Add servicing change for DiagnosticSource

* Update Microsoft.Extensions.Hosting.csproj

* Update Microsoft.Extensions.Hosting.csproj

Co-authored-by: Eric Erhardt <[email protected]>
Co-authored-by: Viktor Hofer <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Diagnostics.Tracing in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants