Nonmoving GC may drop update remembered set blocks due to `setNumCapabilities`
Storage.c:storageAddCapabilities
currently has the following:
// Initialize NonmovingAllocators and UpdRemSets
if (RtsFlags.GcFlags.useNonmoving) {
nonmovingAddCapabilities(to);
for (i = 0; i < to; ++i) {
nonmovingInitUpdRemSet(&getCapability(i)->upd_rem_set);
}
}
This is subtly wrong: the lower iteration bound of 0 means we end up re-initializing (and therefore clearing) the update-remembered sets of capabilities which already exist. This lower bound rather should be from
.
This can result in undefined behavior in programs using the nonmoving GC and setNumCapabilities
.
Edited by Ben Gamari