Support AddressSanitizer and MemorySanitizer (clang)
authorIvan Maidanski <ivmai@mail.ru>
Tue, 15 Nov 2016 14:35:40 +0000 (17:35 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 15 Nov 2016 21:20:27 +0000 (00:20 +0300)
commitce75cf115b8739632fd54bf4a64745749ab13299
treed88f7e8fd5ab9cb4b5766057b05a8ad117ca1096
parente22aaf50d0111ad5481081050d58a39e84e7ed87
Support AddressSanitizer and MemorySanitizer (clang)

* include/private/gc_priv.h (GC_ATTR_NO_SANITIZE_ADDR,
GC_ATTR_NO_SANITIZE_MEMORY): New macro.
* include/private/gcconfig.h [__has_feature(address_sanitizer)]
(ADDRESS_SANITIZER): New macro.
* include/private/gcconfig.h [__has_feature(memory_sanitizer)]
(MEMORY_SANITIZER): Likewise.
* mach_dep.c (GC_with_callee_saves_pushed): Use
GC_ATTR_NO_SANITIZE_ADDR attribute.
* mark.c (GC_mark_from, GC_push_all_eager): Likewise.
* mark.c (GC_mark_from, GC_push_all_eager): Use
GC_ATTR_NO_SANITIZE_MEMORY attribute.
* os_dep.c [ADDRESS_SANITIZER && (UNIX_LIKE || NEED_FIND_LIMIT
|| MPROTECT_VDB)] (__asan_default_options): New function.
* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && CPPCHECK
&& ADDRESS_SANITIZER] (GC_set_and_save_fault_handler):
Reference __asan_default_options.
* os_dep.c [MPROTECT_VDB && !DARWIN && CPPCHECK && ADDRESS_SANITIZER]
(GC_dirty_init): Likewise.
* tests/test.c [MEMORY_SANITIZER] (check_heap_stats): Increase
max_heap_sz by 25% (to avoid "Unexpected heap growth" error if MSan is
used).
* tests/test_cpp.cc [ADDRESS_SANITIZER || MEMORY_SANITIZER] (main):
Call GC_FREE(a) instead of delete a; add comment.
include/private/gc_priv.h
include/private/gcconfig.h
mach_dep.c
mark.c
os_dep.c
tests/test.c
tests/test_cpp.cc