diff options
author | Maxim Ostapenko <m.ostapenko@samsung.com> | 2017-02-03 12:17:59 +0000 |
---|---|---|
committer | Maxim Ostapenko <chefmax@gcc.gnu.org> | 2017-02-03 14:17:59 +0200 |
commit | 778e0ac39798b142bbc96c78da568e2debeeff0b (patch) | |
tree | 7310d86ff5aff97759365f5e8dcc7488aeb4ac27 /libsanitizer | |
parent | 5dd5e20438f0cfd7f6e64a8174e27aca8d75a391 (diff) | |
download | gcc-778e0ac39798b142bbc96c78da568e2debeeff0b.zip gcc-778e0ac39798b142bbc96c78da568e2debeeff0b.tar.gz gcc-778e0ac39798b142bbc96c78da568e2debeeff0b.tar.bz2 |
re PR sanitizer/78663 (Hundreds of asan failures on x86_64-apple-darwin10 at r243019)
PR sanitizer/78663
* sanitizer_common/sanitizer_mac.cc: Cherry-pick upstream r293992.
* sanitizer_common/sanitizer_platform_interceptors.h: Likewise.
From-SVN: r245149
Diffstat (limited to 'libsanitizer')
-rw-r--r-- | libsanitizer/ChangeLog | 6 | ||||
-rw-r--r-- | libsanitizer/sanitizer_common/sanitizer_mac.cc | 22 | ||||
-rw-r--r-- | libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h | 10 |
3 files changed, 28 insertions, 10 deletions
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index 97728e7..c0e5563 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,9 @@ +2017-02-03 Maxim Ostapenko <m.ostapenko@samsung.com> + + PR sanitizer/78663 + * sanitizer_common/sanitizer_mac.cc: Cherry-pick upstream r293992. + * sanitizer_common/sanitizer_platform_interceptors.h: Likewise. + 2017-01-31 Jakub Jelinek <jakub@redhat.com> * configure.tgt: Enable asan and ubsan on 64-bit s390*-*-linux*. diff --git a/libsanitizer/sanitizer_common/sanitizer_mac.cc b/libsanitizer/sanitizer_common/sanitizer_mac.cc index 62be7b0..2a05102 100644 --- a/libsanitizer/sanitizer_common/sanitizer_mac.cc +++ b/libsanitizer/sanitizer_common/sanitizer_mac.cc @@ -91,20 +91,22 @@ namespace __sanitizer { #include "sanitizer_syscall_generic.inc" -// Direct syscalls, don't call libmalloc hooks. +// Direct syscalls, don't call libmalloc hooks (but not available on 10.6). extern "C" void *__mmap(void *addr, size_t len, int prot, int flags, int fildes, - off_t off); -extern "C" int __munmap(void *, size_t); + off_t off) SANITIZER_WEAK_ATTRIBUTE; +extern "C" int __munmap(void *, size_t) SANITIZER_WEAK_ATTRIBUTE; // ---------------------- sanitizer_libc.h uptr internal_mmap(void *addr, size_t length, int prot, int flags, int fd, u64 offset) { if (fd == -1) fd = VM_MAKE_TAG(VM_MEMORY_ANALYSIS_TOOL); - return (uptr)__mmap(addr, length, prot, flags, fd, offset); + if (__mmap) return (uptr)__mmap(addr, length, prot, flags, fd, offset); + return (uptr)mmap(addr, length, prot, flags, fd, offset); } uptr internal_munmap(void *addr, uptr length) { - return __munmap(addr, length); + if (__munmap) return __munmap(addr, length); + return munmap(addr, length); } int internal_mprotect(void *addr, uptr length, int prot) { @@ -190,17 +192,19 @@ uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set, return sigprocmask(how, set, oldset); } -// Doesn't call pthread_atfork() handlers. -extern "C" pid_t __fork(void); +// Doesn't call pthread_atfork() handlers (but not available on 10.6). +extern "C" pid_t __fork(void) SANITIZER_WEAK_ATTRIBUTE; int internal_fork() { - return __fork(); + if (__fork) + return __fork(); + return fork(); } int internal_forkpty(int *amaster) { int master, slave; if (openpty(&master, &slave, nullptr, nullptr, nullptr) == -1) return -1; - int pid = __fork(); + int pid = internal_fork(); if (pid == -1) { close(master); close(slave); diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h index 2a88605..6b2ba31 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h @@ -81,8 +81,16 @@ #define SANITIZER_INTERCEPT_MEMMOVE 1 #define SANITIZER_INTERCEPT_MEMCPY 1 #define SANITIZER_INTERCEPT_MEMCMP 1 +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 +# define SI_MAC_DEPLOYMENT_BELOW_10_7 1 +#else +# define SI_MAC_DEPLOYMENT_BELOW_10_7 0 +#endif +// memmem on Darwin doesn't exist on 10.6 // FIXME: enable memmem on Windows. -#define SANITIZER_INTERCEPT_MEMMEM SI_NOT_WINDOWS +#define SANITIZER_INTERCEPT_MEMMEM \ + SI_NOT_WINDOWS && !SI_MAC_DEPLOYMENT_BELOW_10_7 #define SANITIZER_INTERCEPT_MEMCHR 1 #define SANITIZER_INTERCEPT_MEMRCHR SI_FREEBSD || SI_LINUX |