-
Notifications
You must be signed in to change notification settings - Fork 356
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
DumpIL SOS command does not properly handle DynamicMethods in .NET Core #4850
Comments
Do you have a simple test app that creates a dynamic method? |
Here's a simple test app I wrote recently that generates a continuous stream of DynamicMethod objects. You should be able to tweak this to your needs. using System.Reflection.Emit;
using System.Runtime.CompilerServices;
namespace TestInfiniteDynamicMethods
{
internal class Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
static Func<int, int> GetFibDynamicMethod()
{
DynamicMethod dynamicMethod = new DynamicMethod("Fibonacci", typeof(int), new Type[] { typeof(int) });
ILGenerator ilgen = dynamicMethod.GetILGenerator();
Label labelAfterCmp0 = ilgen.DefineLabel();
ilgen.Emit(OpCodes.Ldarg_0);
ilgen.Emit(OpCodes.Ldc_I4_0);
ilgen.Emit(OpCodes.Bne_Un_S, labelAfterCmp0);
ilgen.Emit(OpCodes.Ldc_I4_0);
ilgen.Emit(OpCodes.Ret);
ilgen.MarkLabel(labelAfterCmp0);
Label labelAfterCmp1 = ilgen.DefineLabel();
ilgen.Emit(OpCodes.Ldarg_0);
ilgen.Emit(OpCodes.Ldc_I4_1);
ilgen.Emit(OpCodes.Bne_Un_S, labelAfterCmp1);
ilgen.Emit(OpCodes.Ldc_I4_1);
ilgen.Emit(OpCodes.Ret);
ilgen.MarkLabel(labelAfterCmp1);
ilgen.Emit(OpCodes.Ldarg_0);
ilgen.Emit(OpCodes.Ldc_I4_1);
ilgen.Emit(OpCodes.Sub);
ilgen.Emit(OpCodes.Call, dynamicMethod);
ilgen.Emit(OpCodes.Ldarg_0);
ilgen.Emit(OpCodes.Ldc_I4_2);
ilgen.Emit(OpCodes.Sub);
ilgen.Emit(OpCodes.Call, dynamicMethod);
ilgen.Emit(OpCodes.Add);
ilgen.Emit(OpCodes.Ret);
return dynamicMethod.CreateDelegate<Func<int, int>>();
}
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
int count = 0;
while (true)
{
GetFibDynamicMethod()(4);
if (((++count) % 200) == 0)
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
if (((++count) % 1000) == 0)
Console.WriteLine(count);
}
}
}
} |
mikem8361
added a commit
that referenced
this issue
Sep 12, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
Configuration
Any vaguely recent .NET Core build.
Regression?
This probably works targeting the .NET Framework
Other information
It appears that at some point in time the fields on the
System.Reflection.Emit.DynamicMethod
object were changed to change them_
prefix to_
. In addition, a few other fields look to have changed their name entirely.GatherDynamicInfo
in the SOS codebase appears to need to be updated to handle the newer paths, and we probably need some testing for this scenario.The text was updated successfully, but these errors were encountered: