[gc] Fix a bug in atomic memmove.
authorMark Probst <mark.probst@gmail.com>
Tue, 12 Jul 2011 15:37:32 +0000 (17:37 +0200)
committerMark Probst <mark.probst@gmail.com>
Tue, 12 Jul 2011 16:02:35 +0000 (18:02 +0200)
mono/metadata/gc.c
mono/tests/Makefile.am
mono/tests/bug-705140.cs [new file with mode: 0644]

index 9f80e35352109a64ab427b2a028cbe003c5002bf..3023daa11e17efe9a478917e53d5fa8efb8921cb 100644 (file)
@@ -1551,7 +1551,7 @@ mono_gc_memmove (void *dest, const void *src, size_t size)
                char *p = (char*)dest + size;
                char *s = (char*)src + size;
                char *start = (char*)dest;
-               char *align_end = MAX((char*)p, (char*)align_down (p));
+               char *align_end = MAX((char*)dest, (char*)align_down (p));
                char *word_start;
 
                while (p > align_end)
index 5532eac7665bcdda2e313e74fcc4f7df5f57da22..5a3a17acb5f098b954882920d5566e8215bd9367 100644 (file)
@@ -376,7 +376,8 @@ BASE_TEST_CS_SRC=           \
        bug-685908.cs   \
        sgen-long-vtype.cs      \
        delegate-invoke.cs      \
-       bug-696593.cs
+       bug-696593.cs   \
+       bug-705140.cs
 
 TEST_CS_SRC_DIST=      \
        $(BASE_TEST_CS_SRC)     \
diff --git a/mono/tests/bug-705140.cs b/mono/tests/bug-705140.cs
new file mode 100644 (file)
index 0000000..33792a9
--- /dev/null
@@ -0,0 +1,34 @@
+using System;
+
+
+namespace BufferTest
+{
+       class Test
+       {
+        public static int Main (string[] args)
+        {
+               int size = 32;
+               byte[] array = new byte[size];
+
+
+               for (byte i = 0; i < size; i++) array[i] = i;
+
+               Buffer.BlockCopy (array, 4, array, 5, 20);
+
+               for (byte i = 0; i < size; i++) {
+                       byte expected;
+                       if (i > 4 && i < 25)
+                               expected = (byte)(i - 1);
+                       else
+                               expected = i;
+                       if (array [i] != expected) {
+                               Console.WriteLine ("error at " + i + " expected " + expected + " but got " + array [i]);
+                               return 1;
+                       }
+               }
+
+               return 0;
+        }
+
+       }
+}