Repository navigation
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
Hi,
I got unusual error I can't point a finger what's wrong with it, maybe a bug so I report it here.
Op jmp error on jump to generic delegate of value tuple of generic array,
.method public static !!T recursive<T>(
!!T Data,
class [mscorlib]System.Func`2<!!T,!!T> Recursive_method,
class [mscorlib]System.Func`2<!!T,bool> Stop_condition)
cil managed aggressiveinlining
{ .custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 )
.maxstack 3
ldarg.2 ldarg.0
callvirt instance !1 class [mscorlib]System.Func`2<!!T,bool>::Invoke(!0)
brfalse.s lb_recursive
ldarg.0 ret
lb_recursive:
ldarg.1 ldarg.0
callvirt instance !1 class [mscorlib]System.Func`2<!!T,!!T>::Invoke(!0)
// It's work fine with tail. call.
/*
ldarg.1 ldarg.2
tail. call !!0 Your_namespace.Your_static_class::recursive<!!0>(
!!0,
class [mscorlib]System.Func`2<!!0,!!0>,
class [mscorlib]System.Func`2<!!0,bool>)
*/
// But error when T is value tuple of generic array type.
starg.s 0
jmp !!0 Your_namespace.Your_static_class::recursive<!!0>(
!!0,
class [mscorlib]System.Func`2<!!0,!!0>,
class [mscorlib]System.Func`2<!!0,bool>)
ret
}
I test on some sample and found it only error when tuple with array type.
Public Function Test_recursion(Of T)(Input As T, Work As Func(Of T, T), Stop_c As Func(Of T, Boolean)) As T
If Stop_c(Input) Then Return Input
Input = Work(Input)
Return Test_recursion(Input, Work, Stop_c)
End Function
Public Sub main()
'// Work fine without any error
Console.WriteLine(
Your_namespace.recursive((Input:=5, sum:=1),
Function(Data) (Data.input - 1, Data.sum * Data.input),
Function(Data) Data.input < 2
).sum
)
Dim Input_data = (Input:={1, 2, 3, 4}, Index:=0, sum:=0)
Console.WriteLine(Test_recursion(Input_data,
Function(Data) (Data.Input, Data.Index + 1, Data.sum + Data.Input(Data.Index)),
Function(Data) Data.Index >= Data.Input.Length).sum)
'// Crash when run into this line, not a hint what's cause this error.
Console.WriteLine(Your_namespace.recursive(Input_data,
Function(Data) (Data.Input, Data.Index + 1, Data.sum + Data.Input(Data.Index)),
Function(Data) Data.Index >= Data.Input.Length).sum)
Console.ReadKey()
End Sub
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Activity
RussKeldorph commentedon Jan 16, 2019
@AndyAyersMS @briansull @dotnet/jit-contrib Does this look familiar?
AndyAyersMS commentedon Jan 16, 2019
Doesn't look familiar.
RussKeldorph commentedon Jan 16, 2019
Ok, assuming CodeGen until proven otherwise.
briansull commentedon Jan 18, 2019
Can you provide a complete repro case for this issue?
And what is the exact "error" that occurs?
Sounds like an A/V is the error.
briansull commentedon Jan 18, 2019
I also don't think that using a 'jmp; opcode is supported for generic methods and such methods have "hidden" parameters that need to be setup, such as the generic context.
RevensofT commentedon Jan 19, 2019
@briansull
I'm sorry, I might be post on wrong place, an error emerge at .Net framework CLR; I'm not sure coreclr work in the same way but the code I post is all I wrote and got this error, an error feedback just a generic error like I write some line wrong in CIL; I just create a console project to test "recursive"(I directly write in in .il) to help me do a tail recursion in VB.net.
In my opinion, jmp isn't much use on any case in .net so I assume it might be an unnotice bug occur on type checking because it's only error when a nest type is array.
briansull commentedon Jan 22, 2019
@RevensofT
The jmp opcode does not support the full set of possible call targets.
Instead it is recommended that you use the tail prefix opcode instead of using the jmp opcode.