[Mono-bugs] [Bug 35987][Wis] New - Delegates must use __stdcall on Windows

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
20 Dec 2002 14:00:54 -0000

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jason@379.com.


--- shadow/35987	Fri Dec 20 09:00:54 2002
+++ shadow/35987.tmp.20731	Fri Dec 20 09:00:54 2002
@@ -0,0 +1,47 @@
+Bug#: 35987
+Product: Mono/Runtime
+Version: unspecified
+OS: other
+OS Details: Windows
+Status: NEW   
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: jason@379.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Delegates must use __stdcall on Windows
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+The problem occurs when passing a delegate to C code. The delegate is
+marshaled to a function pointer. Under windows, the function pointed to is
+expected to use the "__stdcall" calling convention. Mono currently uses the
+"cdecl" convention instead. If C code calls the provided function pointer,
+it will corrupt the stack.
+MS .NET uses the __stdcall convention, so this is a requirement for
+compatibility between the two. Here's a related usenet thread,
+demonstrating the need to be compatible with the MS convention:
+ http://makeashorterlink.com/?C417214D2
+Steps to reproduce the problem:
+1. Create a delegate with some parameters and a return value
+2. Pass it to an unmanaged C function
+3. Call the provided function pointer from unmanaged code
+Because this is a stack corruption issue, many programs will continue to
+run, only to crash somewhere unexpected later.
+I am not certain, but I think this may be related to bug #29256
+For additional context, refer to the mailing list thread "Mono/.NET
+delegate incompatibility"