Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETW event Method/LoadVerbose contains wrong method signature for methods receiving function pointer (C#9) #60829

Closed
Temp1ar opened this issue Oct 25, 2021 · 5 comments · Fixed by #70923
Assignees
Milestone

Comments

@Temp1ar
Copy link

Temp1ar commented Oct 25, 2021

Description

For the method that receive function pointer I'm getting an LoadVerbose event with the value of MethodSignature representing the function pointer signature, not the actual method signature.

Reproduction Steps

  1. Compile console application for .net 6.0 with the following code
namespace TestSignatures;

unsafe class Example
{
  public void Foo(Action<int> a, delegate*<out double, in int, bool> f)
  {
    var i = 10d;
    var j = 1;
    a(42);
    Thread.Sleep(200);
    f(out i, in j);    
  }
    
  public void Foo(Action<int> a, in int b, out int c, ref int d)
  {
    var i = 10d;
    var j = 1;
    a(42);
    Thread.Sleep(200);
    c = j;
    d = b;
  }
}
  
public class Program
{
  public static void Main(string[] args)
  {
    unsafe 
    {
      var e = new Example();
      e.Foo(i => { }, &Method);
      var b = 0;
      var c = 0;
      var d = 0;
      e.Foo(i => { }, b, out c, ref d);
    }
  }
    
  private static bool Method(out double d, in int i) 
  {
    d = 10d;
    Thread.Sleep(200);
    return true;
  }
}

  1. Build application
  2. Profile application with the PerfView or any other ETW profiler
  3. Check the Method/LoadVerbose events, specifically the MethodSignature string field for methods with the name "Foo"

Expected behavior

I expect to see signatures like these:

instance void  (class System.Action`1<int32>,bool(required_modifier System.Runtime.InteropServices.OutAttribute float64&,required_modifier System.Runtime.InteropServices.InAttribute int32&))
instance void  (class System.Action`1<int32>,int32&,int32&,int32&)

Actual behavior

I see following signatures:

bool(required_modifier System.Runtime.InteropServices.OutAttribute float64&,required_modifier System.Runtime.InteropServices.InAttribute int32&)
instance void  (class System.Action`1<int32>,int32&,int32&,int32&)

Regression?

I believe it's broken since the addition of the function pointers to the language, but I'm not sure.

Known Workarounds

No response

Configuration

  • .NET 6.0
  • Windows 10
  • x64
  • I doubt

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Oct 25, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@jeffschwMSFT jeffschwMSFT added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 25, 2021
@ghost
Copy link

ghost commented Oct 25, 2021

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

For the method that receive function pointer I'm getting an LoadVerbose event with the value of MethodSignature representing the function pointer signature, not the actual method signature.

Reproduction Steps

  1. Compile console application for .net 6.0 with the following code
namespace TestSignatures;

unsafe class Example
{
  public void Foo(Action<int> a, delegate*<out double, in int, bool> f)
  {
    var i = 10d;
    var j = 1;
    a(42);
    Thread.Sleep(200);
    f(out i, in j);    
  }
    
  public void Foo(Action<int> a, in int b, out int c, ref int d)
  {
    var i = 10d;
    var j = 1;
    a(42);
    Thread.Sleep(200);
    c = j;
    d = b;
  }
}
  
public class Program
{
  public static void Main(string[] args)
  {
    unsafe 
    {
      var e = new Example();
      e.Foo(i => { }, &Method);
      var b = 0;
      var c = 0;
      var d = 0;
      e.Foo(i => { }, b, out c, ref d);
    }
  }
    
  private static bool Method(out double d, in int i) 
  {
    d = 10d;
    Thread.Sleep(200);
    return true;
  }
}

  1. Build application
  2. Profile application with the PerfView or any other ETW profiler
  3. Check the Method/LoadVerbose events, specifically the MethodSignature string field for methods with the name "Foo"

Expected behavior

I expect to see signatures like these:

instance void  (class System.Action`1<int32>,bool(required_modifier System.Runtime.InteropServices.OutAttribute float64&,required_modifier System.Runtime.InteropServices.InAttribute int32&))
instance void  (class System.Action`1<int32>,int32&,int32&,int32&)

Actual behavior

I see following signatures:

bool(required_modifier System.Runtime.InteropServices.OutAttribute float64&,required_modifier System.Runtime.InteropServices.InAttribute int32&)
instance void  (class System.Action`1<int32>,int32&,int32&,int32&)

Regression?

I believe it's broken since the addition of the function pointers to the language, but I'm not sure.

Known Workarounds

No response

Configuration

  • .NET 6.0
  • Windows 10
  • x64
  • I doubt

Other information

No response

Author: Temp1ar
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged

Milestone: -

@JulieLeeMSFT JulieLeeMSFT added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed untriaged New issue has not been triaged by the area owner labels Nov 2, 2021
@JulieLeeMSFT
Copy link
Member

@AndyAyersMS PTAL.

@AndyAyersMS
Copy link
Member

These events are generated by the runtime, so updating the area path.

@mangod9 I'm probably not the best person to fix this, can you reassign?

@AndyAyersMS AndyAyersMS added area-VM-coreclr and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Nov 2, 2021
@mangod9 mangod9 added this to the 7.0.0 milestone Nov 2, 2021
@mangod9 mangod9 assigned mangod9 and unassigned AndyAyersMS Nov 2, 2021
@AaronRobinsonMSFT
Copy link
Member

I see what is going on here. I will take this.

@AaronRobinsonMSFT AaronRobinsonMSFT removed the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Jun 18, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jun 18, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jun 18, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants