Skip to content

DataTarget.CreateSnapshotAndAttach fails to disassemble generic type in Windows/CoreCLR #1334

@timcassell

Description

@timcassell

While working on dotnet/BenchmarkDotNet#2843, I found that using DataTarget.CreateSnapshotAndAttach in the same process fails to disassemble properly only on Windows and CoreCLR (.Net 8 in my case). It works fine in .Net Framework, and it also works fine in Linux. Thankfully it works with AttachToProcess in Windows, so I can use that as a workaround, but I figured I should raise this issue.

I tried 3.1.512801 and 4.0.0-beta.24360.3, same behavior on both.

The test that failed:

public class Generic<T> where T : new()
{
    [Benchmark]
    public T Create() => new T();
}

[Theory]
[MemberData(nameof(GetAllJits), DisableDiscoveryEnumeration = true)]
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleGenericTypes(Jit jit, Platform platform, IToolchain toolchain)
{
    if (OsDetector.IsMacOS()) return; // currently not supported

    var disassemblyDiagnoser = new DisassemblyDiagnoser(
        new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3));

    CanExecute<Generic<int>>(CreateConfig(jit, platform, toolchain, disassemblyDiagnoser, RunStrategy.Monitoring));

    var result = disassemblyDiagnoser.Results.Values.Single();

    Assert.Empty(result.Errors);
    Assert.Contains(result.Methods, method => method.Maps.Any(map => map.SourceCodes.OfType<Asm>().Any()));
}

https://github.com/dotnet/BenchmarkDotNet/blob/1c3faa21ab9aac8aab277e1fd19e151768c57cba/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs#L136-L159

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