diagnostics icon indicating copy to clipboard operation
diagnostics copied to clipboard

!clrstack reports incorrect method names when <> is encountered

Open leculver opened this issue 2 years ago • 0 comments

When !clrstack encounters Program.<Main>(System.String[]), it trims the method name to: Program.(System.String[]). Both ClrMD and WinDbg (ICorDebug + IMetaDataReader) correctly return Program.<Main>(System.String[]).

I verified this with the main branch. I think the issue is that ClrStackImpl::PrintThread does not DML escape the MethodNameFromIP string we pass to TableOutput. It's not clear whether we should be specifically escaping in PrintThread or if TableOutput should do that.

To repro, create a .Net 8 app (preview), and add this code, and debug the resulting crash dump (or any async Main):

DivideData data = new()
{
    Numerator = 16,
    Denominator = 0,
};

Console.WriteLine($"{data.Numerator}/{data.Denominator} = {await DivideAsync(data)}");

static async Task<int> DivideAsync(DivideData divData)
{
    await Task.Delay(1000);

    return divData.Numerator / divData.Denominator;
}

class DivideData
{
    public int Numerator { get; set; }
    public int Denominator { get; set; }
}

(I'm working on other stuff at the moment, can't take this issue in the next two weeks. I was going to submit a quick fix, but there's not a globally defined DmlEscape.)

leculver avatar Oct 11 '23 22:10 leculver