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

EtwProfiler throws #2685

Open
dellamonica opened this issue Jan 2, 2025 · 2 comments
Open

EtwProfiler throws #2685

dellamonica opened this issue Jan 2, 2025 · 2 comments

Comments

@dellamonica
Copy link

When trying to profile the benchmark, I'm getting this exception. No special configuration was used, just the attribute.

.csproj:

<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.ArgumentNullException.Throw(String paramName)
   at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
   at System.Collections.Generic.SortedDictionary`2.TryGetValue(TKey key, TValue& value)
   at Microsoft.Diagnostics.Tracing.Session.TraceEventProviders.GetProviderGuidByName(String name)
   at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableProvider(String providerName, TraceEventLevel providerLevel, UInt64 matchAnyKeywords, TraceEventProviderOptions options)
   at BenchmarkDotNet.Diagnostics.Windows.UserSession.EnableProviders()
   at BenchmarkDotNet.Diagnostics.Windows.EtwProfiler.Start(DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Diagnostics.Windows.EtwProfiler.Handle(HostSignal signal, DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Diagnosers.CompositeDiagnoser.Handle(HostSignal signal, DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliExecutor.Execute(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, ArtifactsPaths artifactsPaths, IDiagnoser diagnoser, String executableName, IResolver resolver, Int32 launchIndex)
   at BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliExecutor.Execute(ExecuteParameters executeParameters)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.RunExecute(ILogger logger, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, IToolchain toolchain, BuildResult buildResult, IResolver resolver, IDiagnoser diagnoser, Int32 launchIndex)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.Execute(ILogger logger, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, IToolchain toolchain, BuildResult buildResult, IResolver resolver)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.RunCore(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, IResolver resolver, BuildResult buildResult)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.Run(BenchmarkRunInfo benchmarkRunInfo, Dictionary`2 buildResults, IResolver resolver, ILogger logger, EventProcessor eventProcessor, List`1 artifactsToCleanup, String resultsFolderPath, String logFilePath, Int32 totalBenchmarkCount, StartedClock& runsChronometer, Int32& benchmarksToRunCount, TaskbarProgress taskbarProgress)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.Run(BenchmarkRunInfo[] benchmarkRunInfos)
   at BenchmarkDotNet.Running.BenchmarkRunner.RunWithDirtyAssemblyResolveHelper(Type type, IConfig config, String[] args)
   at BenchmarkDotNet.Running.BenchmarkRunner.<>c__DisplayClass0_0`1.<Run>b__0()
   at BenchmarkDotNet.Running.BenchmarkRunner.RunWithExceptionHandling(Func`1 run)
   at BenchmarkDotNet.Running.BenchmarkRunner.Run[T](IConfig config, String[] args)
   at <Program>F434C893D347D378BD1CFEE9E250135FD99E920ADDCBBE6AEE63D66CD410CFDAA__Runner.<>c__1`1.<Add>b__1_0() in C:\Users\domin\dev\DotProduct\Metis\Benchmarks\Program.cs:line 20
   at <Program>F434C893D347D378BD1CFEE9E250135FD99E920ADDCBBE6AEE63D66CD410CFDAA__Runner.Run(ImmutableArray`1 selection) in C:\Users\domin\dev\DotProduct\Metis\Benchmarks\Program.cs:line 28
   at Program.<Main>$(String[] args) in C:\Users\domin\dev\DotProduct\Metis\Benchmarks\Program.cs:line 11

Note: I've also tried creating an explicit configuration where I'd pass an empty list of providers, but it still fails. After checking the code of UserSession.EnableProviders(), it seems like the only culprit could be https://github.com/dotnet/BenchmarkDotNet/blob/cac4f6e7342eb28e73f59d21ca87f48cfce7b6ba/src/BenchmarkDotNet.Diagnostics.Windows/Sessions.cs#L46C46-L46C63

@adamsitnik
Copy link
Member

@brianrob do you have any idea why this could be failing? we have not touched this code for years, I expect it could be some ETW-related problem that occurred for PerfView users in the past.

@brianrob
Copy link
Member

There was an issue around this code a while back which resulted in this change: microsoft/perfview@9d05617#diff-1f06bc7c79946634f1cf3b0eea5ef2e74db9cea1b22a251df4b9173f5c5136abR1643.

It looks like the behavior observed here is slightly different. From the stack, it looks like the call to TraceEventProviders.GetProviderGuidByName is being passed null for name, which results in this exception. I'd expect to get an exception in this case, as a null value is not a valid value for this parameter.

As a next step, I'd recommend debugging into this to see if the value being passed to TraceEventProviders.GetProviderGuidByName is in-fact null.

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

3 participants