Bug 323144 (MONO80455) - [PATCH] Runtime crashes with program that pinvokes a generic signature
Summary: [PATCH] Runtime crashes with program that pinvokes a generic signature
Status: RESOLVED FIXED
Alias: MONO80455
Product: Mono: Runtime
Classification: Mono
Component: interop (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-05 04:41 UTC by Miguel de Icaza
Modified: 2008-06-11 22:49 UTC (History)
3 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Proposed patch (1.09 KB, patch)
2007-12-19 04:17 UTC, Jonathan Chambers
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:22:14 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".

Comment 1 Jonathan Chambers 2007-12-19 04:17:30 UTC
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?
Comment 2 Miguel de Icaza 2007-12-19 18:53:55 UTC
This looks ok to check.
Comment 3 Gert Driesen 2007-12-19 19:35:28 UTC
But I guess a regression test is always welcome ...
Comment 4 Forgotten User vxPDddArjq 2008-06-11 22:49:44 UTC
This works fine with current svn.