dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.39k stars 4.75k forks source link

EventPipeController ctor potentially throws ArgumentNullException? #12512

Closed stephentoub closed 4 years ago

stephentoub commented 5 years ago

EventPipeController's ctor accesses AppContext.BaseDirectory and passes the result to Path.Combine, which will throw an ArgumentNullException if BaseDirectory returns null. BaseDirectory returns the result of GetBaseDirectoryCore, which calls Assembly.GetEntryAssembly()?.Location. GetEntryAssembly may return null, in which case GetBaseDirectoryCore will return null, in which case Path.Combine will throw and the EventPipeController ctor will throw. This will be eaten in the Initialize method by a catch-all block, but it seems like it'd be better not to throw in the first place.

josalem commented 5 years ago

The file-based configuration invocation of EventPipe is meant to silently fail if something goes wrong--as you mentioned, this logic is wrapped in a try/catch/finally block. Since the file-based configuration invocation of Eventpipe is going to be removed entirely in an upcoming change, I'm going to leave this as-is for now.