[Mono-bugs] [Bug 37082][Nor] New - calling native methods with null objects yields exception

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Wed, 22 Jan 2003 14:14:07 -0500 (EST)


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 roland@ilog.com.

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

--- shadow/37082	Wed Jan 22 14:14:07 2003
+++ shadow/37082.tmp.17763	Wed Jan 22 14:14:07 2003
@@ -0,0 +1,92 @@
+Bug#: 37082
+Product: Mono/Runtime
+Version: unspecified
+OS: Red Hat 8.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: roland@ilog.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: calling native methods with null objects yields exception
+
+Description of Problem:
+
+Calling a DllImport'ed method with a null paramter yields an exception
+but not under windows.  
+
+
+Steps to reproduce the problem:
+
+build and execute the following
+
+hello.cs:
+
+using System;
+using System.Runtime.InteropServices;
+
+class Hello
+{
+   [DllImport("hello.dll", EntryPoint="printhello")]
+   static unsafe extern void printhello(double[] array);
+
+   public static void Main(String[] args) {
+      unsafe {
+         double[] array = new double[100];
+         printhello(array);
+         printhello(null);
+         Console.WriteLine("mono:: is alive and well...");
+      }
+   }
+}
+
+
+hello.c:
+
+
+#include <stdio.h>
+
+void
+printhello(double* array) {
+   fprintf (stderr, "hello world from C (%p)", array);
+}
+
+makefile:
+
+all: hello.exe libhello.dell.so
+
+hello.exe:        hello.cs
+        mcs --unsafe -o hello.exe hello.cs
+
+libhello.dell.so: hello.c
+        gcc -o libhello.dell.so hello.c -shared
+
+
+Actual Results:
+
+hello world from C ((nil))
+Unhandled Exception: System.NullReferenceException: A null value was found
+where an object instance was required
+in (unmanaged) 06 .Hello:printhello (double[])
+in <0x00004> 06 .Hello:printhello (double[])
+in <0x0002c> 00 .Hello:Main (string[])
+
+
+Expected Results: produced on windows
+
+hello world from C (00C91B40)hello world from C (00000000)mono:: is
+alive and well...
+
+
+How often does this happen? 
+
+every such method call
+
+
+Additional Information: