Bugzilla – Bug 323144
[PATCH] Runtime crashes with program that pinvokes a generic signature
Last modified: 2008-06-11 22:49:44 UTC
---- Reported by miguel@ximian.com 2007-01-04 21:41:08 MST ---- The following crashes gmcs: mono$ gmcs /tmp/a.cs /tmp/a.cs(6,22): warning CS0169: The private method `A.Do<T>()' is never used In type: A Unhandled Exception: System.InvalidOperationException: Method 'A.Do' does not have a method body. at System.Reflection.Emit.MethodBuilder.fixup () [0x00000] at System.Reflection.Emit.TypeBuilder.CreateType () [0x00000] at Mono.CSharp.TypeContainer.CloseType () [0x00000] mono$ gmcs /tmp/a.cs /tmp/a.cs(6,22): warning CS0169: The private method `A.Do()' is never used Compilation succeeded - 1 warning(s) mono$ cat /tmp/a.cs using System; using System.Runtime.InteropServices; class A { [DllImport ("Dingus")] extern static void Do<T> (); static void Main () { } } ---- Additional Comments From miguel@ximian.com 2007-01-10 15:41:54 MST ---- I should have said: CSC does compile the above program, but the resulting executable will not work (no generic invocations allowed on P/Invoke methods). I think the later is a silly limitation, and could be a "value add" of Mono, but the "value add" is clearly at the bottom of the priority list. The only reason for filing this bug is that the compiler should not crash when generating the above signature. ---- Additional Comments From lupus@ximian.com 2007-01-11 06:46:15 MST ---- The issue is that mcs doesn't set the pinvokeimpl flag for the method, so reflection can't know this shouldn't have a body. ---- Additional Comments From marek.safar@seznam.cz 2007-02-25 18:42:48 MST ---- Fixed gmcs part. But runtime now terminates unexpectedly when produced assembly is executed. Unknown operating system unknown. Setting to default OS "Other".
Created attachment 188164 [details] Proposed patch This fixes the crash which makes mono handle this better than .Net; it crashes with the test case, at least in 2.0. Should I add the test case as a regression test?
This looks ok to check.
But I guess a regression test is always welcome ...
This works fine with current svn.