Skip to content

Commit

Permalink
Use canonical method in TransitionFrames whenever we parse signatures (
Browse files Browse the repository at this point in the history
…#33733)

* Canonicalize arguments before loading instantiation when dropGenericArgumentLevel is TRUE

* Fix casing in COMPlus_GCStress env variable and remove COMPlus_gcServer

Also changing a bunch of assert() calls to _ASSERTE. Usually when _ASSERTE fails in CI lab runs, we tend to get crash dumps associated with test results, unlike assert() which shows a GUI dialog that DHandler dismisses by clicking on the Abort button.

* Remove gcstress switch.

The test will run with gcstress as part of the gcstress lab runs
  • Loading branch information
Fadi Hanna authored Apr 11, 2020
2 parents f9a753f + 5853df3 commit 7fe4e5b
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/coreclr/src/vm/gcenv.os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class GroupProcNo
GroupProcNo(uint16_t group, uint16_t procIndex) : m_groupProc((group << 6) | procIndex)
{
// Making this the same as the # of NUMA node we support.
assert(group < 0x40);
assert(procIndex <= 0x3f);
_ASSERTE(group < 0x40);
_ASSERTE(procIndex <= 0x3f);
}

uint16_t GetGroup() { return m_groupProc >> 6; }
Expand Down Expand Up @@ -120,7 +120,7 @@ bool GCToOSInterface::Initialize()
uint32_t currentProcessCpuCount = PAL_GetLogicalCpuCountFromOS();
if (PAL_GetCurrentThreadAffinitySet(AffinitySet::BitsetDataSize, g_processAffinitySet.GetBitsetData()))
{
assert(currentProcessCpuCount == g_processAffinitySet.Count());
_ASSERTE(currentProcessCpuCount == g_processAffinitySet.Count());
}
else
{
Expand Down Expand Up @@ -1322,31 +1322,31 @@ class GCEvent::Impl
{
WRAPPER_NO_CONTRACT;

assert(m_event.IsValid());
_ASSERTE(m_event.IsValid());
m_event.CloseEvent();
}

void Set()
{
WRAPPER_NO_CONTRACT;

assert(m_event.IsValid());
_ASSERTE(m_event.IsValid());
m_event.Set();
}

void Reset()
{
WRAPPER_NO_CONTRACT;

assert(m_event.IsValid());
_ASSERTE(m_event.IsValid());
m_event.Reset();
}

uint32_t Wait(uint32_t timeout, bool alertable)
{
WRAPPER_NO_CONTRACT;

assert(m_event.IsValid());
_ASSERTE(m_event.IsValid());
return m_event.Wait(timeout, alertable);
}

Expand Down Expand Up @@ -1400,31 +1400,31 @@ void GCEvent::CloseEvent()
{
WRAPPER_NO_CONTRACT;

assert(m_impl != nullptr);
_ASSERTE(m_impl != nullptr);
m_impl->CloseEvent();
}

void GCEvent::Set()
{
WRAPPER_NO_CONTRACT;

assert(m_impl != nullptr);
_ASSERTE(m_impl != nullptr);
m_impl->Set();
}

void GCEvent::Reset()
{
WRAPPER_NO_CONTRACT;

assert(m_impl != nullptr);
_ASSERTE(m_impl != nullptr);
m_impl->Reset();
}

uint32_t GCEvent::Wait(uint32_t timeout, bool alertable)
{
WRAPPER_NO_CONTRACT;

assert(m_impl != nullptr);
_ASSERTE(m_impl != nullptr);
return m_impl->Wait(timeout, alertable);
}

Expand All @@ -1435,7 +1435,7 @@ bool GCEvent::CreateManualEventNoThrow(bool initialState)
GC_NOTRIGGER;
} CONTRACTL_END;

assert(m_impl == nullptr);
_ASSERTE(m_impl == nullptr);
NewHolder<GCEvent::Impl> event = new (nothrow) GCEvent::Impl();
if (!event)
{
Expand All @@ -1454,7 +1454,7 @@ bool GCEvent::CreateAutoEventNoThrow(bool initialState)
GC_NOTRIGGER;
} CONTRACTL_END;

assert(m_impl == nullptr);
_ASSERTE(m_impl == nullptr);
NewHolder<GCEvent::Impl> event = new (nothrow) GCEvent::Impl();
if (!event)
{
Expand All @@ -1473,7 +1473,7 @@ bool GCEvent::CreateOSAutoEventNoThrow(bool initialState)
GC_NOTRIGGER;
} CONTRACTL_END;

assert(m_impl == nullptr);
_ASSERTE(m_impl == nullptr);
NewHolder<GCEvent::Impl> event = new (nothrow) GCEvent::Impl();
if (!event)
{
Expand All @@ -1492,7 +1492,7 @@ bool GCEvent::CreateOSManualEventNoThrow(bool initialState)
GC_NOTRIGGER;
} CONTRACTL_END;

assert(m_impl == nullptr);
_ASSERTE(m_impl == nullptr);
NewHolder<GCEvent::Impl> event = new (nothrow) GCEvent::Impl();
if (!event)
{
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/src/vm/siginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ TypeHandle SigPointer::GetTypeHandleThrowing(
if (tmpEType == ELEMENT_TYPE_CLASS)
typeHnd = TypeHandle(g_pCanonMethodTableClass);
}
else if ((elemType == (CorElementType) ELEMENT_TYPE_CANON_ZAPSIG) ||
else if ((elemType == (CorElementType)ELEMENT_TYPE_CANON_ZAPSIG) ||
(CorTypeInfo::GetGCType_NoThrow(elemType) == TYPE_GC_REF))
{
typeHnd = TypeHandle(g_pCanonMethodTableClass);
Expand Down Expand Up @@ -1389,6 +1389,11 @@ TypeHandle SigPointer::GetTypeHandleThrowing(
thisinst = NULL;
break;
}

if (dropGenericArgumentLevel && level == CLASS_LOAD_APPROXPARENTS)
{
typeHnd = ClassLoader::CanonicalizeGenericArg(typeHnd);
}
}
thisinst[i] = typeHnd;
IfFailThrowBF(psig.SkipExactlyOne(), BFA_BAD_SIGNATURE, pOrigModule);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;

public struct MyStruct<TRequest, TResponse>
{
int _id;
public MyStruct(int id) { _id = id; }
public override string ToString() => this.GetType().ToString() + " = " + _id;
}

public struct GenStruct<T> { }

public sealed class MyStructWrapper<TRequest, TResponse>
{
public MyStruct<TRequest, TResponse> _field;

public MyStructWrapper(MyStruct<TRequest, TResponse> value)
{
_field = value;
}

[MethodImpl(MethodImplOptions.NoInlining)]
public override string ToString() => _field.ToString();
}

public abstract class BaseStructCreator
{
public abstract MyStructWrapper<TRequest, TResponse> GetMyStructWrapper<TRequest, TResponse>() where TRequest : class;
}

public class StructCreator : BaseStructCreator
{
public override MyStructWrapper<TRequest, TResponse> GetMyStructWrapper<TRequest, TResponse>()
{
return new MyStructWrapper<TRequest, TResponse>(CreateCall<TRequest, TResponse>());
}
protected virtual MyStruct<TRequest, TResponse> CreateCall<TRequest, TResponse>() where TRequest : class
{
return new MyStruct<TRequest, TResponse>(123);
}
}

class DerivedCreator : StructCreator
{
protected override MyStruct<TRequest, TResponse> CreateCall<TRequest, TResponse>()
{
return new MyStruct<TRequest, TResponse>(456);
}
}

public class Test
{
[MethodImpl(MethodImplOptions.NoInlining)]
static string RunTest()
{
var creator = new DerivedCreator();
var wrapper = creator.GetMyStructWrapper<Exception, GenStruct<string>>();
return wrapper.ToString();
}
public static int Main()
{
Console.WriteLine("Expected: MyStruct`2[System.Exception,GenStruct`1[System.String]] = 456");

string result = RunTest();
Console.WriteLine("Actual : " + result);

string expected = "MyStruct`2[System.Exception,GenStruct`1[System.String]] = 456";
return result == expected ? 100 : -1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestKind>BuildAndRun</CLRTestKind>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 7fe4e5b

Please sign in to comment.