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:
tenderlove 2019-04-01 22:52:35 +00:00
parent 990df87302
commit 1286674bb9
2 changed files with 24 additions and 0 deletions

View file

@ -105,6 +105,7 @@ extern "C" {
# define __asan_poison_memory_region(x, y)
# define __asan_unpoison_memory_region(x, y)
# define __asan_region_is_poisoned(x, y) 0
# define poisoned_object_p(x) 0
#endif
#ifdef HAVE_SANITIZER_MSAN_INTERFACE_H
@ -132,6 +133,15 @@ poison_object(VALUE obj)
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
unpoison_memory_region(const volatile void *ptr, size_t size, bool malloc_p)
{