summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2021-01-13 13:46:03 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2021-01-13 14:53:45 -0800
commit589a8026f029611dafb316fe750b54e54304239a (patch)
treecce3a44c76eb118aa33efafcdb1f71589faabb63
parent70cd351c7c71c48ee18d7c01e851a89614086f8f (diff)
fix ASAN errors
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4067
-rw-r--r--gc.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/gc.c b/gc.c
index 0dbee77293c..27cf65b196a 100644
--- a/gc.c
+++ b/gc.c
@@ -2217,7 +2217,9 @@ ractor_cache_slots(rb_objspace_t *objspace, rb_ractor_t *cr)
page->free_slots = 0;
page->freelist = NULL;
+ asan_unpoison_object((VALUE)cr->newobj_cache.freelist, false);
GC_ASSERT(RB_TYPE_P((VALUE)cr->newobj_cache.freelist, T_NONE));
+ asan_poison_object((VALUE)cr->newobj_cache.freelist);
}
ALWAYS_INLINE(static VALUE newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t *cr, int wb_protected));
@@ -5079,11 +5081,22 @@ gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap)
RUBY_DEBUG_LOG("ractor using_page:%p freelist:%p", page, freelist);
if (page && freelist) {
- RVALUE **p = &page->freelist;
- while (*p) {
- p = &(*p)->as.free.next;
+ asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false);
+ if (page->freelist) {
+ RVALUE *p = page->freelist;
+ asan_unpoison_object((VALUE)p, false);
+ while (p->as.free.next) {
+ RVALUE *prev = p;
+ p = p->as.free.next;
+ asan_poison_object((VALUE)prev);
+ asan_unpoison_object((VALUE)p, false);
+ }
+ p->as.free.next = freelist;
+ asan_poison_object((VALUE)p);
+ } else {
+ page->freelist = freelist;
}
- *p = freelist;
+ asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
}
r->newobj_cache.using_page = NULL;