diff options
author | Simon Marlow <smarlow@fb.com> | 2018-04-27 11:31:19 -0700 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2018-05-02 12:48:38 +0100 |
commit | 4cb5595e5e800818721a623a5419cad29a528000 (patch) | |
tree | 596ea21e66144540e8cb696d0b8c34d7cf2eece1 /rts/sm/Storage.c | |
parent | dc655bf0310012b193cf49cce9f5b0bfbc53764c (diff) | |
download | haskell-4cb5595e5e800818721a623a5419cad29a528000.tar.gz |
storageAddCapabilities: fix bug in updating nursery pointers
Summary:
We were unconditionally updating the nursery pointers to be
`nurseries[cap->no]`, but when using nursery chunks this might be
wrong. This manifested as a later assertion failure in allocate().
Test Plan: new test case
Reviewers: bgamari, niteria, erikd
Subscribers: thomie, carter
Differential Revision: https://phabricator.haskell.org/D4649
Diffstat (limited to 'rts/sm/Storage.c')
-rw-r--r-- | rts/sm/Storage.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index 9174646899..52dab73709 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -220,6 +220,7 @@ initStorage (void) void storageAddCapabilities (uint32_t from, uint32_t to) { uint32_t n, g, i, new_n_nurseries; + nursery *old_nurseries; if (RtsFlags.GcFlags.nurseryChunkSize == 0) { new_n_nurseries = to; @@ -229,6 +230,7 @@ void storageAddCapabilities (uint32_t from, uint32_t to) stg_max(to, total_alloc / RtsFlags.GcFlags.nurseryChunkSize); } + old_nurseries = nurseries; if (from > 0) { nurseries = stgReallocBytes(nurseries, new_n_nurseries * sizeof(struct nursery_), @@ -240,8 +242,9 @@ void storageAddCapabilities (uint32_t from, uint32_t to) // 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]; + for (i = 0; i < from; i++) { + uint32_t index = capabilities[i]->r.rNursery - old_nurseries; + capabilities[i]->r.rNursery = &nurseries[index]; } /* The allocation area. Policy: keep the allocation area |