Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Rebase Rust changes on LLVM head #15

Closed
wants to merge 68 commits into from
Closed

Rebase Rust changes on LLVM head #15

wants to merge 68 commits into from

Conversation

angelsl
Copy link

@angelsl angelsl commented Nov 6, 2015

cc: @vadimcn @vhbit @alexcrichton

I will open the PR on the main repo when this is merged. rust-lang/rust#29659

Hal Finkel and others added 30 commits October 23, 2015 20:37
Fixing up this test case because LLVM is smarter now, and can better analyze:

  if ((argc << shift) == 16)

in this test case.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251147 91177308-0d34-0410-b5e6-96231b3b80d8
This patch enables the ptrace syscall interceptors for arm and adds support
for both PTRACE_GETVFPREGS and PTRACE_SETVFPREGS used to get the VFP register
from ARM.

The ptrace tests is also updated with arm and PTRACE_GETVFPREGS tests.


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251321 91177308-0d34-0410-b5e6-96231b3b80d8
This patch fixes the ptrace interceptor for aarch64. The PTRACE_GETREGSET
ptrace syscall with with invalid memory might zero the iovec::iov_base
field and then masking the subsequent check after the syscall (since it
will be 0 and it will not trigger an invalid access). The fix is to copy
the value on a local variable and use its value on the checks.

The patch also adds more coverage on the Linux/ptrace.cc testcase by addding
check for PTRACE_GETREGSET for both general and floating registers (aarch64
definitions added only).


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251331 91177308-0d34-0410-b5e6-96231b3b80d8
The check for the glibc version was not working as expected (dlsym
was finding the interceptor instead of the libc implementation).

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251345 91177308-0d34-0410-b5e6-96231b3b80d8
Asanwrapper is required on older android versions to work around undesired
linker behavior. It is not required on L and newer, and does not fully
support multiarch devices.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251359 91177308-0d34-0410-b5e6-96231b3b80d8
We've switched to Gold earlier because of a minor misconfiguration
of the BFD linker in Android NDK. It turns out, Gold has much bigger
problems:

https://sourceware.org/bugzilla/show_bug.cgi?id=19163
(a bug is actually in the android runtime loader, but it means that
gold does not work with android L and even M).

Switching back to BFD and adding a workaround by explicitly linking
libm to all tests.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251360 91177308-0d34-0410-b5e6-96231b3b80d8
The test is sensitive to stack layout changes. Tweak it a bit to
expose the bug on aarch64 as well as on arm.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251361 91177308-0d34-0410-b5e6-96231b3b80d8
This will tag all mmapped memory sanitizers use with "Performance tool data"
when viewed in vmmap. (Even though sanitizers are not performance tools, it's
the best available match and better than having the unidentified objects.)

http://reviews.llvm.org/D13609

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251445 91177308-0d34-0410-b5e6-96231b3b80d8
When ASan currently detects a bug, by default it will only print out the text
of the report to stderr. This patch changes this behavior and writes the full
text of the report to syslog before we terminate the process. It also calls
os_trace (Activity Tracing available on OS X and iOS) with a message saying
that the report is available in syslog. This is useful, because this message
will be shown in the crash log.

For this to work, the patch makes sure we store the full report into
error_message_buffer unconditionally, and it also strips out ANSI escape
sequences from the report (they are used when producing colored reports).

I've initially tried to log to syslog during printing, which is done on Android
right now. The advantage is that if we crash during error reporting or the
produced error does not go through ScopedInErrorReport, we would still get a
(partial) message in the syslog. However, that solution is very problematic on
OS X. One issue is that the logging routine uses GCD, which may spawn a new
thread on its behalf. In many cases, the reporting logic locks threadRegistry,
which leads to deadlocks.

Reviewed at http://reviews.llvm.org/D13452

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251447 91177308-0d34-0410-b5e6-96231b3b80d8
It was recently enabled for non-x86 targets and doesn't seem to work for MIPS.
The reason is currently unclear so XFAILing while I investigate.



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251466 91177308-0d34-0410-b5e6-96231b3b80d8
This reverts commit 251447.

(Which caused failures on a Linux bot.)

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251467 91177308-0d34-0410-b5e6-96231b3b80d8
Summary:
I have othen been stuck when I got an ASAN report, but no symbols
are resolved. The reasons might be different, and it always 
requires a bit of detective work to track down.

These more verbose error messages will help the users like me.

Reviewers: samsonov

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251553 91177308-0d34-0410-b5e6-96231b3b80d8
app_process32, when started via a shell script wrapper, needs a
different security context to satisty SELinux.

Patch by Abhishek Arya.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251572 91177308-0d34-0410-b5e6-96231b3b80d8
        When ASan currently detects a bug, by default it will only print out the text
        of the report to stderr. This patch changes this behavior and writes the full
        text of the report to syslog before we terminate the process. It also calls
        os_trace (Activity Tracing available on OS X and iOS) with a message saying
        that the report is available in syslog. This is useful, because this message
        will be shown in the crash log.

        For this to work, the patch makes sure we store the full report into
        error_message_buffer unconditionally, and it also strips out ANSI escape
        sequences from the report (they are used when producing colored reports).

        I've initially tried to log to syslog during printing, which is done on Android
        right now. The advantage is that if we crash during error reporting or the
        produced error does not go through ScopedInErrorReport, we would still get a
        (partial) message in the syslog. However, that solution is very problematic on
        OS X. One issue is that the logging routine uses GCD, which may spawn a new
        thread on its behalf. In many cases, the reporting logic locks threadRegistry,
        which leads to deadlocks.

        Reviewed at http://reviews.llvm.org/D13452

        (In addition, add sanitizer_common_libcdep.cc to buildgo.sh to avoid
         build failures on Linux.)

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251577 91177308-0d34-0410-b5e6-96231b3b80d8
This patch unify the 39-bit and 42-bit mapping for aarch64 to use only
one instrumentation algorithm.  A runtime check avoid mapping 42-bit 
only segments for 39-bit kernels.

The mapping to use now is for 39 and 42-bits:

    0x00000000000ULL-0x01000000000ULL  MappingDesc::INVALID
    0x01000000000ULL-0x02000000000ULL  MappingDesc::SHADOW
    0x02000000000ULL-0x03000000000ULL  MappingDesc::ORIGIN
    0x03000000000ULL-0x04000000000ULL  MappingDesc::SHADOW
    0x04000000000ULL-0x05000000000ULL  MappingDesc::ORIGIN
    0x05000000000ULL-0x06000000000ULL  MappingDesc::APP
    0x06000000000ULL-0x07000000000ULL  MappingDesc::INVALID
    0x07000000000ULL-0x08000000000ULL  MappingDesc::APP

And only for 42-bits:

    0x08000000000ULL-0x09000000000ULL  MappingDesc::INVALID
    0x09000000000ULL-0x0A000000000ULL  MappingDesc::SHADOW
    0x0A000000000ULL-0x0B000000000ULL  MappingDesc::ORIGIN
    0x0B000000000ULL-0x0F000000000ULL  MappingDesc::INVALID
    0x0F000000000ULL-0x10000000000ULL  MappingDesc::APP
    0x10000000000ULL-0x11000000000ULL  MappingDesc::INVALID
    0x11000000000ULL-0x12000000000ULL  MappingDesc::APP
    0x12000000000ULL-0x17000000000ULL  MappingDesc::INVALID
    0x17000000000ULL-0x18000000000ULL  MappingDesc::SHADOW
    0x18000000000ULL-0x19000000000ULL  MappingDesc::ORIGIN
    0x19000000000ULL-0x20000000000ULL  MappingDesc::INVALID
    0x20000000000ULL-0x21000000000ULL  MappingDesc::APP
    0x21000000000ULL-0x26000000000ULL  MappingDesc::INVALID
    0x26000000000ULL-0x27000000000ULL  MappingDesc::SHADOW
    0x27000000000ULL-0x28000000000ULL  MappingDesc::ORIGIN
    0x28000000000ULL-0x29000000000ULL  MappingDesc::SHADOW
    0x29000000000ULL-0x2A000000000ULL  MappingDesc::ORIGIN
    0x2A000000000ULL-0x2B000000000ULL  MappingDesc::APP
    0x2B000000000ULL-0x2C000000000ULL  MappingDesc::INVALID
    0x2C000000000ULL-0x2D000000000ULL  MappingDesc::SHADOW
    0x2D000000000ULL-0x2E000000000ULL  MappingDesc::ORIGIN
    0x2E000000000ULL-0x2F000000000ULL  MappingDesc::APP
    0x2F000000000ULL-0x39000000000ULL  MappingDesc::INVALID
    0x39000000000ULL-0x3A000000000ULL  MappingDesc::SHADOW
    0x3A000000000ULL-0x3B000000000ULL  MappingDesc::ORIGIN
    0x3B000000000ULL-0x3C000000000ULL  MappingDesc::APP
    0x3C000000000ULL-0x3D000000000ULL  MappingDesc::INVALID
    0x3D000000000ULL-0x3E000000000ULL  MappingDesc::SHADOW
    0x3E000000000ULL-0x3F000000000ULL  MappingDesc::ORIGIN
    0x3F000000000ULL-0x40000000000ULL  MappingDesc::APP

And although complex it provides a better memory utilization that
previous one.

[1] http://reviews.llvm.org/D13817


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251625 91177308-0d34-0410-b5e6-96231b3b80d8
Define WIN32_LEAN_AND_MEAN before including Windows.h.  This is already being
done in some places.  This does it more broadly.  This permits building ASAN on
Linux for Winndows, as well as reduces the amount of included declarations.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251649 91177308-0d34-0410-b5e6-96231b3b80d8
This reverts commit r250823.

Replacing at least some of empty
constructors with "= default" variants is a semantical change which we
don't want. E.g. __tsan::ClockBlock contains a union of large arrays,
and it's critical for correctness and performance that we don't memset()
these arrays in the constructor.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251717 91177308-0d34-0410-b5e6-96231b3b80d8
Hi, this patch adds a CMake flag called `COMPILER_RT_ENABLE_TSAN_OSX`, which is off by default. If enabled, the build system will be building the OS X version of the TSan runtime library (called `libclang_rt.tsan_osx_dynamic.dylib`). I'll submit patches that fix OS X build errors shortly.

This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251915 91177308-0d34-0410-b5e6-96231b3b80d8
This patch modifies `tsan_interceptors.cc` to be buildable on OS X. Several of the intercepted methods are not available on OS X, so we need to `#if !SANITIZER_MAC` them. Plus a few other fixes, e.g. `pthread_yield` doesn't exist, let's use `internal_sched_yield` instead.

This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.

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




git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251916 91177308-0d34-0410-b5e6-96231b3b80d8
This patch moves a few functions from `sanitizer_linux_libcdep.cc` to `sanitizer_posix_libcdep.cc` in order to use them on OS X as well. Plus a few more small build fixes.

This is part of an effort to port TSan to OS X, and it's one the very first steps. Don't expect TSan on OS X to actually work or pass tests at this point.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@251918 91177308-0d34-0410-b5e6-96231b3b80d8
kubamracek and others added 26 commits November 5, 2015 10:31
TSan needs to use a custom malloc zone on OS X, which is already implemented in ASan.  This patch uses the sanitizer_common implementation in `sanitizer_malloc_mac.inc` for TSan as well.

Reviewed at http://reviews.llvm.org/D14330




git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252155 91177308-0d34-0410-b5e6-96231b3b80d8
This implements a "poor man's TLV" to be used for TSan's ThreadState on OS X. Based on the fact that `pthread_self()` is always available and reliable and returns a valid pointer to memory, we'll use the shadow memory of this pointer as a thread-local storage. No user code should ever read/write to this internal libpthread structure, so it's safe to use it for this purpose. We lazily allocate the ThreadState object and store the pointer here.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252159 91177308-0d34-0410-b5e6-96231b3b80d8
TSan has a re-implementation of `pthread_once` in its interceptor, which assumes that the `pthread_once_t *once_control` pointer is actually pointing to a "storage" which is zero-initialized and used for the atomic operations. However, that's not true on OS X, where pthread_once_t is a structure, that contains a header (with a magic value) and the actual storage follows after that. This patch skips the header to make the interceptor work on OS X.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252160 91177308-0d34-0410-b5e6-96231b3b80d8
A call to memmove is used early during new thread initialization on OS X. This patch uses the `COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED` check, similarly to how we deal with other early-used interceptors.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252161 91177308-0d34-0410-b5e6-96231b3b80d8
On OS X, memcpy and memmove are actually aliases of the same implementation, which means the interceptor of memcpy is also invoked when memmove is called. The current implementation of the interceptor uses `internal_memcpy` to perform the actual memory operation, which can produce an incorrect result when memmove semantics are expected. Let's call `internal_memmove` instead.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252162 91177308-0d34-0410-b5e6-96231b3b80d8
Fixing `tsan_interceptors.cc`, which on OS X produces a bunch of warnings about unused constants and functions.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252165 91177308-0d34-0410-b5e6-96231b3b80d8
… fixes of tests and __fixuint

Summary:
The following tests for 128-bit floating-point type behaved in a strange way, thought it were bugs, but seem to be mistakes in tests:

 * `fixtfsi` test checked for `0x80000001` as a value returned for number less than can be represented, while `LONG_MIN` should be returned on saturation;
 * `fixunstfdi` wasn't enabled for AArch64, only for PPC, but there is nothing PPC specific in that test;
 * `multf3` tried to underflow multiplication by producing result with 16383 exponent, while there are still 112 bits of fraction plus implicit bit, so resultant exponent should be 16497.

Tests for some other builtins didn't exist:

 * `fixtfdi`
 * `fixtfti`
 * `fixunstfti`

They were made by copying similar files and adjusting for wider types and adding/removing some reasonable/extra checks.

Also `__fixuint` seems to have off by one error, updated tests to catch this case.

Reviewers: rengolin, zatrazz, howard.hinnant, t.p.northover, jmolloy, enefaim

Subscribers: aemerson, llvm-commits, rengolin

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

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252180 91177308-0d34-0410-b5e6-96231b3b80d8
OS X doesn't have `pthread_yield`. Let's use `sched_yield` instead.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252283 91177308-0d34-0410-b5e6-96231b3b80d8
This patch adds `tsan_new_delete.cc` into the OS X build.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252284 91177308-0d34-0410-b5e6-96231b3b80d8
The current implementation does not work on darwin and can have issues with other OSes in future.
See http://reviews.llvm.org/D14427
Make it portable once and for all (minus usleep call).

Reviewed in:
http://reviews.llvm.org/D14434




git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252292 91177308-0d34-0410-b5e6-96231b3b80d8
This patch enables running lit tests on OS X:
1) Simply enable tests for Darwin (they were restricted to Linux and FreeBSD).
2) Disable using instrumented libcxx (libcxx_tsan) on Darwin.
3) On Darwin, override abort_on_error=0, otherwise all tests would generate crash logs and take much longer to process.

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



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@252309 91177308-0d34-0410-b5e6-96231b3b80d8
Based on 1957424 (vadimcn)
clang_linux.mk was complaining on AArch64. These makefiles create
targets that are never used anyway, so let's remove them.
@alexcrichton
Copy link
Member

@angelsl angelsl deleted the rust5 branch November 9, 2015 03:23
TimNN pushed a commit that referenced this pull request Apr 13, 2017
Enable more ignores when we start crashing.
Unwind in CHECK SIGSEGVs if happens early:

FATAL: ThreadSanitizer CHECK failed: ../projects/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc:105 "((beg)) <= ((end))" (0x8000000000, 0x4000000000)
Program received signal SIGSEGV, Segmentation fault.
__tsan::MetaMap::GetAndLock (this=0x1337c88 <__tsan::ctx_placeholder+8>, thr=thr@entry=0x7ffff7f91800, pc=pc@entry=4639488, addr=addr@entry=140737339086992, write_lock=write_lock@entry=true, 
    create=create@entry=true) at ../projects/compiler-rt/lib/tsan/rtl/tsan_sync.cc:208
208	  u32 idx0 = *meta;
(gdb) bt
#0  __tsan::MetaMap::GetAndLock (this=0x1337c88 <__tsan::ctx_placeholder+8>, thr=thr@entry=0x7ffff7f91800, pc=pc@entry=4639488, addr=addr@entry=140737339086992, write_lock=write_lock@entry=true, 
    create=create@entry=true) at ../projects/compiler-rt/lib/tsan/rtl/tsan_sync.cc:208
#1  0x00000000004a965f in __tsan::MetaMap::GetOrCreateAndLock (this=<optimized out>, thr=thr@entry=0x7ffff7f91800, pc=pc@entry=4639488, addr=addr@entry=140737339086992, write_lock=write_lock@entry=true)
    at ../projects/compiler-rt/lib/tsan/rtl/tsan_sync.cc:198
#2  0x00000000004a162a in __tsan::Release (thr=0x7ffff7f91800, pc=pc@entry=4639488, addr=addr@entry=140737339086992) at ../projects/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc:395
#3  0x000000000046cc40 in __interceptor_pthread_once (o=0x7ffff71a5890 <once_regsizes>, f=0x7ffff6f9d9c0 <init_dwarf_reg_size_table>) at ../projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:1334
#4  0x00007ffff6f9fe86 in __gthread_once (__func=0x7ffff6f9d9c0 <init_dwarf_reg_size_table>, __once=0x7ffff71a5890 <once_regsizes>) at ./gthr-default.h:699
#5  uw_init_context_1 (context=context@entry=0x7fffffffd6d0, outer_cfa=outer_cfa@entry=0x7fffffffd980, outer_ra=0x437d13 <__sanitizer::BufferedStackTrace::SlowUnwindStack(unsigned long, unsigned int)+67>)
    at ../../../src/libgcc/unwind-dw2.c:1572
#6  0x00007ffff6fa06a8 in _Unwind_Backtrace (trace=0x437c30 <__sanitizer::Unwind_Trace(_Unwind_Context*, void*)>, trace_argument=0x7fffffffd980) at ../../../src/libgcc/unwind.inc:283
#7  0x0000000000437d13 in __sanitizer::BufferedStackTrace::SlowUnwindStack (this=0x7ffff6103208, pc=pc@entry=4863574, max_depth=max_depth@entry=256)
    at ../projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:125
#8  0x0000000000434f4a in __sanitizer::BufferedStackTrace::Unwind (this=this@entry=0x7ffff6103208, max_depth=max_depth@entry=256, pc=pc@entry=4863574, bp=bp@entry=0, context=context@entry=0x0, 
    stack_top=stack_top@entry=0, stack_bottom=stack_bottom@entry=0, request_fast_unwind=request_fast_unwind@entry=false) at ../projects/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc:76
#9  0x00000000004a36b3 in PrintCurrentStackSlow (pc=4863574) at ../projects/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc:696
#10 __tsan::TsanCheckFailed (file=<optimized out>, line=<optimized out>, cond=<optimized out>, v1=<optimized out>, v2=<optimized out>) at ../projects/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc:44
#11 0x000000000042dfd6 in __sanitizer::CheckFailed (file=file@entry=0x4b9fd0 "../projects/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc", line=line@entry=105, 
    cond=cond@entry=0x4ba049 "((beg)) <= ((end))", v1=v1@entry=549755813888, v2=v2@entry=274877906944) at ../projects/compiler-rt/lib/sanitizer_common/sanitizer_termination.cc:79
#12 0x00000000004aa36c in ProtectRange (end=274877906944, beg=549755813888) at ../projects/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc:105
#13 __tsan::CheckAndProtect () at ../projects/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc:133
#14 0x00000000004a9e95 in __tsan::InitializePlatform () at ../projects/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc:280
#15 0x0000000000497e73 in __tsan::Initialize (thr=0x7ffff7f91800) at ../projects/compiler-rt/lib/tsan/rtl/tsan_rtl.cc:343
#16 0x00007ffff7dea25a in _dl_init (main_map=0x7ffff7ffe1c8, argc=1, argv=0x7fffffffdb88, env=0x7fffffffdb98) at dl-init.c:111
#17 0x00007ffff7ddb30a in _dl_start_user () at rtld.c:871



git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281969 91177308-0d34-0410-b5e6-96231b3b80d8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.