Commit Graph

6977 Commits

Author SHA1 Message Date
Dmitry Vyukov 144eafd9ee tsan: fix a crash
Fixes crash reported in:
https://bugs.chromium.org/p/v8/issues/detail?id=4995

The problem is that we don't have a processor in a free interceptor
during thread exit.

The crash was introduced by introduction of Processors.
However, previously we silently leaked memory which wasn't any better.

llvm-svn: 268782
2016-05-06 19:35:22 +00:00
Xinliang David Li bedb81e09f Revert r268608 -- unexplained darwin bot failure
llvm-svn: 268779
2016-05-06 19:26:56 +00:00
Renato Golin 039f2ac354 [InstProf] Temporarily removing a test that fails/passes on different configurations (PR27667)
llvm-svn: 268748
2016-05-06 16:44:56 +00:00
Renato Golin 00966ed8b9 XFAILing a test on ARM. See PR27667
llvm-svn: 268745
2016-05-06 15:34:54 +00:00
Kuba Brecka 12aaa1c955 Revert r268716. This has caused test failures in MSan on Linux.
llvm-svn: 268723
2016-05-06 10:23:10 +00:00
Kuba Brecka a609e37ebd [sanitizer] Fix a crash when demangling Swift symbols
To invoke the Swift demangler, we use dlsym to locate swift_demangle. However, dlsym malloc's storage and stores it in thread-local storage. Since allocations from the symbolizer are done with the system allocator (at least in TSan, interceptors are skipped when inside the symbolizer), we will crash when we try to deallocate later using the sanitizer allocator again.

To fix this, let's just not call dlsym from the demangler, and call it during initialization.

Differential Revision: http://reviews.llvm.org/D19974

llvm-svn: 268716
2016-05-06 08:54:58 +00:00
Maxim Ostapenko 6dccd5bc1f [asan] Bail out on stack overflow in recovery mode.
In recovery mode, when ASan detects stack overflow (say, when infinite recursion detected),
it tries to continue program execution and hangs on repetitive error reports. There isn't any
sense to do it, we can just bail out on stack overflow error, because the program would crash soon anyway.

Differential Revision: http://reviews.llvm.org/D19958

llvm-svn: 268713
2016-05-06 07:09:22 +00:00
Xinliang David Li ac96ea422b [profile] Remove another unneeded field in raw profile reader
DataValueSize is now removed. The change is consolidated
with previous raw version bump.

llvm-svn: 268704
2016-05-06 02:13:12 +00:00
Xinliang David Li 2516bcd01c Add a test of VP with shared lib
llvm-svn: 268612
2016-05-05 06:28:12 +00:00
Xinliang David Li 0c09036232 IR value profile testing cleanup
llvm-svn: 268608
2016-05-05 05:41:02 +00:00
Xinliang David Li 2cb6f0ce29 Sync up with master file
llvm-svn: 268603
2016-05-05 04:07:45 +00:00
Mike Aizatsky c826e634cc [sanitizer] Move stat/__xstat to the common interceptors
Summary:
Adds stat/__xstat to the common interceptors.

Removes the now-duplicate stat/__xstat interceptor from msan/tsan/esan.
This adds stat/__xstat to asan, which previously did not intercept it.

Resubmit of http://reviews.llvm.org/D19875 with win build fixes.

Reviewers: aizatsky, eugenis

Subscribers: tberghammer, llvm-commits, danalbert, vitalybuka, bruening, srhines, kubabrecka, kcc

Differential Revision: http://reviews.llvm.org/D19890

llvm-svn: 268466
2016-05-03 23:43:45 +00:00
Mike Aizatsky 7e72f66bf2 Revert "[sanitizer] Move stat/__xstat to the common interceptors"
This reverts commit 268440 because it breaks the windows bot.

http://lab.llvm.org:8011/builders/sanitizer-windows/builds/21425/steps/build%20compiler-rt/logs/stdio

llvm-svn: 268448
2016-05-03 21:49:56 +00:00
Mike Aizatsky 3eb521d417 [sanitizer] Move stat/__xstat to the common interceptors
Summary:
Adds stat/__xstat to the common interceptors.

Removes the now-duplicate stat/__xstat interceptor from msan/tsan/esan.
This adds stat/__xstat to asan, which previously did not intercept it.

Reviewers: aizatsky, eugenis

Subscribers: tberghammer, danalbert, srhines, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, bruening

Differential Revision: http://reviews.llvm.org/D19875

llvm-svn: 268440
2016-05-03 21:22:06 +00:00
Chris Bieneman aa3d2c13bf [CMake] NFC. Add support for testing the compiler without testing the linker
Summary:
One of the big limitations we have in the compiler-rt build system today is that we cannot bootstrap building the builtins because you need a fully functional toolchain to pass CMake's tests.

This change adds support for compile only tests.

It is NFC because nothing is using the compile-only tests yet.

I believe this is the last separable part of D16653.

Reviewers: samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D19692

llvm-svn: 268427
2016-05-03 19:48:11 +00:00
Derek Bruening 2a14132285 [esan] Use do-while rather than braces for empty interceptors
Summary:
Replaces {} with a do..while sequence in esan's empty interceptors to allow
natural use with a trailing semicolon.  The sequence uses each argument to
avoid warnings.

Reviewers: filcab

Subscribers: kubabrecka, llvm-commits, zhaoqin

Differential Revision: http://reviews.llvm.org/D19832

llvm-svn: 268426
2016-05-03 19:44:32 +00:00
Dmitry Vyukov 7a1b7addf8 tsan: update tsan_analyze to what tip clang generates
We used to depend on host gcc. But some distributions got
new gcc recently which broke the check. Generally, we can't
depend that an arbitrary host gcc generates something stable.

Switch to clang.
This has an additional advantage of catching regressions in
clang codegen.

llvm-svn: 268382
2016-05-03 13:59:41 +00:00
Vitaly Buka 8742943cb0 Relax stack check as on some platforms demanglers fail
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
2016-05-02 23:34:40 +00:00
Vitaly Buka 9102fc20f8 Add another failing use-after-scope test
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
2016-05-02 23:12:04 +00:00
Kostya Serebryany 9d91336a83 [compiler-rt] adjust platform_limits_linux.cc #include of posix_types
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
2016-05-02 19:10:48 +00:00
Kostya Serebryany d83c96fa44 [scan-build] fix logic error warning emitted on compiler-rt code base
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
2016-05-02 19:07:20 +00:00
Kuba Brecka a90528bb89 [sanitizer] Fix a crash in SizeClassAllocator32 with an out-of-range pointer
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
2016-05-02 15:23:01 +00:00
Kuba Brecka d052a57900 [sanitizer] Don't reuse the main thread in ThreadRegistry
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
2016-05-02 15:06:08 +00:00
Marcin Koscielnicki ee587cba0e [ASan] Add shadow offset for SystemZ.
This is the compiler-rt counterpart to D19650.

Differential Revision: http://reviews.llvm.org/D19652

llvm-svn: 268162
2016-04-30 10:02:12 +00:00
Filipe Cabecinhas 30cba35a84 Finally fix invalid-pointer-pairs.cc. This time the demangle on the Windows buildbot.
llvm-svn: 268160
2016-04-30 08:34:40 +00:00
Kuba Brecka 9ccde5ace4 [tsan] Return 0 from malloc_size for non-malloc'd pointers
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
2016-04-30 07:14:41 +00:00
Filipe Cabecinhas 486c5d6ae9 Fix test's memory leaks.
llvm-svn: 268138
2016-04-29 23:42:34 +00:00
Filipe Cabecinhas dd754ef857 Try to fix clang-cmake-aarch64-42vma by removing a memory leak (have a global var capture it).
llvm-svn: 268114
2016-04-29 21:33:12 +00:00
Filipe Cabecinhas 04d61050ea [asan] Assert in __sanitizer_ptr_{sub,cmp} if one of the pointers was freed.
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
2016-04-29 20:37:34 +00:00
Marcin Koscielnicki 14824b1c52 [sanitizers] [SystemZ] Mark kernel 3.12.58+ as safe from CVE-2016-2143.
llvm-svn: 268046
2016-04-29 14:59:19 +00:00
Evgeniy Stepanov 01c7450ec5 [msan] Tests for vector compare intrinsics.
llvm-svn: 267967
2016-04-29 01:20:05 +00:00
Marcin Koscielnicki a0193ecfe1 [ASan] [SystemZ] Mark segv_read_write.c as UNSUPPORTED.
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
2016-04-29 00:43:20 +00:00
Marcin Koscielnicki 174f8b1981 [ASan] Reenable __builtin_setjmp test on PowerPC, disable on SystemZ.
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
2016-04-28 22:23:19 +00:00
Chris Bieneman 257fe3ab99 [CMake] Adding another missing include. NFC.
This also works fine today, but will break with my upcoming refactoring.

llvm-svn: 267941
2016-04-28 21:16:45 +00:00
Chris Bieneman 551ccac7e4 [CMake] Updating Apple CMake cache file
Changing the Apple CMake cache file to better match the way Apple Clang builds are built.

llvm-svn: 267913
2016-04-28 18:24:29 +00:00
Chris Bieneman 1dd58a7018 [CMake] Adding some missing CMake includes. NFC.
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
2016-04-28 18:22:01 +00:00
Vedant Kumar 6a2ec9fc57 [test/asan] Update a test case to work with old Darwin SDK's
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
2016-04-28 17:48:35 +00:00
Peter Collingbourne f730de619f Update visibility flags for CFI tests.
Differential Revision: http://reviews.llvm.org/D18813

llvm-svn: 267902
2016-04-28 17:09:09 +00:00
Kuba Brecka dc7b607b09 [tsan] Fix Darwin GCD support after separation of Processor and ThreadState
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
2016-04-28 09:26:30 +00:00
Marcin Koscielnicki 0bec2fef8e [MSan] [PowerPC] Dereference function descriptors when recording stack origins.
Differential Revision: http://reviews.llvm.org/D19543

llvm-svn: 267795
2016-04-27 21:24:24 +00:00
Marcin Koscielnicki 66f0deacb5 [sanitizers] Get the proper symbol version when long double transition is 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
2016-04-27 21:24:21 +00:00
Derek Bruening 41939466d1 [sanitizer] Add early call handling to strchr + strrchr interceptors
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
2016-04-27 21:20:46 +00:00
Mike Aizatsky ccd318dc7e [sanitizers] read/write page fault detection on mac.
Summary: Resubmit of http://reviews.llvm.org/D19495 enabled only on intel.

Subscribers: kubabrecka

Differential Revision: http://reviews.llvm.org/D19561

llvm-svn: 267750
2016-04-27 18:02:21 +00:00
Marcin Koscielnicki b7b5ac60c4 [sanitizer] [SystemZ] Abort if the kernel might be vulnerable to CVE-2016-2143.
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
2016-04-27 17:42:00 +00:00
Reid Kleckner a16ef7633b Un-XFAIL tests on Windows after fixing PR27492
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
2016-04-27 16:38:03 +00:00
Dmitry Vyukov 914b399736 tsan: fix windows support
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
2016-04-27 15:55:05 +00:00
Dmitry Vyukov 4592eb0534 tsan: fix darwin Go support
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
2016-04-27 14:28:42 +00:00
Dmitry Vyukov 221e2c61ec tsan: fix windows Go support
Unmap can't unmap arbitrary regions on windows.

llvm-svn: 267716
2016-04-27 14:03:14 +00:00
Dmitry Vyukov 51c294a9e8 tsan: fix darwin Go build
syslog_lock is not defined in Go build.

llvm-svn: 267714
2016-04-27 13:40:05 +00:00
Dmitry Vyukov 3e0315c044 tsan: make windows shadow mapping a bijection
CheckShadowMapping function started catching that
mem->shadow->mem mapping is not bijection.
Make it bijection.

llvm-svn: 267713
2016-04-27 13:34:01 +00:00