Fix OverflowException in b115557.cs GC test on systems with fewer than four processor...
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Fri, 6 Nov 2015 19:14:24 +0000 (20:14 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 16 Nov 2015 19:47:55 +0000 (20:47 +0100)
_allocPerThreadMB/2 can be larger than what fits into byte (because it's based on the number of processors/cores),
resulting in an OverflowException on those systems.

tests/src/GC/Stress/Tests/b115557.cs

index 39cc4e8..7a02d51 100644 (file)
@@ -28,7 +28,7 @@ internal class MyThread
         for (int i = 0; i < _allocPerThreadMB / 2; i++)
         {
             largeArray[i] = new byte[2 * 1024 * 1024];  // 2 MB
-            largeArray[i][i + 100] = Convert.ToByte(i);
+            largeArray[i][i + 100] = Convert.ToByte(Math.Min(i, byte.MaxValue));
         }
         int sum = 0;
         for (int i = 0; i < _allocPerThreadMB / 2; i++)