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

EventSource event with 4 string parameters with null values behaves inconsistent in .NET 8 #102197

Open
desdesdes opened this issue May 14, 2024 · 2 comments

Comments

@desdesdes
Copy link

desdesdes commented May 14, 2024

Description

When raising EventSource events and an ETW listener is attached and the event contains more than 4 string parameters it uses this overload:

WriteEvent(int eventId, params EventSourcePrimitive[] args)

When the WriteEvent is called with one or more parameter has the null value the debug log contains EventSource Error: EventSourceException while processing event "TestEvent": Null passed as a event argument and the event is not passed to ETW.

This does work when we use .net 6 (uses a method with different signature) or when it has less then 4 parameters (uses a different overload) of when all parameters contain a non-null value.

Reproduction Steps

Open perfview.exe and listen to MyEventSource events. Then run the following program.

internal class Program
{
    static void Main(string[] args)
    {
        MyEventSource.Log.TestEvent("Hallo", null, null, null);
        Console.WriteLine("Ready!");

        Console.ReadLine();
    }
}

public class MyEventSource : EventSource
{
    public MyEventSource() //: base(EventSourceSettings.EtwSelfDescribingEventFormat)
    {

    }

    internal static MyEventSource Log = new MyEventSource();

    [Event(1)]
    public void TestEvent(string a, string b, string c, string d)
    {
        WriteEvent(1, a, b, c, d);
    }
}

In the debug output of the console application we see:
EventSource Error: EventSourceException while processing event "TestEvent": Null passed as a event argument.

If we use .net 6 of if we use EtwSelfDescribingEventFormat or if we use less then 3 parameters this error is not logged and the event is properly traced. Because usually the parameters are filled or not filled at runtime it is very hard to spot the problem and tracing may apprear unrelayable.

Expected behavior

Event is captured in ETW (perfview)

Actual behavior

Event is not captured in ETW (perfview)

Regression?

No response

Known Workarounds

Use EventSourceSettings.EtwSelfDescribingEventFormat

Configuration

.NET 8 on x64

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label May 14, 2024
Copy link
Contributor

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

@tommcdon
Copy link
Member

Seems to be a duplicate to #12662

@tommcdon tommcdon added this to the 9.0.0 milestone May 20, 2024
@tommcdon tommcdon removed the untriaged New issue has not been triaged by the area owner label May 20, 2024
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

2 participants