unpoison / poison objects while walking the heap
This fixes some ASAN errors git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
990df87302
commit
1286674bb9
10
internal.h
10
internal.h
@ -105,6 +105,7 @@ extern "C" {
|
|||||||
# define __asan_poison_memory_region(x, y)
|
# define __asan_poison_memory_region(x, y)
|
||||||
# define __asan_unpoison_memory_region(x, y)
|
# define __asan_unpoison_memory_region(x, y)
|
||||||
# define __asan_region_is_poisoned(x, y) 0
|
# define __asan_region_is_poisoned(x, y) 0
|
||||||
|
# define poisoned_object_p(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SANITIZER_MSAN_INTERFACE_H
|
#ifdef HAVE_SANITIZER_MSAN_INTERFACE_H
|
||||||
@ -132,6 +133,15 @@ poison_object(VALUE obj)
|
|||||||
poison_memory_region(ptr, SIZEOF_VALUE);
|
poison_memory_region(ptr, SIZEOF_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __has_feature(address_sanitizer)
|
||||||
|
static inline void *
|
||||||
|
poisoned_object_p(VALUE obj)
|
||||||
|
{
|
||||||
|
struct RVALUE *ptr = (void *)obj;
|
||||||
|
return __asan_region_is_poisoned(ptr, SIZEOF_VALUE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p)
|
unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p)
|
||||||
{
|
{
|
||||||
|
14
iseq.c
14
iseq.c
@ -1011,10 +1011,17 @@ remove_coverage_i(void *vstart, void *vend, size_t stride, void *data)
|
|||||||
{
|
{
|
||||||
VALUE v = (VALUE)vstart;
|
VALUE v = (VALUE)vstart;
|
||||||
for (; v != (VALUE)vend; v += stride) {
|
for (; v != (VALUE)vend; v += stride) {
|
||||||
|
void *ptr = poisoned_object_p(v);
|
||||||
|
unpoison_object(v, false);
|
||||||
|
|
||||||
if (rb_obj_is_iseq(v)) {
|
if (rb_obj_is_iseq(v)) {
|
||||||
rb_iseq_t *iseq = (rb_iseq_t *)v;
|
rb_iseq_t *iseq = (rb_iseq_t *)v;
|
||||||
ISEQ_COVERAGE_SET(iseq, Qnil);
|
ISEQ_COVERAGE_SET(iseq, Qnil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ptr) {
|
||||||
|
poison_object(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3156,9 +3163,16 @@ trace_set_i(void *vstart, void *vend, size_t stride, void *data)
|
|||||||
|
|
||||||
VALUE v = (VALUE)vstart;
|
VALUE v = (VALUE)vstart;
|
||||||
for (; v != (VALUE)vend; v += stride) {
|
for (; v != (VALUE)vend; v += stride) {
|
||||||
|
void *ptr = poisoned_object_p(v);
|
||||||
|
unpoison_object(v, false);
|
||||||
|
|
||||||
if (rb_obj_is_iseq(v)) {
|
if (rb_obj_is_iseq(v)) {
|
||||||
rb_iseq_trace_set(rb_iseq_check((rb_iseq_t *)v), turnon_events);
|
rb_iseq_trace_set(rb_iseq_check((rb_iseq_t *)v), turnon_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ptr) {
|
||||||
|
poison_object(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user