[Mono-bugs] [Bug 29486][Nor] Changed - P/Invoke automatic marshaller will creat thunks for null function pointers.

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
27 Aug 2002 06:25:40 -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 miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=29486

--- shadow/29486	Mon Aug 26 21:42:50 2002
+++ shadow/29486.tmp.4488	Tue Aug 27 02:25:40 2002
@@ -2,16 +2,16 @@
 Product: Mono/Runtime
 Version: unspecified
 OS: other
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Normal
 Component: misc
-AssignedTo: mono-bugs@ximian.com                            
+AssignedTo: dietmar@ximian.com                            
 ReportedBy: miguel@ximian.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
 Summary: P/Invoke automatic marshaller will creat thunks for null function pointers.
@@ -19,6 +19,50 @@
 If a delegate is null, the runtime will still create a thunk and call it.
 
 This breaks code that takes callbacks, and does things like:
 
 if (func != null)
     (*func) (...)
+
+------- Additional Comments From miguel@ximian.com  2002-08-27 02:25 -------
+I tested this with the Microsoft runtime, and it does indeed pass a
+NULL when a null is passed as a delegate, here is an example:
+
+C:\>type a.c
+void x (void *p)
+{
+
+	printf ("valor: %p\n", p);
+}
+
+C:\>type a.def
+EXPORTS
+        x
+C:\>cl /LD a.c a.def
+
+C:\>type a.cs
+using System;
+using System.Runtime.InteropServices;
+
+class X {
+
+	[DllImport ("a.dll")]
+	extern static void x (XXX i);
+
+	delegate void XXX ();
+
+	static void T ()
+	{
+	}
+
+	static void Main ()
+
+	{
+		x (new XXX(T));
+		x (null);
+	}
+}
+C:\>csc a.cs
+C:\>a.exe
+valor: 0015C8D6
+valor: 00000000
+