summaryrefslogtreecommitdiffstats
path: root/compiler-rt
Commit message (Collapse)AuthorAgeFilesLines
* Relax stack check as on some platforms demanglers failVitaly Buka2016-05-021-1/+1
| | | | | | | | | | | | | | Summary: On Windows (already fixed) and FreeBSD we have stacks traces without operator(). Reviewers: eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D19427 llvm-svn: 268332
* Add another failing use-after-scope testVitaly Buka2016-05-021-0/+15
| | | | | | | | | | | Summary: Use after scope is not detected if array larger then 8 bytes. Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19572 llvm-svn: 268330
* [compiler-rt] adjust platform_limits_linux.cc #include of posix_typesKostya Serebryany2016-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Hello, Building a recent gcc on a powerpc-linux system advertsing: Red Hat Enterprise Linux Server release 5.10 (Tikanga) we stumbled on a compilation error on a file originating from compiler-rt/lib/sanitizer-common. sanitizer_platform_limits_linux.cc #includes asm/posix_types.h, which, on our system, uses __kernel_fd_set and associated macros. These aren't defined at the point of their use, and the compilation fails with symptoms like: In file included from ../../../../src/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:0: /usr/include/asm/posix_types.h:72:51: error: '__kernel_fd_set' has not been declared static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) ... The attached patch is a suggestion to fix this, by including linux/posix_types.h instead of asm/posix_types.h. linux/posix_types defines the necessary types and macros, then #includes asm/posix_types.h. We have been using it locally for gcc without problems for a couple of years on powerpc, x86 and x86_64-linux platforms. It is still needed for gcc-6 on our powerpc host and applies cleanly on the compiler-rt trunk. Comments ? Thanks much in advance for your feedback, With Kind Regards, Olivier Reviewers: llvm-commits, kcc Subscribers: kcc, kubabrecka Differential Revision: http://reviews.llvm.org/D19799 llvm-svn: 268283
* [scan-build] fix logic error warning emitted on compiler-rt code baseKostya Serebryany2016-05-021-0/+1
| | | | | | | | | | | | | | | | | Summary: Fix a "called c++ object pointer is null" warning emitted by Clang Static Analyzer on the following file: - lib/asan/asan_suppressions.cc. Signed-off-by: Apelete Seketeli <apelete@seketeli.net> Reviewers: kcc Subscribers: Eugene.Zelenko, kubabrecka, llvm-commits Differential Revision: http://reviews.llvm.org/D19627 llvm-svn: 268282
* [sanitizer] Fix a crash in SizeClassAllocator32 with an out-of-range pointerKuba Brecka2016-05-022-0/+18
| | | | | | | | This happens on a 64-bit platform that uses SizeClassAllocator32 (e.g. ASan on AArch64). When querying a large invalid pointer, `__sanitizer_get_allocated_size(0xdeadbeefdeadbeef)`, an assertion will fail. This patch changes PointerIsMine to return false if the pointer is outside of [kSpaceBeg, kSpaceBeg + kSpaceSize). Differential Revision: http://reviews.llvm.org/D15008 llvm-svn: 268243
* [sanitizer] Don't reuse the main thread in ThreadRegistryKuba Brecka2016-05-021-0/+2
| | | | | | | | There is a hard-to-reproduce crash happening on OS X that involves terminating the main thread (dispatch_main does that, see discussion at http://reviews.llvm.org/D18496) and later reusing the main thread's ThreadContext. This patch disables reuse of the main thread. I believe this problem exists only on OS X, because on other systems the main thread cannot be terminated without exiting the process. Differential Revision: http://reviews.llvm.org/D19722 llvm-svn: 268238
* [ASan] Add shadow offset for SystemZ.Marcin Koscielnicki2016-04-303-1/+20
| | | | | | | | This is the compiler-rt counterpart to D19650. Differential Revision: http://reviews.llvm.org/D19652 llvm-svn: 268162
* Finally fix invalid-pointer-pairs.cc. This time the demangle on the Windows ↵Filipe Cabecinhas2016-04-301-3/+3
| | | | | | buildbot. llvm-svn: 268160
* [tsan] Return 0 from malloc_size for non-malloc'd pointersKuba Brecka2016-04-303-14/+49
| | | | | | | | In http://reviews.llvm.org/D19100, I introduced a bug: On OS X, existing programs rely on malloc_size() to detect whether a pointer comes from heap memory (malloc_size returns non-zero) or not. We have to distinguish between a zero-sized allocation (where we need to return 1 from malloc_size, due to other binary compatibility reasons, see http://reviews.llvm.org/D19100), and pointers that are not returned from malloc at all. Differential Revision: http://reviews.llvm.org/D19653 llvm-svn: 268157
* Fix test's memory leaks.Filipe Cabecinhas2016-04-291-9/+15
| | | | llvm-svn: 268138
* Try to fix clang-cmake-aarch64-42vma by removing a memory leak (have a ↵Filipe Cabecinhas2016-04-291-1/+2
| | | | | | global var capture it). llvm-svn: 268114
* [asan] Assert in __sanitizer_ptr_{sub,cmp} if one of the pointers was freed.Filipe Cabecinhas2016-04-294-9/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This (partially) implements the check mentioned at http://kristerw.blogspot.co.uk/2016/04/dangling-pointers-and-undefined-behavior.html (via John Regehr) Quoting: "That the behavior is undefined follows from C11 6.2.4 "Storage durations of objects" The lifetime of an object is the portion of program execution during which storage is guaranteed to be reserved for it. An object exists, has a constant address, and retains its last-stored value throughout its lifetime. If an object is referred to outside of its lifetime, the behavior is undefined. The value of a pointer becomes indeterminate when the object it points to (or just past) reaches the end of its lifetime. and 7.22.3 "Memory management functions" that says that free ends the lifetime of objects The lifetime of an allocated object extends from the allocation until the deallocation. " We can probably implement this for stack variables too, but I think this is a good start to see if there's interest in this check. We can also hide this behind a flag, too. Reviewers: samsonov, kcc, rsmith, regehr Subscribers: kubabrecka, llvm-commits Differential Revision: http://reviews.llvm.org/D19691 llvm-svn: 268097
* [sanitizers] [SystemZ] Mark kernel 3.12.58+ as safe from CVE-2016-2143.Marcin Koscielnicki2016-04-291-0/+3
| | | | llvm-svn: 268046
* [msan] Tests for vector compare intrinsics.Evgeniy Stepanov2016-04-291-1/+42
| | | | llvm-svn: 267967
* [ASan] [SystemZ] Mark segv_read_write.c as UNSUPPORTED.Marcin Koscielnicki2016-04-291-1/+1
| | | | | | | | | | On s390*-linux, sigcontext just doesn't contain any information that could be used to recover the type of access, so there's no way to fix this, short of emulating the faulting instruction. Differential Revision: http://reviews.llvm.org/D19655 llvm-svn: 267960
* [ASan] Reenable __builtin_setjmp test on PowerPC, disable on SystemZ.Marcin Koscielnicki2016-04-281-6/+5
| | | | | | | | | | | | Since __builtin_setjmp has been fixed by rL267943, the test now works on PowerPC. Enable it. On the other hand, the SystemZ backend doesn't currently support __builtin_setjmp. Disable it. Differential Revision: http://reviews.llvm.org/D19657 llvm-svn: 267946
* [CMake] Adding another missing include. NFC.Chris Bieneman2016-04-281-0/+2
| | | | | | This also works fine today, but will break with my upcoming refactoring. llvm-svn: 267941
* [CMake] Updating Apple CMake cache fileChris Bieneman2016-04-281-3/+6
| | | | | | Changing the Apple CMake cache file to better match the way Apple Clang builds are built. llvm-svn: 267913
* [CMake] Adding some missing CMake includes. NFC.Chris Bieneman2016-04-281-0/+3
| | | | | | This happens to be working now because the includes exist in another CMake file that is included before this one. That will change with upcoming refactoring. llvm-svn: 267912
* [test/asan] Update a test case to work with old Darwin SDK'sVedant Kumar2016-04-281-1/+1
| | | | | | | | | On Darwin, MAP_ANONYMOUS is a synonym for MAP_ANON. However, some SDK's don't define MAP_ANONYMOUS. Use MAP_ANON to work around this. (As a point of interest, the situation is exactly reversed on Linux.) llvm-svn: 267907
* Update visibility flags for CFI tests.Peter Collingbourne2016-04-281-10/+10
| | | | | | Differential Revision: http://reviews.llvm.org/D18813 llvm-svn: 267902
* [tsan] Fix Darwin GCD support after separation of Processor and ThreadStateKuba Brecka2016-04-282-6/+8
| | | | | | Recent TSan changes (r267678) which factor out parts of ThreadState into a Processor structure broke worker threads on OS X. This fixes it by properly calling ProcCreate for GCD worker threads and by replacing some CHECKs with RAW_CHECK in early process initialization. CHECK() in TSan calls the allocator, which requires a valid Processor. llvm-svn: 267864
* [MSan] [PowerPC] Dereference function descriptors when recording stack origins.Marcin Koscielnicki2016-04-271-0/+7
| | | | | | Differential Revision: http://reviews.llvm.org/D19543 llvm-svn: 267795
* [sanitizers] Get the proper symbol version when long double transition is ↵Marcin Koscielnicki2016-04-276-6/+42
| | | | | | | | | | | | | | | | | involved. On linux, some architectures had an ABI transition from 64-bit long double (ie. same as double) to 128-bit long double. On those, glibc symbols involving long doubles come in two versions, and we need to pass the correct one to dlvsym when intercepting them. A few more functions we intercept are also versioned (all printf, scanf, strtold variants), but there's no need to fix these, as the REAL() versions are never called. Differential Revision: http://reviews.llvm.org/D19555 llvm-svn: 267794
* [sanitizer] Add early call handling to strchr + strrchr interceptorsDerek Bruening2016-04-271-0/+4
| | | | | | | | | | | | | | | | | Summary: The strchr and strrchr interceptors are sometimes invoked too early for their REAL() counterparts to be initialized. We have seen this in hooks invoked from tcmalloc on the dlsym() used in initializing interceptors. A special check is added to use internal_ routines for this situation. Reviewers: vitalybuka, aizatsky, filcab Subscribers: filcab, llvm-commits, eugenis, kcc, zhaoqin, aizatsky, kubabrecka Differential Revision: http://reviews.llvm.org/D19607 llvm-svn: 267793
* [sanitizers] read/write page fault detection on mac.Mike Aizatsky2016-04-272-1/+32
| | | | | | | | | | Summary: Resubmit of http://reviews.llvm.org/D19495 enabled only on intel. Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19561 llvm-svn: 267750
* [sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143.Marcin Koscielnicki2016-04-277-0/+84
| | | | | | | | | | | | | | | | | | In short, CVE-2016-2143 will crash the machine if a process uses both >4TB virtual addresses and fork(). ASan, TSan, and MSan will, by necessity, map a sizable chunk of virtual address space, which is much larger than 4TB. Even worse, sanitizers will always use fork() for llvm-symbolizer when a bug is detected. Disable all three by aborting on process initialization if the running kernel version is not known to contain a fix. Unfortunately, there's no reliable way to detect the fix without crashing the kernel. So, we rely on whitelisting - I've included a list of upstream kernel versions that will work. In case someone uses a distribution kernel or applied the fix themselves, an override switch is also included. Differential Revision: http://reviews.llvm.org/D19576 llvm-svn: 267747
* Un-XFAIL tests on Windows after fixing PR27492Reid Kleckner2016-04-272-5/+1
| | | | | | | Private symbols in PDBs do not have parameter types in their names so we have to drop the parens from the lambda call operator. llvm-svn: 267735
* tsan: fix windows supportDmitry Vyukov2016-04-271-11/+9
| | | | | | | | | | | | | | UnmapOrDie used to do MEM_DECOMMIT and so worked on partial regions. But r263160 changed it to use MEM_RELEASE and MEM_RELEASE can only work with whole regions mapped by VirtualAlloc. This broke windows as: FATAL: ThreadSanitizer CHECK failed: gotsan.cc:8296 "((mbi.AllocationBase == addr && "Windows cannot unmap part of a previous mapping")) != (0)" (0x0, 0x0) Restore the previous behavior. llvm-svn: 267730
* tsan: fix darwin Go supportDmitry Vyukov2016-04-271-2/+2
| | | | | | | | os_trace turns out to be a macro that creates static object. Function-static objects use __cxa_atexit and __dso_handle which are not present in Go runtime. llvm-svn: 267720
* tsan: fix windows Go supportDmitry Vyukov2016-04-271-0/+6
| | | | | | Unmap can't unmap arbitrary regions on windows. llvm-svn: 267716
* tsan: fix darwin Go buildDmitry Vyukov2016-04-271-0/+2
| | | | | | syslog_lock is not defined in Go build. llvm-svn: 267714
* tsan: make windows shadow mapping a bijectionDmitry Vyukov2016-04-271-1/+4
| | | | | | | | CheckShadowMapping function started catching that mem->shadow->mem mapping is not bijection. Make it bijection. llvm-svn: 267713
* tsan: fix build Dmitry Vyukov2016-04-271-0/+1
| | | | | error: implicit declaration of function 'abort' is invalid in C99 llvm-svn: 267710
* tsan: fix darwin Go buildDmitry Vyukov2016-04-271-0/+6
| | | | | | | | Ifdef out global variables with destructors. This requires runtime support that is not provided by Go runtime (in particular _dso_handle symbol). llvm-svn: 267709
* tsan: change tsan/Go interface for obtaining the current ProcessorDmitry Vyukov2016-04-2711-69/+82
| | | | | | | | | | | | | | | Current interface assumes that Go calls ProcWire/ProcUnwire to establish the association between thread and proc. With the wisdom of hindsight, this interface does not work very well. I had to sprinkle Go scheduler with wire/unwire calls, and any mistake leads to hard to debug crashes. This is not something one wants to maintian. Fortunately, there is a simpler solution. We can ask Go runtime as to what is the current Processor, and that question is very easy to answer on Go side. Switch to such interface. llvm-svn: 267703
* tsan: fix windows buildDmitry Vyukov2016-04-271-1/+1
| | | | | warning: '__sanitizer::uptr __sanitizer::GetPreferredBase(const char*)' defined but not used llvm-svn: 267682
* tsan: fix windows buildDmitry Vyukov2016-04-271-1/+1
| | | | llvm-svn: 267681
* tsan: add missing fileDmitry Vyukov2016-04-271-0/+61
| | | | llvm-svn: 267680
* tsan: fix compiler warningDmitry Vyukov2016-04-271-2/+1
| | | | | | | | | tsan_debugging.cc: In function ‘void* __tsan_get_current_report()’: tsan_debugging.cc:61:18: warning: cast from type ‘const __tsan::ReportDesc*’ to type ‘void*’ casts away qualifiers [-Wcast-qual] return (void *)rep; llvm-svn: 267679
* tsan: split thread into logical and physical stateDmitry Vyukov2016-04-2717-96/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | This is reincarnation of http://reviews.llvm.org/D17648 with the bug fix pointed out by Adhemerval (zatrazz). Currently ThreadState holds both logical state (required for race-detection algorithm, user-visible) and physical state (various caches, most notably malloc cache). Move physical state in a new Process entity. Besides just being the right thing from abstraction point of view, this solves several problems: Cache everything on P level in Go. Currently we cache on a mix of goroutine and OS thread levels. This unnecessary increases memory consumption. Properly handle free operations in Go. Frees are issue by GC which don't have goroutine context. As the result we could not do anything more than just clearing shadow. For example, we leaked sync objects and heap block descriptors. This will allow to get rid of libc malloc in Go (now we have Processor context for internal allocator cache). This in turn will allow to get rid of dependency on libc entirely. Potentially we can make Processor per-CPU in C++ mode instead of per-thread, which will reduce resource consumption. The distinction between Thread and Processor is currently used only by Go, C++ creates Processor per OS thread, which is equivalent to the current scheme. llvm-svn: 267678
* [Compiler-rt][CFI] Enabling CFI for MIPS64Mohit K. Bhakkad2016-04-271-1/+1
| | | | | | | | | | Reviewers: eugenis Subscribers: jaydeep, sagar, Sanitizers Differential Revision: http://reviews.llvm.org/D19531 llvm-svn: 267674
* [sanitizers] rewriting test assuming assert() changes coverage.Mike Aizatsky2016-04-261-19/+43
| | | | | | | | | | | | | Summary: On windows platform assert() call creates two distinct CFG edges which are coverage-instrumented. Simply calling assert would change coverage numbers on the platform. Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19514 llvm-svn: 267610
* [sanitizers] [NFC] Add defines for the various PowerPC ABIs.Marcin Koscielnicki2016-04-264-6/+37
| | | | | | Differential Revision: http://reviews.llvm.org/D19542 llvm-svn: 267586
* [CMake] [PR27403] Fix COMPILER_RT_ENABLE_IOS when using Xcode from the App ↵Chris Bieneman2016-04-262-2/+6
| | | | | | | | | | Store. This change modifies find_darwin_sdk_dir to set a variable if a Darwin "Internal" SDK is present which allows CMake to disable components that require internal-only APIs. This mechanism is then used to disable TSan when an internal SDK is not present. llvm-svn: 267575
* [sanitizer] [SystemZ] Add ptrace support bits.Marcin Koscielnicki2016-04-268-7/+52
| | | | | | Differential Revision: http://reviews.llvm.org/D19134 llvm-svn: 267548
* [sanitizer] [SystemZ] Implement internal_clone.Marcin Koscielnicki2016-04-262-1/+63
| | | | | | Differential Revision: http://reviews.llvm.org/D19159 llvm-svn: 267547
* Revert "[sanitizers] read/write page fault detection on mac."Mehdi Amini2016-04-262-2/+1
| | | | | | | | | This reverts commit r267477. It broke our bots that enables the AArch64 backends, it seems that this code is using a Darwin *X86 specific* field. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 267526
* [MSan] Use COMMON_INTERCEPTOR_ENTER in libdl interceptors.Marcin Koscielnicki2016-04-252-62/+60
| | | | | | | | | | | This fixes fails in test/msan/dlerror.cc - when real dlerror calls strcmp, our strcmp interceptor now skips poison checking, since it's called in interceptor context. Strictly speaking, only the dlerror change is necessary to fix the fail, but let's also change the other two just in case. Differential Revision: http://reviews.llvm.org/D19499 llvm-svn: 267486
* [sanitizers] read/write page fault detection on mac.Mike Aizatsky2016-04-252-1/+2
| | | | | | | | Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19495 llvm-svn: 267477
OpenPOWER on IntegriCloud