Skip to content

Rewriting methods on ConcurrentDictionary throws exception on .NET 6, 7, and 8 #55

@Miista

Description

@Miista

As part of #54 we disabled rewriting methods on ConcurrentDictionary. We did this because doing so would result in the following errors (detailed error messages follow below table):

Runtime Error
.NET 6 System.InvalidProgramException: Common Language Runtime detected an invalid program.
.NET 7 System.InvalidProgramException: Common Language Runtime detected an invalid program.
.NET 8 System.BadImageFormatException: Bad IL format.

.NET 6 error message

System.InvalidProgramException
Common Language Runtime detected an invalid program.
   at stub_callvirt_System.Object_GetHashCode(String& )
   at impl_System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]]_TryAddInternal(ConcurrentDictionary`2 , String , Nullable`1 , ConcurrentDictionary`2 , Boolean , Boolean , ConcurrentDictionary`2& )
   at stub_call_System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]]_TryAddInternal(ConcurrentDictionary`2 , String , Nullable`1 , ConcurrentDictionary`2 , Boolean , Boolean , ConcurrentDictionary`2& )
   at impl_System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]]_set_Item(ConcurrentDictionary`2 , String , ConcurrentDictionary`2 )
   at stub_callvirt_System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]]_set_Item(ConcurrentDictionary`2 , String , ConcurrentDictionary`2 )
   at impl_Pose.Tests.LolObject_LolMethod(LolObject )
   at stub_callvirt_Pose.Tests.LolObject_LolMethod(LolObject )
   at impl_Pose.Tests.RegressionTests+<>c__DisplayClass2_0_<Can_devirtualize_methods>b__2(<>c__DisplayClass2_0 )

.NET 7 error message

System.InvalidProgramException: Common Language Runtime detected an invalid program.

System.InvalidProgramException
Common Language Runtime detected an invalid program.
   at stub_callvirt_System.Object_GetHashCode(String&)
   at impl_System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]]_TryAddInternal(ConcurrentDictionary`2, String, Nullable`1, ConcurrentDictionary`2, Boolean, Boolean, ConcurrentDictionary`2&)
   at stub_call_System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]]_TryAddInternal(ConcurrentDictionary`2, String, Nullable`1, ConcurrentDictionary`2, Boolean, Boolean, ConcurrentDictionary`2&)
   at impl_System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]]_set_Item(ConcurrentDictionary`2, String, ConcurrentDictionary`2)
   at stub_callvirt_System.Collections.Concurrent.ConcurrentDictionary`2[System.String,System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]]_set_Item(ConcurrentDictionary`2, String, ConcurrentDictionary`2)
   at impl_Pose.Tests.LolObject_LolMethod(LolObject)
   at stub_callvirt_Pose.Tests.LolObject_LolMethod(LolObject)
   at impl_Pose.Tests.RegressionTests+<>c__DisplayClass2_0_<Can_devirtualize_methods>b__2(<>c__DisplayClass2_0)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

.NET 8 error message

System.BadImageFormatException
Bad IL format.
   at stub_call_System.Numerics.INumberBase`1[System.Int32]_IsNegative(Int32)
   at impl_System.ArgumentOutOfRangeException_ThrowIfNegative[Int32](Int32, String)
   at stub_call_System.ArgumentOutOfRangeException_ThrowIfNegative[Int32](Int32, String)
   at impl_System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]_.ctor(ConcurrentDictionary`2, Int32, Int32, Boolean, IEqualityComparer`1)
   at stub_call_System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]_.ctor(ConcurrentDictionary`2, Int32, Int32, Boolean, IEqualityComparer`1)
   at impl_System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]_.ctor(ConcurrentDictionary`2)
   at stub_newobj_System.Collections.Concurrent.ConcurrentDictionary`2[Pose.Tests.ICollectionClass,Pose.Tests.ICollectionClass]_.ctor()
   at impl_Pose.Tests.LolObject_LolMethod(LolObject)
   at stub_callvirt_Pose.Tests.LolObject_LolMethod(LolObject)
   at impl_Pose.Tests.RegressionTests+<>c__DisplayClass2_0_<Can_devirtualize_methods>b__2(<>c__DisplayClass2_0)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: lowThe issue has low priorityquestion/investigationFurther information or investigation is required

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions