Bugzilla – Bug 321544
[verifier] Mono 1.1.16 crashes on valid tailcall code
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by bbjamey@gmail.com 2006-07-11 19:50:43 MST ---- Description of Problem: Mono 1.1.16 crashes on valid tailcall+generics code Steps to reproduce the problem: 1. ILASM and run the IL code below (e.g. using .NET ILASM). This works on .NET Windows. Mono gives Unhandled Exception: System.InvalidProgramException: Invalid IL code in Maine:M2 (int,int): IL_0024: call 0x2b000001 at <0x00000> <unknown method> at Maine.Main () [0x00000] // Microsoft (R) .NET Framework IL Disassembler. Version 2.0.50727.42 // Copyright (c) Microsoft Corporation. All rights reserved. // Metadata version: v2.0.50727 .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 2:0:0:0 } .assembly bug { .custom instance void [mscorlib] System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor (int32) = ( 01 00 08 00 00 00 00 00 ) .custom instance void [mscorlib] System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. .hash algorithm 0x00008004 .ver 0:0:0:0 } .module bug.exe // MVID: {2529DA8A-C8D4-4653-BA0C-4DC9C45594EB} .imagebase 0x00400000 .file alignment 0x00000200 .stackreserve 0x00100000 .subsystem 0x0003 // WINDOWS_CUI .corflags 0x00000001 // ILONLY // Image base: 0x00EF0000 // =============== CLASS MEMBERS DECLARATION =================== .class private auto ansi beforefieldinit Maine extends [mscorlib]System.Object { .method private hidebysig static class [mscorlib] System.Collections.Generic.List`1<!!T> M1<T,U>(class [mscorlib]System.Collections.Generic.List`1<!!T> a, !!U b) cil managed { // Code size 19 (0x13) .maxstack 2 .locals init (class [mscorlib]System.Collections.Generic.List`1<!!T> V_0) IL_0000: nop IL_0001: ldarg.0 IL_0002: callvirt instance int32 class [mscorlib] System.Collections.Generic.List`1<!!T>::get_Count() IL_0007: ldc.i4.0 IL_0008: blt.s IL_000d IL_000a: ldarg.0 IL_000b: br.s IL_000e IL_000d: ldarg.0 IL_000e: stloc.0 IL_000f: br.s IL_0011 IL_0011: ldloc.0 IL_0012: ret } // end of method Maine::M1 .method private hidebysig static class [mscorlib] System.Collections.Generic.List`1<int32> M2<T>(int32 x, !!T y) cil managed { // Code size 44 (0x2c) .maxstack 2 .locals init (class [mscorlib] System.Collections.Generic.List`1<int32> V_0, bool V_1) IL_0000: nop IL_0001: ldarg.0 IL_0002: ldc.i4.4 IL_0003: clt IL_0005: ldc.i4.0 IL_0006: ceq IL_0008: stloc.1 IL_0009: ldloc.1 IL_000a: brtrue.s IL_001a IL_000c: newobj instance void class [mscorlib] System.Collections.Generic.List`1<int32>::.ctor() IL_0011: ldc.i4.1 IL_0012: tail. call class [mscorlib] System.Collections.Generic.List`1<!!0> Maine::M1<int32,int32>(class [mscorlib]System.Collections.Generic.List`1<!!0>, !!1) IL_0017: ret IL_001a: ldarg.0 IL_001b: ldarg.1 IL_001c: call class [mscorlib] System.Collections.Generic.List`1<int32> Maine::M2<!!0>(int32, !!0) IL_0021: ldc.i4.2 IL_0022: tail. call class [mscorlib] System.Collections.Generic.List`1<!!0> Maine::M1<int32,int32>(class [mscorlib]System.Collections.Generic.List`1<!!0>, !!1) IL_002b: ret } // end of method Maine::M2 .method private hidebysig static void Main() cil managed { .entrypoint // Code size 10 (0xa) .maxstack 8 IL_0000: nop IL_0001: ldc.i4.1 IL_0002: ldc.i4.2 IL_0003: call class [mscorlib] System.Collections.Generic.List`1<int32> Maine::M2<int32>(int32, !!0) IL_0008: pop IL_0009: ret } // end of method Maine::Main .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { // Code size 7 (0x7) .maxstack 8 IL_0000: ldarg.0 IL_0001: call instance void [mscorlib]System.Object::.ctor() IL_0006: ret } // end of method Maine::.ctor } // end of class Maine Expected Results: No crash, successful exit How often does this happen? : All the time Additional Information: Mono tailcalls are badly broken. This completely messes with the use of any functional languages on Mono. The above is a condensed test case from F# code. Why don't the Mono team regularly test against F# code? Every time I run F# code on Mono I find many bugs in Mono. There are hundreds of great test cases in the F# samples just waiting for you. Please test using F# code!!! ---- Additional Comments From miguel@ximian.com 2006-07-12 17:22:48 MST ---- This seems to be a bug in the verifier. ---- Additional Comments From bbjamey@gmail.com 2006-07-12 22:06:11 MST ---- I don't think so - similar programs do not run correctly. See #78828 (https://bugzilla.novell.com/show_bug.cgi?id=MONO78828) for example. The symptoms vary between the above error and the incorrect execution exhibited by 78828. thanks BB ---- Additional Comments From martin@ximian.com 2006-07-14 15:19:20 MST ---- Created an attachment (id=170095) non-generic test case ---- Additional Comments From martin@ximian.com 2006-07-14 15:20:10 MST ---- This has absolutely nothing to do with generics, it's the CHECK_STACK (n) in mini.c:4431 which is failing. ---- Additional Comments From vargaz@gmail.com 2006-07-19 14:36:50 MST ---- Fixed in SVN. Imported an attachment (id=170095) Unknown operating system unknown. Setting to default OS "Other".