-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Access violation (crashes the process) while writing EventSource events #99603
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
There is a bug here: runtime/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs Lines 342 to 386 in 1381d5e
The |
Repro by internal reflection using System;
using System.Diagnostics.Tracing;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main()
{
Type httpTelemetryType = Type.GetType("System.Net.Http.HttpTelemetry, System.Net.Http", throwOnError: true)!;
FieldInfo logField = httpTelemetryType.GetField("Log") ?? throw new Exception("HttpTelemetry.Log field does not exist");
var httpTelemetry = (EventSource)logField.GetValue(null) ?? throw new Exception("HttpTelemetry.Log is null");
// public void Http11ConnectionEstablished(long connectionId, string scheme, string host, int port, IPEndPoint? remoteEndPoint)
Action<long, string, string, int, IPEndPoint?> http11ConnectionEstablished
= httpTelemetryType.GetMethod("Http11ConnectionEstablished")
.CreateDelegate<Action<long, string, string, int, IPEndPoint?>>(httpTelemetry);
// public void Http11ConnectionClosed(long connectionId)
Action<long> http11ConnectionClosed
= httpTelemetryType.GetMethod("Http11ConnectionClosed")
.CreateDelegate<Action<long>>(httpTelemetry);
var listener = new DummyListener();
listener.EnableEvents(httpTelemetry, EventLevel.Verbose);
var gcInducerThread = new Thread(() =>
{
while (true)
{
Thread.Sleep(TimeSpan.FromSeconds(1));
Console.Write("GC...");
GC.Collect();
Console.WriteLine("finished.");
}
});
gcInducerThread.IsBackground = true;
gcInducerThread.Start();
Console.WriteLine("Running...");
Parallel.For(1, 1_000_000_000, (long connectionId) =>
{
var remoteEndPoint = new IPEndPoint(address: connectionId, port: 80);
http11ConnectionEstablished(connectionId, "http", $"host{connectionId}", remoteEndPoint.Port, remoteEndPoint);
http11ConnectionClosed(connectionId);
});
}
}
class DummyListener : EventListener
{
} |
I guess |
Looks like we introduced this one in 8.0: #88853 |
Reopening to track backport consideration |
Describe the bug
There is a path in the logging of EventSource events in the HTTP stack which causes an Access Violation.
To Reproduce
Issue appears entirely in .NET call stacks so there are no specific steps to reproduce.
Exceptions (if any)
Further technical details
CLR and .Net versions are in the call stack above.
The text was updated successfully, but these errors were encountered: