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

[EventPipe] Null passed as an event argument causes crash #12662

Open
jiangzeng01 opened this issue May 8, 2019 · 8 comments
Open

[EventPipe] Null passed as an event argument causes crash #12662

jiangzeng01 opened this issue May 8, 2019 · 8 comments
Assignees
Labels
area-Tracing-coreclr help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@jiangzeng01
Copy link
Contributor

Test:
coreclr\tests\src\tracing\eventsource\eventsourcetrace\EventSourceTrace.cs
Line 23:
this.WriteEvent(1, x, y, z, null);

F:\TempRepo\coreclr>bin\tests\Windows_NT.x64.Debug\tracing\eventsource\eventsourcetrace\eventsourcetrace\eventsourcetrace.cmd
BEGIN EXECUTION
 "F:\TempRepo\coreclr\bin\tests\Windows_NT.x64.Debug\Tests\Core_Root\corerun.exe" eventsourcetrace.exe
        Start: Enable tracing.
        End: Enable tracing.

        Start: Messaging.

Unhandled Exception: System.Diagnostics.Tracing.EventSourceException: Null passed as a event argument.
   at System.Diagnostics.Tracing.EventSource.ThrowEventSourceException(String eventName, Exception innerEx)
   at System.Diagnostics.Tracing.EventSource.WriteEventVarargs(Int32 eventId, Guid* childActivityID, Object[] args)
   at System.Diagnostics.Tracing.EventSource.WriteEvent(Int32 eventId, Object[] args)
   at Tracing.Tests.SimpleEventSource.MathResult(Int32 x, Int32 y, Int32 z, String formula) in F:\TempRepo\coreclr\tests\src\tracing\eventsource\eventsourcetrace\EventSourceTrace.cs:line 23
   at Tracing.Tests.EventSourceTrace.Main(String[] args) in F:\TempRepo\coreclr\tests\src\tracing\eventsource\eventsourcetrace\EventSourceTrace.cs:line 75
Expected: 100
Actual: 255
END EXECUTION - FAILED
FAILED
@sywhang sywhang self-assigned this May 8, 2019
@sywhang
Copy link
Contributor

sywhang commented May 8, 2019

@brianrob Is this an expected behavior that's working as design? I tried something similar on Framework and it doesn't seem to be throwing there. Just wanted to know what the correct behavior should be here before I put out a "fix" :-)

@brianrob
Copy link
Member

brianrob commented May 8, 2019

@sywhang, I would expect a null argument passed for formula in Tracing.Tests.SimpleEventSource.MathResult(Int32 x, Int32 y, Int32 z, String formula) should result in that null being written into the trace file. Said another way, null is a legal value for reference types.

@jorive
Copy link
Member

jorive commented May 8, 2019

I think the function being called here is WriteEvent(Int32, param object[])

@brianrob
Copy link
Member

brianrob commented May 8, 2019

Right - every manifest based event is implemented as something that looks like this:

[Event(1)]
public void MathResult(Int32 x, Int32 y, Int32 z, String formula)
{
    WriteEvent(1, x, y, z, formula);
}

There are various overloads of WriteEvent to avoid the array allocation and subsequent boxing associated with param object[], but if there isn't a specialized overload for the set of arguments to the event then the compiler will bind to WriteEvent(Int32, param object[]).

So even though you see the exception inside fo WriteEvent, the work being done is on-behalf-of the event method.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@daviburg
Copy link

I got tripped by that today. I have tracing in place and sometimes one of the write event parameters (type string) is null, most of the time it's not. So first it look all hunky dory then I get this back from customer traces:

EventSourceException while processing event "**redacted**": Null passed as a event argument.

@AaronRobinsonMSFT AaronRobinsonMSFT self-assigned this Sep 1, 2022
@JJamesWWang
Copy link
Contributor

@davmason @noahfalk Is this issue still actionable? I noticed the original file with the failing test no longer exists.

@noahfalk
Copy link
Member

I'm guessing the underlying issue may still actionable even if the test is gone or moved. Given that the bug is 3 years old there was probably some churn in the tests since then. The only way to know for sure would be to recreate a new test case that hits the issue. From the description it appears you would need to create an EventSource that takes a reference type argument such as a string and then pass null to it. Hope that helps!

@AaronRobinsonMSFT
Copy link
Member

@JJamesWWang The introduction for EventSource is at https://learn.microsoft.com/dotnet/core/diagnostics/eventsource-getting-started. You could also try searching in git and check the history to recover the old test source that existed in 2019.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tracing-coreclr help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants