Skip to content

Commit

Permalink
Fix GC for TRec mutable array entries.
Browse files Browse the repository at this point in the history
We use the offset to determine if an entry is a pointer.  With mutable arrays
we have pointer entires beyond the index of the last non-pointer.
  • Loading branch information
Ryan Yates committed Aug 8, 2018
1 parent 7334221 commit def1e00
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
3 changes: 2 additions & 1 deletion rts/RetainerProfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,8 @@ pop( StgClosure **c, StgClosure **cp, retainer *r )
if (field_no == 0) {
*c = (StgClosure *)entry->tarray;
} else if (field_no == 1) {
if (entry->offset < entry->tarray->ptrs) {
if (entry->offset < entry->tarray->ptrs ||
(entry->offset >= (entry->tarray->ptrs + entry->tarray->words))) {
*c = NULL;
popOff();
return;
Expand Down
6 changes: 4 additions & 2 deletions rts/sm/Compact.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ update_fwd_large( bdescr *bd )
thread_(&tc->prev_chunk);
for (i = 0; i < tc -> next_entry_idx; i ++, e++ ) {
thread_(&e->tarray);
if (e->offset < e->tarray->ptrs) {
if (e->offset < e->tarray->ptrs ||
(e->offset >= (e->tarray->ptrs + e->tarray->words))) {
thread(&e->expected_value.ptr);
thread(&e->new_value.ptr);
}
Expand Down Expand Up @@ -808,7 +809,8 @@ thread_obj (StgInfoTable *info, StgPtr p)
thread_(&tc->prev_chunk);
for (i = 0; i < tc -> next_entry_idx; i ++, e++ ) {
thread_(&e->tarray);
if (e->offset < e->tarray->ptrs) {
if (e->offset < e->tarray->ptrs ||
(e->offset >= (e->tarray->ptrs + e->tarray->words))) {
thread(&e->expected_value.ptr);
thread(&e->new_value.ptr);
}
Expand Down
1 change: 1 addition & 0 deletions rts/sm/Evac.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ evacuate(StgClosure **p)
const StgInfoTable* i = INFO_PTR_TO_STRUCT(info);
StgWord o = GET_MUT_CON_EXT_SIZE(itbl_to_mut_con_ext_itbl(i));
StgInt dynSize = (StgInt)*(q->payload + o + i->layout.payload.ptrs + i->layout.payload.nptrs - 1);
debugTrace(DEBUG_gc,"evac MUT_CON_ARR_EXT_DIRTY %p count %d", q, dynSize);
copy_tag(p,info,q,mut_constr_ext_sizeW_fromITBL(i)+dynSize,gen_no,tag);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions rts/sm/GC.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ GarbageCollect (nat collect_gen,
mutlist_TVAR,
mutlist_TREC_CHUNK, mutlist_TREC_HEADER,
mutlist_WAKEUP_CHUNK,
mutlist_OTHERS,
mutlist_CONSTR);
mutlist_CONSTR,
mutlist_OTHERS);
}

bdescr *next, *prev;
Expand Down
3 changes: 2 additions & 1 deletion rts/sm/Sanity.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@ checkClosure( StgClosure* p )
for (i = 0; i < tc -> next_entry_idx; i ++) {
TArrayRecEntry* e = &tc->entries[i];
ASSERT(LOOKS_LIKE_CLOSURE_PTR(e->tarray));
if (e->offset < e->tarray->ptrs) {
if (e->offset < e->tarray->ptrs ||
(e->offset >= (e->tarray->ptrs + e->tarray->words))) {
ASSERT(LOOKS_LIKE_CLOSURE_PTR(e->expected_value.ptr));
ASSERT(LOOKS_LIKE_CLOSURE_PTR(e->new_value.ptr));
}
Expand Down
15 changes: 12 additions & 3 deletions rts/sm/Scav.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ scavenge_block (bdescr *bd)
}
p += info->layout.payload.nptrs-1; // Size field
end = p + *p + 1;
debugTrace(DEBUG_gc,"scav MUT_CON_ARR_EXT_CLEAN %p count %d", q, *p);
for (p = p + 1; p < end; p++) {
evacuate((StgClosure **)p);
}
Expand All @@ -697,6 +698,7 @@ scavenge_block (bdescr *bd)
}
p += info->layout.payload.nptrs-1; // Size field
end = p + *p + 1;
debugTrace(DEBUG_gc,"scav MUT_CON_ARR_EXT_DIRTY %p count %d", q, *p);
for (p = p + 1; p < end; p++) {
evacuate((StgClosure **)p);
}
Expand Down Expand Up @@ -970,7 +972,8 @@ scavenge_block (bdescr *bd)
evacuate((StgClosure **)&tc->prev_chunk);
for (i = 0; i < tc -> next_entry_idx; i ++, e++ ) {
evacuate((StgClosure **)&e->tarray);
if (e->offset < e->tarray->ptrs) {
if (e->offset < e->tarray->ptrs ||
(e->offset >= (e->tarray->ptrs + e->tarray->words))) {
evacuate((StgClosure **)&e->expected_value.ptr);
evacuate((StgClosure **)&e->new_value.ptr);
}
Expand Down Expand Up @@ -1277,6 +1280,7 @@ scavenge_mark_stack(void)
}
p += info->layout.payload.nptrs-1; // Size field
end = p + *p + 1;
debugTrace(DEBUG_gc,"scav MUT_CON_ARR_EXT_CLEAN %p count %d", q, *p);
for (p = p + 1; p < end; p++) {
evacuate((StgClosure **)p);
}
Expand All @@ -1296,6 +1300,7 @@ scavenge_mark_stack(void)
}
p += info->layout.payload.nptrs-1; // Size field
end = p + *p + 1;
debugTrace(DEBUG_gc,"scav MUT_CON_ARR_EXT_DIRTY %p count %d", q, *p);
for (p = p + 1; p < end; p++) {
evacuate((StgClosure **)p);
}
Expand Down Expand Up @@ -1567,7 +1572,8 @@ scavenge_mark_stack(void)
evacuate((StgClosure **)&tc->prev_chunk);
for (i = 0; i < tc -> next_entry_idx; i ++, e++ ) {
evacuate((StgClosure **)&e->tarray);
if (e->offset < e->tarray->ptrs) {
if (e->offset < e->tarray->ptrs ||
(e->offset >= (e->tarray->ptrs + e->tarray->words))) {
evacuate((StgClosure **)&e->expected_value.ptr);
evacuate((StgClosure **)&e->new_value.ptr);
}
Expand Down Expand Up @@ -1802,6 +1808,7 @@ scavenge_one(StgPtr p)
}
p += info->layout.payload.nptrs-1; // Size field
end = p + *p + 1;
debugTrace(DEBUG_gc,"scav MUT_CON_ARR_EXT_CLEAN %p count %d", q, *p);
for (p = p + 1; p < end; p++) {
evacuate((StgClosure **)p);
}
Expand All @@ -1820,6 +1827,7 @@ scavenge_one(StgPtr p)
}
p += info->layout.payload.nptrs-1; // Size field
end = p + *p + 1;
debugTrace(DEBUG_gc,"scav MUT_CON_ARR_EXT_DIRTY %p count %d", q, *p);
for (p = p + 1; p < end; p++) {
evacuate((StgClosure **)p);
}
Expand Down Expand Up @@ -2076,7 +2084,8 @@ scavenge_one(StgPtr p)
evacuate((StgClosure **)&tc->prev_chunk);
for (i = 0; i < tc -> next_entry_idx; i ++, e++ ) {
evacuate((StgClosure **)&e->tarray);
if (e->offset < e->tarray->ptrs) {
if (e->offset < e->tarray->ptrs ||
(e->offset >= (e->tarray->ptrs + e->tarray->words))) {
evacuate((StgClosure **)&e->expected_value.ptr);
evacuate((StgClosure **)&e->new_value.ptr);
}
Expand Down

0 comments on commit def1e00

Please sign in to comment.