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

Frozen collection tests fail on NativeAOT #88628

Closed
eerhardt opened this issue Jul 10, 2023 · 3 comments · Fixed by #89569
Closed

Frozen collection tests fail on NativeAOT #88628

eerhardt opened this issue Jul 10, 2023 · 3 comments · Fixed by #89569

Comments

@eerhardt
Copy link
Member

LookupItems_AllItemsFoundAsExpected test is failing on runtime-extra-platforms.

https://dev.azure.com/dnceng-public/public/_build/results?buildId=333900&view=results

System.NotSupportedException : 'Xunit.Sdk.AssertEqualityComparer1[System.Collections.Generic.HashSet1[System.Collections.Generic.KeyValuePair2[System.UIntPtr,System.UIntPtr]]].CompareTypedSets[System.Collections.Generic.KeyValuePair2[System.UIntPtr,System.UIntPtr]](https://dev.azure.com/dnceng-public/public/_build/results?buildId=333900&view=ms.vss-test-web.build-test-results-tab&runId=6918600&resultId=106768&paneView=debug)' is missing native code. MethodInfo.MakeGenericMethod() is not compatible with AOT compilation. Inspect and fix AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility

Stack trace
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.GetUncachedMethodInvoker(RuntimeTypeInfo[], MemberInfo) + 0x74
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.MakeGenericMethod(Type[]) + 0x1ff
   at System.Collections.Frozen.Tests.FrozenDictionary_Generic_Tests`2.LookupItems_AllItemsFoundAsExpected(Int32 size, IEqualityComparer`1 comparer, Boolean specifySameComparer) + 0x296
   at System.Collections.Immutable.Tests!<BaseAddress>+0xc2051e
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x167

This test failed in #78046 for the same reason. To fix that issue, we added an rd.xml file to ensure Int32 native code was generated during PublishAot.

However, with #88093, we now added more primitive types to the test - see System.UIntPtr above.

To fix this, we need to add more types to the rd.xml file that was added in #78005.

<Type Name="Xunit.Sdk.AssertEqualityComparer`1[[System.Collections.Generic.HashSet`1[[System.Collections.Generic.KeyValuePair`2[[System.UInt64, System.Private.CoreLib],[System.UInt64, System.Private.CoreLib]],System.Private.CoreLib]],System.Private.CoreLib]]" Dynamic="Required All">
<Method Name="CompareTypedSets" Dynamic="Required All">
<GenericArgument Name="System.Collections.Generic.KeyValuePair`2[[System.UInt64,System.Private.CoreLib],[System.UInt64,System.Private.CoreLib]],System.Private.CoreLib" />
</Method>
</Type>

cc @adamsitnik @VSadov

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 10, 2023
@ghost
Copy link

ghost commented Jul 10, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

LookupItems_AllItemsFoundAsExpected test is failing on runtime-extra-platforms.

https://dev.azure.com/dnceng-public/public/_build/results?buildId=333900&view=results

System.NotSupportedException : 'Xunit.Sdk.AssertEqualityComparer1[System.Collections.Generic.HashSet1[System.Collections.Generic.KeyValuePair2[System.UIntPtr,System.UIntPtr]]].CompareTypedSets[System.Collections.Generic.KeyValuePair2[System.UIntPtr,System.UIntPtr]](https://dev.azure.com/dnceng-public/public/_build/results?buildId=333900&view=ms.vss-test-web.build-test-results-tab&runId=6918600&resultId=106768&paneView=debug)' is missing native code. MethodInfo.MakeGenericMethod() is not compatible with AOT compilation. Inspect and fix AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility

Stack trace
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.GetUncachedMethodInvoker(RuntimeTypeInfo[], MemberInfo) + 0x74
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.MakeGenericMethod(Type[]) + 0x1ff
   at System.Collections.Frozen.Tests.FrozenDictionary_Generic_Tests`2.LookupItems_AllItemsFoundAsExpected(Int32 size, IEqualityComparer`1 comparer, Boolean specifySameComparer) + 0x296
   at System.Collections.Immutable.Tests!<BaseAddress>+0xc2051e
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x167

This test failed in #78046 for the same reason. To fix that issue, we added an rd.xml file to ensure Int32 native code was generated during PublishAot.

However, with #88093, we now added more primitive types to the test - see System.UIntPtr above.

To fix this, we need to add more types to the rd.xml file that was added in #78005.

<Type Name="Xunit.Sdk.AssertEqualityComparer`1[[System.Collections.Generic.HashSet`1[[System.Collections.Generic.KeyValuePair`2[[System.UInt64, System.Private.CoreLib],[System.UInt64, System.Private.CoreLib]],System.Private.CoreLib]],System.Private.CoreLib]]" Dynamic="Required All">
<Method Name="CompareTypedSets" Dynamic="Required All">
<GenericArgument Name="System.Collections.Generic.KeyValuePair`2[[System.UInt64,System.Private.CoreLib],[System.UInt64,System.Private.CoreLib]],System.Private.CoreLib" />
</Method>
</Type>

cc @adamsitnik @VSadov

Author: eerhardt
Assignees: -
Labels:

untriaged, area-NativeAOT-coreclr

Milestone: -

@ghost
Copy link

ghost commented Jul 10, 2023

Tagging subscribers to this area: @dotnet/area-system-collections
See info in area-owners.md if you want to be subscribed.

Issue Details

LookupItems_AllItemsFoundAsExpected test is failing on runtime-extra-platforms.

https://dev.azure.com/dnceng-public/public/_build/results?buildId=333900&view=results

System.NotSupportedException : 'Xunit.Sdk.AssertEqualityComparer1[System.Collections.Generic.HashSet1[System.Collections.Generic.KeyValuePair2[System.UIntPtr,System.UIntPtr]]].CompareTypedSets[System.Collections.Generic.KeyValuePair2[System.UIntPtr,System.UIntPtr]](https://dev.azure.com/dnceng-public/public/_build/results?buildId=333900&view=ms.vss-test-web.build-test-results-tab&runId=6918600&resultId=106768&paneView=debug)' is missing native code. MethodInfo.MakeGenericMethod() is not compatible with AOT compilation. Inspect and fix AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility

Stack trace
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.GetUncachedMethodInvoker(RuntimeTypeInfo[], MemberInfo) + 0x74
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.MakeGenericMethod(Type[]) + 0x1ff
   at System.Collections.Frozen.Tests.FrozenDictionary_Generic_Tests`2.LookupItems_AllItemsFoundAsExpected(Int32 size, IEqualityComparer`1 comparer, Boolean specifySameComparer) + 0x296
   at System.Collections.Immutable.Tests!<BaseAddress>+0xc2051e
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x167

This test failed in #78046 for the same reason. To fix that issue, we added an rd.xml file to ensure Int32 native code was generated during PublishAot.

However, with #88093, we now added more primitive types to the test - see System.UIntPtr above.

To fix this, we need to add more types to the rd.xml file that was added in #78005.

<Type Name="Xunit.Sdk.AssertEqualityComparer`1[[System.Collections.Generic.HashSet`1[[System.Collections.Generic.KeyValuePair`2[[System.UInt64, System.Private.CoreLib],[System.UInt64, System.Private.CoreLib]],System.Private.CoreLib]],System.Private.CoreLib]]" Dynamic="Required All">
<Method Name="CompareTypedSets" Dynamic="Required All">
<GenericArgument Name="System.Collections.Generic.KeyValuePair`2[[System.UInt64,System.Private.CoreLib],[System.UInt64,System.Private.CoreLib]],System.Private.CoreLib" />
</Method>
</Type>

cc @adamsitnik @VSadov

Author: eerhardt
Assignees: -
Labels:

area-System.Collections, untriaged, test-failure

Milestone: -

@eerhardt eerhardt added the blocking-clean-ci-optional Blocking optional rolling runs label Jul 10, 2023
@eiriktsarpalis eiriktsarpalis removed the untriaged New issue has not been triaged by the area owner label Jul 12, 2023
@eiriktsarpalis eiriktsarpalis added this to the 8.0.0 milestone Jul 12, 2023
@eiriktsarpalis
Copy link
Member

Another alternative is replacing the AOT-unfriendly assert method with the one we keep in AssertExtensions.cs:

public static void Equal<T>(HashSet<T> expected, HashSet<T> actual)
{
if (!actual.SetEquals(expected))
{
throw new XunitException($"Expected: {string.Join(", ", expected)}{Environment.NewLine}Actual: {string.Join(", ", actual)}");
}
}

eiriktsarpalis added a commit to eiriktsarpalis/runtime that referenced this issue Jul 27, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 27, 2023
eiriktsarpalis added a commit that referenced this issue Jul 27, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 27, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 26, 2023
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.

2 participants