Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

COMException (segmentation fault) when running HardwareCounters

Đang mở
#2,811 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản demo net8.0 được cung cấp với HardwareCounters và xem xét lỗi tại Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableKernelProvider, BenchmarkDotNet.Diagnostics.Windows.KernelSession.EnableProviders và EtwProfiler.Start. Tái hiện COMException trên Windows 11 và xác định việc thực thi bộ đếm phần cứng thành công cần những gì; hoàn tất có nghĩa là benchmark chạy mà không gặp ngoại lệ tài nguyên đang được sử dụng hoặc Segmentation fault.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hello,

I am trying hardware counters for the first time after finding this article. I have unfortunately been unable to use these counters as I run into an exception when using them. I have stripped everything back to a tiny demo and still receive the error.

I'm on Windows 11 Pro.

My dotnet --version is 8.0.412.

$ dotnet run -c Release
// Validating benchmarks:
// ***** BenchmarkRunner: Start   *****
// ***** Found 1 benchmark(s) in total *****
// ***** Building 1 exe(s) in Parallel: Start   *****
// start dotnet  restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true /p:ArtifactsPath="C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1/" /p:OutDir="C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1\bin\Release\net8.0/" /p:OutputPath="C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1\bin\Release\net8.0/" /p:PublishDir="C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1\publish/" in C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1
// command took 0.62 sec and exited with 0
// start dotnet  build -c Release --no-restore /p:UseSharedCompilation=false /p:BuildInParallel=false /m:1 /p:Deterministic=true /p:Optimize=true /p:ArtifactsPath="C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1/" /p:OutDir="C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1\bin\Release\net8.0/" /p:OutputPath="C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1\bin\Release\net8.0/" /p:PublishDir="C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1\publish/" --output "C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1\bin\Release\net8.0/" in C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1
// command took 3.23 sec and exited with 0
// ***** Done, took 00:00:03 (3.88 sec)   *****
// Found 1 benchmarks:
//   DemoClass.Demo: DefaultJob

Setup power plan (GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c FriendlyName: High performance)
// **************************
// Benchmark: DemoClass.Demo: DefaultJob
// *** Execute ***
// Launch: 1 / 1
// Execute: dotnet Benchmarking-DefaultJob-1.dll --anonymousPipes 1764 1440 --benchmarkName DemoClass.Demo --job Default --benchmarkId 0 in C:\Users\{some-directory}\bin\Release\net8.0\Benchmarking-DefaultJob-1\bin\Release\net8.0
Unhandled exception. System.Runtime.InteropServices.COMException (0x800700AA): The requested resource is in use. (0x800700AA)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at Microsoft.Diagnostics.Tracing.Session.TraceEventSession.EnableKernelProvider(Keywords flags, Keywords stackCapture)
   at BenchmarkDotNet.Diagnostics.Windows.KernelSession.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.<Main>$(String[] args) in C:\Users\{some-directory}\Program.cs:line 5
Successfully reverted power plan (GUID: 381b4222-f694-41f0-9685-ff5bb260df2e FriendlyName: Balanced)
// * Artifacts cleanup *
Artifacts cleanup is finished
Segmentation fault

Here is my program.

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Running;

var summary = BenchmarkRunner.Run<DemoClass>();
Console.WriteLine(summary);

[MemoryDiagnoser]
[HardwareCounters(HardwareCounter.BranchMispredictions, HardwareCounter.BranchInstructions)]
public class DemoClass
{
    [Benchmark]
    public int Demo() => 1 + 2;
}

And here is my csproj.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="../{ProgramName}.csproj" />
    <PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
    <PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.15.2" />
  </ItemGroup>

</Project>
Ngôn ngữ chính
C#
Star
11.5k
Fork
1.1k
Merge trung bình
3 ngày 2 giờ
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/BenchmarkDotNet

Tất cả issue của dotnet/BenchmarkDotNet

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.