Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program {
- string str = "str";
- /* Nursery size 4 000 000 000 */
- public const int NURSERY_SIZE = 4000000;
- public const int SIZEOF_OBJECT = 24;
- public const int NUM_ELEMENTS = (NURSERY_SIZE * 2 / 3)/ SIZEOF_OBJECT;
- public static void Main (string[] args)
- {
- /* Array in major heap */
- Program[] array = new Program [NUM_ELEMENTS * 2];
- /* Fill nursery with objects, we have wbarriers for half the array */
- for (int i = 0; i < NUM_ELEMENTS; i++)
- array [i] = new Program ();
- /* We reverse array, the other half of the array will have missing remsets due to bug */
- Array.Reverse (array);
- /* We promote all objects, gc will fail to update refs for half the array */
- GC.Collect (0);
- /* Clear the nursery */
- for (int i = 0; i < NURSERY_SIZE; i++)
- new object ();
- /* Half of the references in the array will be junk, crash here */
- for (int i = NUM_ELEMENTS; i < (NUM_ELEMENTS * 2); i++) {
- if (!string.Equals (array [i].str, "str")) {
- Console.WriteLine ("We have a junk object, str {0}", array [i].str);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement