Open hez2010 opened 5 years ago
Thanks for reporting this!
This is an access violation around this stack
reproNative.exe!00007ff7c77cb878() Unknown
> reproNative.exe!S_P_CoreLib_System_Delegate__CreateObjectArrayDelegate() Line 758 Unknown
reproNative.exe!S_P_CoreLib_Internal_Runtime_Augments_DynamicDelegateAugments__CreateObjectArrayDelegate() Line 31 Unknown
reproNative.exe!System_Linq_Expressions_System_Dynamic_Utils_DelegateHelpers__CreateObjectArrayDelegate() Line 20 Unknown
reproNative.exe!System_Linq_Expressions_System_Linq_Expressions_Interpreter_LightLambda__MakeDelegate() Line 366 Unknown
reproNative.exe!System_Linq_Expressions_System_Linq_Expressions_Interpreter_LightDelegateCreator__CreateDelegate_0() Line 33 Unknown
reproNative.exe!System_Linq_Expressions_System_Linq_Expressions_Interpreter_LightDelegateCreator__CreateDelegate() Line 28 Unknown
reproNative.exe!System_Linq_Expressions_System_Linq_Expressions_LambdaExpression__Compile_0() Line 131 Unknown
reproNative.exe!System_Linq_Expressions_System_Linq_Expressions_LambdaExpression__Compile() Line 112 Unknown
reproNative.exe!repro_TypeTest_GenericNum_1<Int32>___ctor() Line 33 Unknown
reproNative.exe!repro_TypeTest_Program__Main() Line 94 Unknown
reproNative.exe!repro__Module___MainMethodWrapper() Unknown
We're failing to construct a Func<int, int, int>
and Func<int, int, bool>
delegate, but instead of throwing an exception, the reflection stack ends up using an incomplete delegate type (the one that was used in a cast in your repro) that is not suitable to be allocated.
You can work around by adding
new Func<int, int, int>((int x, int y) => x).ToString();
new Func<int, int, bool>((int x, int y) => false).ToString();
anywhere in your app.
As for the CoreRT fix, I think we'll want to filter the incomplete types in ExecutionEnvironmentImplementation.TryGetConstructedGenericTypeForComponents
, but I need to check what .NET Native does here (it's possible it promotes incomplete generic types to complete generic types).
Bug: The code below will cause program crashing during runtime
dotnet --info: