Skip to content

Commit

Permalink
is_pointer_to_heap() checks also tomb or not.
Browse files Browse the repository at this point in the history
is_pointer_to_heap(obj) checks this obj belong to a heap page.
However, this function returns TRUE even if the page is tomb page.
This is re-commit of [712c027].

heap_page_add_freeobj() should not use is_pointer_to_heap(), but
should check more explicitly.
  • Loading branch information
ko1 committed May 27, 2019
1 parent ea6e284 commit 61da57c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions gc.c
Expand Up @@ -1495,9 +1495,14 @@ heap_page_add_freeobj(rb_objspace_t *objspace, struct heap_page *page, VALUE obj
page->freelist = p;
asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));

if (RGENGC_CHECK_MODE && !is_pointer_to_heap(objspace, p)) {
rb_bug("heap_page_add_freeobj: %p is not rvalue.", (void *)p);
if (RGENGC_CHECK_MODE &&
/* obj should belong to page */
!(&page->start[0] <= (RVALUE *)obj &&
(RVALUE *)obj < &page->start[page->total_slots] &&
obj % sizeof(RVALUE) == 0)) {
rb_bug("heap_page_add_freeobj: %p is not rvalue.", (void *)p);
}

asan_poison_object(obj);

gc_report(3, objspace, "heap_page_add_freeobj: add %p to freelist\n", (void *)obj);
Expand Down Expand Up @@ -2213,7 +2218,13 @@ is_pointer_to_heap(rb_objspace_t *objspace, void *ptr)
if (page->start <= p) {
if (p < page->start + page->total_slots) {
RB_DEBUG_COUNTER_INC(gc_isptr_maybe);
return TRUE;

if (page->flags.in_tomb) {
return FALSE;
}
else {
return TRUE;
}
}
lo = mid + 1;
}
Expand Down

0 comments on commit 61da57c

Please sign in to comment.