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

[Tracing] EventProvider Disposal hangs within a callback #106087

Open
mdh1418 opened this issue Aug 7, 2024 · 1 comment
Open

[Tracing] EventProvider Disposal hangs within a callback #106087

mdh1418 opened this issue Aug 7, 2024 · 1 comment

Comments

@mdh1418
Copy link
Member

mdh1418 commented Aug 7, 2024

Description

#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, #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.

The same behavior is exhibited on ETW

Reproduction Steps

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>

Expected behavior

Sample's output

MyEventSource is ready to be enabled
Command: Enable
Dispose() complete

Actual behavior

Sample's output

MyEventSource is ready to be enabled
Command: Enable

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@mdh1418 mdh1418 added this to the 10.0.0 milestone Aug 7, 2024
@mdh1418 mdh1418 self-assigned this Aug 7, 2024
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant