Benchmarkdotnet: NullReferenceException when run in WSL

Created on 16 Jun 2020  路  6Comments  路  Source: dotnet/BenchmarkDotNet

I'm getting a an unhandled System.NullReferenceException when trying to use BenchmarkDotNet in WSL 1 and 2, with the code hosted in either WSL and Windows file systems.
My project is very simple and just works in Windows.

Stacktrace:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at BenchmarkDotNet.Disassemblers.ClrMdDisassembler.AttachAndDisassemble(Settings settings)
   at BenchmarkDotNet.Disassemblers.LinuxDisassembler.Disassemble(DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Diagnosers.DisassemblyDiagnoser.Handle(HostSignal signal, DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Diagnosers.CompositeDiagnoser.Handle(HostSignal signal, DiagnoserActionParameters parameters)
   at BenchmarkDotNet.Loggers.SynchronousProcessOutputLoggerWithDiagnoser.ProcessInput()
   at BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliExecutor.Execute(BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, ArtifactsPaths artifactsPaths, IDiagnoser diagnoser, String executableName, IResolver resolver)
   at BenchmarkDotNet.Toolchains.DotNetCli.DotNetCliExecutor.Execute(ExecuteParameters executeParameters)
   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, List`1 artifactsToCleanup, String resultsFolderPath, String logFilePath, StartedClock& runChronometer)
   at BenchmarkDotNet.Running.BenchmarkRunnerClean.Run(BenchmarkRunInfo[] benchmarkRunInfos)
   at BenchmarkDotNet.Running.BenchmarkSwitcher.RunWithDirtyAssemblyResolveHelper(String[] args, IConfig config)
   at BenchmarkDotNet.Running.BenchmarkSwitcher.Run(String[] args, IConfig config)
   at <Namespace>.Program.Main(String[] args) in /home/<user>/<project_path>/Program.cs:line 10

.NET Core version: Version: 3.1.4
Installed packages: BenchmarkDotNet v0.12.1 and BenchmarkDotNet.Diagnostics.Windows v0.12.1

bug help wanted up-for-grabs

Most helpful comment

It just works now 馃槼
I'm unable to reproduce it now using the same code, BenchmarkDotNet and .NET Core versions and WSL1/2 instances I initially used!
Feel free to close this @adamsitnik, I guess it's not relevant any more. Thanks @stanciuadrian!

All 6 comments

Hi @eduherminio

0.12.1 is using a version of ClrMD that does not support WSL (https://github.com/microsoft/clrmd/pull/304)

We have recently updated it in https://github.com/dotnet/BenchmarkDotNet/pull/1459 but have not released a new version to nuget.org yet.

Could you please download the latest BDN version (0.12.1.1372) from our CI feed that contains the ClrMD version update and let me know if this helps?

You need to add our CI feed to your nuget.config file: (it can be generated by using dotnet new nugetconfig)

<packageSources>
  <add key="bdn-ci" value="https://ci.appveyor.com/nuget/benchmarkdotnet" />
</packageSources>

I'm afraid I'm getting the same exception with 0.12.1.1372 @adamsitnik.

@eduherminio thanks for quick confirmation!

I've used BDN v0.12.1428 with .NET Core 3.1 on Ubuntu WSL2 and the following code:

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;

public class Program
{
    [Benchmark]
    public void Go() { }

    static void Main(string[] args)
        => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, new DebugInProcessConfig());
}

I got no exception when the binary was executed from both filesystems.

Could you please test again / share more about your simple test?

It just works now 馃槼
I'm unable to reproduce it now using the same code, BenchmarkDotNet and .NET Core versions and WSL1/2 instances I initially used!
Feel free to close this @adamsitnik, I guess it's not relevant any more. Thanks @stanciuadrian!

@stanciuadrian thanks for giving it a try!

@eduherminio thanks for the confirmation!

Was this page helpful?
0 / 5 - 0 ratings