Skip to content

Benchmark process freeze when running DisassemblyDiagnoserTests with xUnit v3 on macos(x64/arm64) #3076

Description

@filzrev

I'm trying to update BenchmarkDotNet tests to use xUnit v3. (#3065)

But DisassemblyDiagnoserTests cause freeze and cause CI timeout(6h) when running tests with xUnit v3 on macos(x64/arm64)

It's not happen on following conditions.

  1. Running tests on other OS (Windows/Ubuntu).
  2. Run benchmark with dotnet run command on macos

So I'm suspecting the issue has caused by SynchronizationContext(xUnit/BenchmarkDotNet) related problem,
But I don't have any proof.

Minimum reproduceable example code
https://github.com/filzrev/test_ci_on_macos

Activity

  1. filzrev commented on Apr 6, 2026

    @filzrev
    ContributorAuthor

    It seems following DiagnosticsClient::WriteDump method causing timeout.

    if (OsDetector.IsMacOS())
    {
    // ClrMD does not support CreateSnapshotAndAttach on MacOS, and AttachToProcess is unreliable, so we have to create a dump file and load it.
    string dumpPath = Path.GetTempFileName();
    try
    {
    try
    {
    new DiagnosticsClient(processId).WriteDump(DumpType.Full, dumpPath, logDumpGeneration: false);
    }
    catch (ServerErrorException sxe)
    {
    throw new ArgumentException($"Unable to create a snapshot of process {processId:x}.", sxe);
    }
    return DataTarget.LoadDump(dumpPath);
    }
    finally
    {
    File.Delete(dumpPath);
    }

    I don't knows why it cause freeze when benchmark running under xUnit v3.

  2. timcassell commented on Apr 6, 2026

    @timcassell
    Collaborator

    It sounds like an xUnit or DiagnosticsClient bug. Can you repro with just that code in a test?

  3. timcassell commented on Apr 6, 2026

    @timcassell
    Collaborator

    Also can you try updating Microsoft.Diagnostics.NETCore.Client? It looks like the dependent version from ClrMD is quite old now.

    Could also try the new 4.0.0-beta.26203.1 version of ClrMD.

  4. filzrev commented on Apr 8, 2026

    @filzrev
    ContributorAuthor

    It can be reproduced with simple console application without using BenchmarkDotNet/xUnit.v3/dotnet test

    On macos(x64/arm64).
    WriteDump method stop processing after outputting following logs.

    [createdump] 00030bc6 TickFrequency: 1000000 ticks per ms
    [createdump] 00030bc6 PAGE_SIZE 4096

    It might be there is an issue when creating dump self process on macos environment.

    Additionally, I've tries following changes, but it seems there is no behavior differences.

    • Create dump with dotnet-dump command.
    • Try to use WriteDump/WriteDumpAsync methods
    • Update ClrMD and Microsoft.Diagnostics.NETCore.Client versions
    • Add ConfigureAwait(false)
  5. timcassell commented on Apr 8, 2026

    @timcassell
    Collaborator

    Since you can repro separately, it's clearly an issue with the diagnostics client getting stuck on something from xUnit, nothing we can do here. Please report the bug to dotnet/runtime. You can add a link to the runtime issue in the skip reason.

  6. filzrev commented on Apr 9, 2026

    @filzrev
    ContributorAuthor

    I've found createdump on macos issue is tracked by dotnet/runtime#119945.

    Dump works as expected when disable AppHost with <UseAppHost>false</UseAppHost> setting.

    Though, xunit.v3 requires AppHost existence
    It need to skip related benchmarks on macos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions