Open mdh1418 opened 1 month ago
https://github.com/dotnet/runtime/issues/80666 uncovered an issue where EventPipeEventProvider's callback had been invoked after the gchandle was freed. To align EventPipe with ETW which blocks disposal for in-flight callbacks, https://github.com/dotnet/runtime/pull/106040 added a signal wait/set blocking behavior to ep_delete_provider. As a result, a deadlock can occur should users invoke EventPipeEventProvider's Unregister or ep_delete_provider within a callback.
ep_delete_provider
The same behavior is exhibited on ETW
using System.Diagnostics.Tracing; MyEventSource eventSource = new MyEventSource(); Console.WriteLine("MyEventSource is ready to be enabled"); Console.ReadLine(); [EventSource(Name ="MyEventSource")] class MyEventSource : EventSource { override protected void OnEventCommand(EventCommandEventArgs command) { Console.WriteLine($"Command: {command.Command}"); this.Dispose(); Console.WriteLine($"Dispose() complete"); } }
dotnet-trace collect --providers MyEventSource -p <pid of running sample>
Sample's output
MyEventSource is ready to be enabled Command: Enable Dispose() complete
MyEventSource is ready to be enabled Command: Enable
No response
Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti See info in area-owners.md if you want to be subscribed.
Description
https://github.com/dotnet/runtime/issues/80666 uncovered an issue where EventPipeEventProvider's callback had been invoked after the gchandle was freed. To align EventPipe with ETW which blocks disposal for in-flight callbacks, https://github.com/dotnet/runtime/pull/106040 added a signal wait/set blocking behavior to
ep_delete_provider
. As a result, a deadlock can occur should users invoke EventPipeEventProvider's Unregister orep_delete_provider
within a callback.The same behavior is exhibited on ETW
Reproduction Steps
dotnet-trace collect --providers MyEventSource -p <pid of running sample>
Expected behavior
Sample's output
Actual behavior
Sample's output
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response