Skip to content

Commit 2d46cc1

Browse files
committed
Fix issue introduced while attempting to handle statics in DFS Mark
(I wasn't a careful reader, isPointerInHeap checks that something is in the heap when it is a pointer, not that it is a pointer which is in the heap)
1 parent d0cfead commit 2d46cc1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

runtime/gc/dfs-mark.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ size_t dfsMarkByMode (GC_state s, pointer root,
114114
assert (not isPointerMarkedByMode (cur, mode));
115115
assert (header == getHeader (cur));
116116
assert (headerp == getHeaderp (cur));
117+
assert (isPointerInHeap (s, cur));
117118
header ^= MARK_MASK;
118119
/* Store the mark. In the case of an object that contains a pointer to
119120
* itself, it is essential that we store the marked header before marking
@@ -140,9 +141,9 @@ size_t dfsMarkByMode (GC_state s, pointer root,
140141
if (DEBUG_DFS_MARK)
141142
fprintf (stderr, "markInNormal objptrIndex = %"PRIu32"\n", objptrIndex);
142143
assert (objptrIndex < numObjptrs);
143-
// next = *(pointer*)todo;
144144
next = fetchObjptrToPointer (todo, s->heap.start);
145-
if (not isPointerInHeap (s, next)) {
145+
if (not isPointer (next) or
146+
not isPointerInHeap (s, next)) {
146147
markNextInNormal:
147148
assert (objptrIndex < numObjptrs);
148149
objptrIndex++;
@@ -216,9 +217,9 @@ size_t dfsMarkByMode (GC_state s, pointer root,
216217
assert (sequenceIndex < getSequenceLength (cur));
217218
assert (objptrIndex < numObjptrs);
218219
assert (todo == indexSequenceAtObjptrIndex (s, cur, sequenceIndex, objptrIndex));
219-
// next = *(pointer*)todo;
220220
next = fetchObjptrToPointer (todo, s->heap.start);
221-
if (not (isPointerInHeap(s, next))) {
221+
if (not isPointer (next) or
222+
not isPointerInHeap (s, next)) {
222223
markNextInSequence:
223224
assert (sequenceIndex < getSequenceLength (cur));
224225
assert (objptrIndex < numObjptrs);
@@ -274,14 +275,14 @@ size_t dfsMarkByMode (GC_state s, pointer root,
274275
goto markInStack;
275276
}
276277
todo = top - frameInfo->size + frameOffsets [objptrIndex + 1];
277-
// next = *(pointer*)todo;
278278
next = fetchObjptrToPointer (todo, s->heap.start);
279279
if (DEBUG_DFS_MARK)
280280
fprintf (stderr,
281281
" offset %u todo "FMTPTR" next = "FMTPTR"\n",
282282
frameOffsets [objptrIndex + 1],
283283
(uintptr_t)todo, (uintptr_t)next);
284-
if (not isPointerInHeap (s, next)) {
284+
if (not isPointer (next) or
285+
not isPointerInHeap (s, next)) {
285286
objptrIndex++;
286287
goto markInFrame;
287288
}

0 commit comments

Comments
 (0)