You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// DurationTypeHelper.h
#pragma once
#include "DurationTypeArrayLeakComponent_h.h"
#include <wrl.h>
namespace ABI
{
namespace DurationTypeArrayLeakComponent
{
class DurationTypeHelper :
public Microsoft::WRL::ActivationFactory<IDurationTypeHelperStatics>
{
InspectableClassStatic(RuntimeClass_DurationTypeArrayLeakComponent_DurationTypeHelper, BaseTrust);
public:
DurationTypeHelper();
virtual HRESULT STDMETHODCALLTYPE CopyDurationTypesArray(UINT32 inTypesSize, ABI::Windows::UI::Xaml::DurationType* inTypes, UINT32 outTypesSize, ABI::Windows::UI::Xaml::DurationType* outTypes) override;
};
}
}
// DurationTypeHelper.cpp
#include "DurationTypeHelper.h"
using namespace ABI::DurationTypeArrayLeakComponent;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::Xaml;
DurationTypeHelper::DurationTypeHelper()
{
}
HRESULT STDMETHODCALLTYPE DurationTypeHelper::CopyDurationTypesArray(UINT32 inTypesSize, DurationType* inTypes, UINT32 outTypesSize, DurationType* outTypes)
{
if (inTypesSize != outTypesSize)
{
RoOriginateError(E_INVALIDARG, Microsoft::WRL::Wrappers::HStringReference(L"Array lengths must match.").Get());
return E_INVALIDARG;
}
for (UINT32 i = 0; i < inTypesSize; i++)
outTypes[i] = inTypes[i];
return S_OK;
}
ActivatableStaticOnlyFactory(DurationTypeHelper)
This C# code throws exception on CoreCLR (and desktop .NET too):
using DurationTypeArrayLeakComponent;
using System;
using Windows.UI.Xaml;
namespace DurationTypeArrayLeak
{
class Program
{
static void Main()
{
var types = new DurationType[]
{
DurationType.Automatic,
DurationType.Forever,
DurationType.TimeSpan,
DurationType.Forever,
DurationType.Automatic,
DurationType.TimeSpan
};
var typesCopy = new DurationType[types.Length];
DurationTypeHelper.CopyDurationTypesArray(types, typesCopy);
for (int i = 0; i < types.Length; i++)
{
if (types[i] != typesCopy[i])
throw new Exception("Type was not copied correctly.");
}
}
}
}
This doesn't happen on .NET Native. It seems the source of the problem is that the JIT passes 0 as array element size to MngdHiddenLengthArrayMarshaler::CreateMarshaler:
Given this C++ WinRT Component:
This C# code throws exception on CoreCLR (and desktop .NET too):
Full repro project: DurationTypeArrayLeak.zip
This doesn't happen on .NET Native. It seems the source of the problem is that the JIT passes 0 as array element size to MngdHiddenLengthArrayMarshaler::CreateMarshaler:
The text was updated successfully, but these errors were encountered: