Fix for a bug in setNumCapabilities
authorSimon Marlow <marlowsd@gmail.com>
Tue, 13 Dec 2011 13:03:44 +0000 (13:03 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Tue, 13 Dec 2011 15:02:12 +0000 (15:02 +0000)
rts/sm/Storage.c

index dc887c3..012ba51 100644 (file)
@@ -190,7 +190,7 @@ initStorage( void )
 
 void storageAddCapabilities (nat from, nat to)
 {
-    nat n, g;
+    nat n, g, i;
 
     if (from > 0) {
         nurseries = stgReallocBytes(nurseries, to * sizeof(struct nursery_),
@@ -200,6 +200,12 @@ void storageAddCapabilities (nat from, nat to)
                                     "storageAddCapabilities");
     }
 
+    // we've moved the nurseries, so we have to update the rNursery
+    // pointers from the Capabilities.
+    for (i = 0; i < to; i++) {
+        capabilities[i].r.rNursery = &nurseries[i];
+    }
+
     /* The allocation area.  Policy: keep the allocation area
      * small to begin with, even if we have a large suggested heap
      * size.  Reason: we're going to do a major collection first, and we
@@ -463,8 +469,7 @@ assignNurseriesToCapabilities (nat from, nat to)
     nat i;
 
     for (i = from; i < to; i++) {
-       capabilities[i].r.rNursery        = &nurseries[i];
-       capabilities[i].r.rCurrentNursery = nurseries[i].blocks;
+        capabilities[i].r.rCurrentNursery = nurseries[i].blocks;
        capabilities[i].r.rCurrentAlloc   = NULL;
     }
 }