Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e24179e
[release/8.0-staging] [browser] Use whole assembly name when looking …
maraf Jan 19, 2024
5e9e29f
[release/8.0][browser] BrowserWebSocket.ReceiveAsync after server ini…
pavelsavara Jan 23, 2024
fe443a9
[release/8.0][mono][debugger] Debugger improvements on .net8 (#97160)
thaystg Jan 24, 2024
d7a4118
[release/8.0-staging] Add additionalSize for the DisableOptData (#97479)
github-actions[bot] Jan 26, 2024
1901707
[release/8.0-staging] Bump to new Ubuntu 22.04 queue for PPC64 (#97555)
github-actions[bot] Jan 26, 2024
b54886b
[release/8.0-staging] Fix compilation error with generic type attribu…
github-actions[bot] Jan 31, 2024
e6d8079
Remove use of NewHolder as field. (#97843)
github-actions[bot] Feb 6, 2024
b0025c7
[release/8.0-staging] Update dependencies from dotnet/runtime-assets …
dotnet-maestro[bot] Feb 7, 2024
d8042d4
Update dependencies from https://github.com/dotnet/hotreload-utils bu…
dotnet-maestro[bot] Feb 7, 2024
c2415d7
[release/8.0] Fix STJ SG regression in handling of property names tha…
eiriktsarpalis Feb 8, 2024
2663ba6
Update SystemDataSqlClientVersion from 4.8.5 -> 4.8.6 for component g…
github-actions[bot] Feb 8, 2024
d62ff0b
Disable jiterpreter_do_jit_call to address issues with disabling Wasm…
kg Feb 8, 2024
53c1d13
Fixes exception while debugging on Chrome as IDE (#97871)
github-actions[bot] Feb 9, 2024
ea2b2e8
Backport #97418 (#97568)
thaystg Feb 9, 2024
279fe23
Update dependencies from https://github.com/dotnet/runtime-assets bui…
dotnet-maestro[bot] Feb 9, 2024
eded9a5
[release/8.0-staging] Ensure that the Create(Dot(...)) optimization d…
github-actions[bot] Feb 9, 2024
a143568
Don't clean up thread list on shutdown (#97188)
github-actions[bot] Feb 9, 2024
2767a15
[mono][interp] Fix inlining of ldarga (#97650)
BrzVlad Feb 9, 2024
ef1b0d6
[release/8.0-staging] [mono][jit] Fix passing of byref arguments in m…
vargaz Feb 9, 2024
4b040aa
Stop trying to format HOST_RUNTIME_CONTRACT property with locale sett…
elinor-fung Feb 9, 2024
6cd0edd
Backport of Handle open types to appear in interface maps (#97733) to…
davidwrighton Feb 9, 2024
c804f58
[release/8.0-staging] Move a lock to protect m_pDynamicStaticsInfo (#…
github-actions[bot] Feb 9, 2024
f4075f3
Ensure that constant folding for SIMD shifts on xarch follow the corr…
tannergooding Feb 10, 2024
d45a576
[release/8.0-staging] Ensure that the various `Max*Number` and `Min*N…
github-actions[bot] Feb 10, 2024
ff4e048
Define installer-owned directories (#98241)
github-actions[bot] Feb 11, 2024
2190e9b
Fix Windows implementation of NegotiateAuthenticationPal.GetMIC (#98031)
filipnavara Feb 12, 2024
dedae5e
[release/8.0-staging] Fix constant folding for arm64 MultiplyByScalar…
jakobbotsch Feb 12, 2024
bb540a8
[NativeAOT][8.0] Use ld_classic in ILC build and in build integration…
VSadov Feb 12, 2024
ba68cf1
Fix side effect of only not sending assembly_load while invoking meth…
github-actions[bot] Feb 12, 2024
6dec8dd
Fix polluted CompareState when comparing element types in a signature…
elinor-fung Feb 12, 2024
9598872
[release/8.0-staging] Update dependencies from dotnet/emsdk (#97405)
dotnet-maestro[bot] Feb 12, 2024
11ae42b
[release/8.0-staging] Fix regex lazy loop handling of backtracking st…
github-actions[bot] Feb 12, 2024
b7fda9f
Add ca-certificates to Mariner 2.0 deps (#98267)
github-actions[bot] Feb 12, 2024
00c95a6
[release/8.0-staging] Ensure that Vector512 uses the same patterns as…
github-actions[bot] Feb 12, 2024
c192fba
[release/8.0-staging] Implement faster RSA key check
github-actions[bot] Feb 12, 2024
11a4ff1
[release/8.0-staging] ServiceKey comparisons use Equals for matching …
github-actions[bot] Feb 12, 2024
ec1636f
Merge branch 'release/8.0' into release/8.0-staging
carlossanlop Feb 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix polluted CompareState when comparing element types in a signature (
…#98249)

We were propagating state from each type in the method signature to the
comparisons for the next type. This resulted in type equivalence checks
being disabled for any parameters that came after a generic parameter.
  • Loading branch information
elinor-fung authored Feb 12, 2024
commit 6dec8dd10ca45d925fb3577be9cfd44a4822b7fc
12 changes: 6 additions & 6 deletions src/coreclr/vm/siginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4204,8 +4204,6 @@ MetaSig::CompareTypeDefsUnderSubstitutions(
SigPointer inst1 = pSubst1->GetInst();
SigPointer inst2 = pSubst2->GetInst();

TokenPairList visited { pVisited };
CompareState state{ &visited };
for (DWORD i = 0; i < pTypeDef1->GetNumGenericArgs(); i++)
{
PCCOR_SIGNATURE startInst1 = inst1.GetPtr();
Expand All @@ -4214,6 +4212,8 @@ MetaSig::CompareTypeDefsUnderSubstitutions(
PCCOR_SIGNATURE startInst2 = inst2.GetPtr();
IfFailThrow(inst2.SkipExactlyOne());
PCCOR_SIGNATURE endInst2ptr = inst2.GetPtr();
TokenPairList visited{ pVisited };
CompareState state{ &visited };
if (!CompareElementType(
startInst1,
startInst2,
Expand Down Expand Up @@ -4382,8 +4382,6 @@ MetaSig::CompareMethodSigs(
IfFailThrow(CorSigUncompressData_EndPtr(pSig1, pEndSig1, &ArgCount1));
IfFailThrow(CorSigUncompressData_EndPtr(pSig2, pEndSig2, &ArgCount2));

TokenPairList visited{ pVisited };

if (ArgCount1 != ArgCount2)
{
if ((callConv & IMAGE_CEE_CS_CALLCONV_MASK) != IMAGE_CEE_CS_CALLCONV_VARARG)
Expand All @@ -4405,7 +4403,6 @@ MetaSig::CompareMethodSigs(
// to correctly handle overloads, where there are a number of varargs methods
// to pick from, like m1(int,...) and m2(int,int,...), etc.

CompareState state{ &visited };
// <= because we want to include a check of the return value!
for (i = 0; i <= ArgCount1; i++)
{
Expand Down Expand Up @@ -4437,6 +4434,8 @@ MetaSig::CompareMethodSigs(
else
{
// We are in bounds on both sides. Compare the element.
TokenPairList visited{ pVisited };
CompareState state{ &visited };
if (!CompareElementType(
pSig1,
pSig2,
Expand All @@ -4461,7 +4460,6 @@ MetaSig::CompareMethodSigs(
}

// do return type as well
CompareState state{ &visited };
for (i = 0; i <= ArgCount1; i++)
{
if (i == 0 && skipReturnTypeSig)
Expand All @@ -4476,6 +4474,8 @@ MetaSig::CompareMethodSigs(
}
else
{
TokenPairList visited{ pVisited };
CompareState state{ &visited };
if (!CompareElementType(
pSig1,
pSig2,
Expand Down
6 changes: 6 additions & 0 deletions src/tests/baseservices/typeequivalence/contracts/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public interface ISparseType
int MultiplyBy20(int a);
}

[Guid("BD752276-52DF-4CD1-8C62-49D202F15C8D")]
public struct TestValueType
{
public int Field;
}

//
// Below types are used in type punning tests and shouldn't be used anywhere else.
//
Expand Down
12 changes: 12 additions & 0 deletions src/tests/baseservices/typeequivalence/impl/Impls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,15 @@ public static int GetField_3(OnlyLoadOnce_3 s)
return s.Field;
}
}

public static class MethodCall
{
// Include a generic type in the method signature before the type using type equivalence to ensure that
// processing of the generic type does not affect subsequent type processing during signature comparison.
public static System.Collections.Generic.List<int> InterfaceAfterGeneric(IEmptyType t) => null;
public static System.Collections.Generic.List<int> ValueTypeAfterGeneric(TestValueType t) => null;

// Generic type after the type using type equivalence should also not affect processing.
public static void InterfaceBeforeGeneric(IEmptyType t, System.Collections.Generic.List<int> l) { }
public static void ValueTypeBeforeGeneric(TestValueType t, System.Collections.Generic.List<int> l) { }
}
87 changes: 44 additions & 43 deletions src/tests/baseservices/typeequivalence/simple/Simple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public struct EquivalentValueType
public int A;
}

[PlatformSpecific(TestPlatforms.Windows)]
public class Simple
{
private class EmptyType2 : IEmptyType
Expand All @@ -30,7 +31,8 @@ public static object Create()
}
}

private static void InterfaceTypesFromDifferentAssembliesAreEquivalent()
[Fact]
public static void InterfaceTypesFromDifferentAssembliesAreEquivalent()
{
Console.WriteLine($"{nameof(InterfaceTypesFromDifferentAssembliesAreEquivalent)}");
var inAsm = EmptyType.Create();
Expand All @@ -44,9 +46,10 @@ void AreNotSameObject(IEmptyType a, IEmptyType b)
}
}

private static void ValidateTypeInstanceEquality()
[Fact]
public static void TypeInstanceEquality()
{
Console.WriteLine($"{nameof(ValidateTypeInstanceEquality)}");
Console.WriteLine($"{nameof(TypeInstanceEquality)}");
var inAsm = EmptyType.Create();
var otherAsm = EmptyType2.Create();

Expand Down Expand Up @@ -110,7 +113,8 @@ public override string ScaleString(string s)
}
}

private static void InterfaceTypesMethodOperations()
[Fact]
public static void InterfaceTypesMethodOperations()
{
Console.WriteLine($"{nameof(InterfaceTypesMethodOperations)}");

Expand Down Expand Up @@ -141,7 +145,8 @@ private static void InterfaceTypesMethodOperations()
}
}

private static void CallSparseInterface()
[Fact]
public static void CallSparseInterface()
{
Console.WriteLine($"{nameof(CallSparseInterface)}");

Expand All @@ -156,9 +161,10 @@ private static void CallSparseInterface()
Assert.Equal(input * 18, sparseType.MultiplyBy18(input));
}

private static void TestArrayEquivalence()
[Fact]
public static void ArrayEquivalence()
{
Console.WriteLine($"{nameof(TestArrayEquivalence)}");
Console.WriteLine($"{nameof(ArrayEquivalence)}");
var inAsm = EmptyType.Create();
var otherAsm = EmptyType2.Create();

Expand All @@ -173,9 +179,10 @@ private static void TestArrayEquivalence()
Assert.False(inAsmInterfaceType.MakeArrayType(1).IsEquivalentTo(otherAsmInterfaceType.MakeArrayType(2)));
}

private static void TestByRefEquivalence()
[Fact]
public static void ByRefEquivalence()
{
Console.WriteLine($"{nameof(TestByRefEquivalence)}");
Console.WriteLine($"{nameof(ByRefEquivalence)}");
var inAsm = EmptyType.Create();
var otherAsm = EmptyType2.Create();

Expand All @@ -197,9 +204,10 @@ public void Method(V input)
}
}

private static void TestGenericClassNonEquivalence()
[Fact]
public static void GenericClassNonEquivalence()
{
Console.WriteLine($"{nameof(TestGenericClassNonEquivalence)}");
Console.WriteLine($"{nameof(GenericClassNonEquivalence)}");
var inAsm = EmptyType.Create();
var otherAsm = EmptyType2.Create();

Expand All @@ -209,9 +217,10 @@ private static void TestGenericClassNonEquivalence()
Assert.False(typeof(Generic<>).MakeGenericType(inAsmInterfaceType).IsEquivalentTo(typeof(Generic<>).MakeGenericType(otherAsmInterfaceType)));
}

private static void TestGenericInterfaceEquivalence()
[Fact]
public static void GenericInterfaceEquivalence()
{
Console.WriteLine($"{nameof(TestGenericInterfaceEquivalence)}");
Console.WriteLine($"{nameof(GenericInterfaceEquivalence)}");
var inAsm = EmptyType.Create();
var otherAsm = EmptyType2.Create();

Expand All @@ -221,9 +230,10 @@ private static void TestGenericInterfaceEquivalence()
Assert.True(typeof(IGeneric<>).MakeGenericType(inAsmInterfaceType).IsEquivalentTo(typeof(IGeneric<>).MakeGenericType(otherAsmInterfaceType)));
}

private static unsafe void TestTypeEquivalenceWithTypePunning()
[Fact]
public static unsafe void TypeEquivalenceWithTypePunning()
{
Console.WriteLine($"{nameof(TestTypeEquivalenceWithTypePunning)}");
Console.WriteLine($"{nameof(TypeEquivalenceWithTypePunning)}");

{
Console.WriteLine($"-- GetFunctionPointer()");
Expand Down Expand Up @@ -260,10 +270,11 @@ private static unsafe void TestTypeEquivalenceWithTypePunning()
}
}

[Fact]
[MethodImpl (MethodImplOptions.NoInlining)]
private static void TestLoadingValueTypesWithMethod()
public static void LoadValueTypesWithMethod()
{
Console.WriteLine($"{nameof(TestLoadingValueTypesWithMethod)}");
Console.WriteLine($"{nameof(LoadValueTypesWithMethod)}");
Console.WriteLine($"-- {typeof(ValueTypeWithStaticMethod).Name}");
Assert.Throws<TypeLoadException>(() => LoadInvalidType());
}
Expand All @@ -274,7 +285,8 @@ private static void LoadInvalidType()
Console.WriteLine($"-- {typeof(ValueTypeWithInstanceMethod).Name}");
}

private static void TestCastsOptimizations()
[Fact]
public static void CastsOptimizations()
{
string otherTypeName = $"{typeof(EquivalentValueType).FullName},{typeof(EmptyType).Assembly.GetName().Name}";
Type otherEquivalentValueType = Type.GetType(otherTypeName);
Expand All @@ -285,32 +297,21 @@ private static void TestCastsOptimizations()
EquivalentValueType inst = (EquivalentValueType)otherEquivalentValueTypeInstance;
}

public static int Main()
[Fact]
public static void MethodCallSignature()
{
if (!OperatingSystem.IsWindows())
{
return 100;
}
try
{
InterfaceTypesFromDifferentAssembliesAreEquivalent();
ValidateTypeInstanceEquality();
InterfaceTypesMethodOperations();
CallSparseInterface();
TestByRefEquivalence();
TestArrayEquivalence();
TestGenericClassNonEquivalence();
TestGenericInterfaceEquivalence();
TestTypeEquivalenceWithTypePunning();
TestLoadingValueTypesWithMethod();
TestCastsOptimizations();
}
catch (Exception e)
{
Console.WriteLine($"Test Failure: {e}");
return 101;
}
Console.WriteLine($"{nameof(MethodCallSignature)}");

Console.WriteLine($"-- {nameof(MethodCall.InterfaceAfterGeneric)}");
MethodCall.InterfaceAfterGeneric((IEmptyType)EmptyType2.Create());

Console.WriteLine($"-- {nameof(MethodCall.ValueTypeAfterGeneric)}");
MethodCall.ValueTypeAfterGeneric(new TestValueType());

Console.WriteLine($"-- {nameof(MethodCall.InterfaceBeforeGeneric)}");
MethodCall.InterfaceBeforeGeneric((IEmptyType)EmptyType2.Create(), null);

return 100;
Console.WriteLine($"-- {nameof(MethodCall.ValueTypeBeforeGeneric)}");
MethodCall.ValueTypeBeforeGeneric(new TestValueType(), null);
}
}