[Mono-bugs] [Bug 36202][Wis] New - .Net executable runs under mono on linux but mcs executable does not

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
31 Dec 2002 13:07:16 -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 dbuskirk@hotmail.com.

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

--- shadow/36202	Tue Dec 31 08:07:16 2002
+++ shadow/36202.tmp.22366	Tue Dec 31 08:07:16 2002
@@ -0,0 +1,107 @@
+Bug#: 36202
+Product: Mono/MCS
+Version: unspecified
+OS: SuSE 8.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: dbuskirk@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: .Net executable runs under mono on linux but mcs executable does not
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+Sample C# code using "unsafe" compiles under mcs without error but does 
+not run under mono. The same source compiled on Windows using C# .NET 
+produces an
+executable which runs correctly under mono on Linux.
+
+Source:
+// Sample code taken from the MSDN Library - dbuskirk@hotmail.com
+// compile with: /unsafe
+using System;
+
+class Test
+{
+    // The unsafe keyword allows pointers to be used within
+    // the following method:
+    static unsafe void Copy(byte[] src, int srcIndex,
+        byte[] dst, int dstIndex, int count)
+    {
+        if (src == null || srcIndex < 0 ||
+            dst == null || dstIndex < 0 || count < 0)
+        {
+            throw new ArgumentException();
+        }
+        int srcLen = src.Length;
+        int dstLen = dst.Length;
+        if (srcLen - srcIndex < count ||
+            dstLen - dstIndex < count)
+        {
+            throw new ArgumentException();
+        }
+        // The following fixed statement pins the location of
+        // the src and dst objects in memory so that they will
+        // not be moved by garbage collection.
+        fixed (byte* pSrc = src, pDst = dst)
+        {
+            byte* ps = pSrc;
+            byte* pd = pDst;
+            // Loop over the count in blocks of 4 bytes, copying an
+            // integer (4 bytes) at a time:
+            for (int n = count >> 2; n != 0; n--)
+            {
+                *((int*)pd) = *((int*)ps);
+                pd += 4;
+                ps += 4;
+            }
+            // Complete the copy by moving any bytes that weren't
+            // moved in blocks of 4:
+            for (count &= 3; count != 0; count--)
+            {
+                *pd = *ps;
+                pd++;
+                ps++;
+            }
+        }
+    }
+
+    static void Main(string[] args) 
+    {
+        byte[] a = new byte[100];
+        byte[] b = new byte[100];
+        for(int i=0; i<100; ++i) 
+           a[i] = (byte)i;
+        Copy(a, 0, b, 0, 100);
+        Console.WriteLine("The first 10 elements are:");
+        for(int i=0; i<10; ++i) 
+           Console.Write(b[i] + "{0}", i < 9 ? " " : "");
+        Console.WriteLine("\n");
+    }
+}
+
+
+
+Steps to reproduce the problem:
+1. 
+2. 
+3. 
+
+Actual Results:
+
+
+Expected Results:
+
+
+How often does this happen? 
+
+
+Additional Information: