From cc0796dba41decd108241a826de71ee4b8dacbd3 Mon Sep 17 00:00:00 2001 From: Francis Ricci Date: Sat, 13 Jan 2018 14:43:49 +0000 Subject: [Sanitizers, LSan, Darwin] Allow for lack of VM_MEMORY_OS_ALLOC_ONCE Summary: Some time ago, the sanitizers as of r315899 were imported into gcc mainline. This broke bootstrap on Darwin 10 and 11, as reported in GCC PR sanitizer/82824 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82824) due to the unconditional use of VM_MEMORY_OS_ALLOC_ONCE. This was only introduced in Darwin 13/Mac OS X 10.9. The use of the macro was introduced in r300450. I couldn't find any statement which Darwin versions are supposed to be supported by LLVM, but the trivial patch to use the macro only if present allowed the gcc bootstrap to finish. So far, I haven't tried building llvm/compiler-rt on Darwin 11. Maybe the patch is simple enough to go in nonetheless. Committing on behalf of ro. Reviewers: glider, fjricci, kcc, kuba, kubamracek, george.karpenkov Reviewed By: fjricci Subscribers: #sanitizers, zaks.anna, srhines, dberris, kubamracek, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D39888 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@322437 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/lsan/lsan_common_mac.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/lsan') diff --git a/lib/lsan/lsan_common_mac.cc b/lib/lsan/lsan_common_mac.cc index ac27c7af6..b8f8b25f6 100644 --- a/lib/lsan/lsan_common_mac.cc +++ b/lib/lsan/lsan_common_mac.cc @@ -24,6 +24,13 @@ #include +// Only introduced in Mac OS X 10.9. +#ifdef VM_MEMORY_OS_ALLOC_ONCE +static const int kSanitizerVmMemoryOsAllocOnce = VM_MEMORY_OS_ALLOC_ONCE; +#else +static const int kSanitizerVmMemoryOsAllocOnce = 73; +#endif + namespace __lsan { typedef struct { @@ -157,7 +164,7 @@ void ProcessPlatformSpecificAllocations(Frontier *frontier) { // libxpc stashes some pointers in the Kernel Alloc Once page, // make sure not to report those as leaks. - if (info.user_tag == VM_MEMORY_OS_ALLOC_ONCE) { + if (info.user_tag == kSanitizerVmMemoryOsAllocOnce) { ScanRangeForPointers(address, end_address, frontier, "GLOBAL", kReachable); -- cgit v1.2.3