Commit Graph

5475 Commits

Author SHA1 Message Date
Dmitry Vyukov 57f2e64c06 tsan: fix parsing of second_deadlock_stack flag
It was broken during flag parsing refactoring.
Enable test for the flag.

llvm-svn: 234878
2015-04-14 10:32:33 +00:00
Timur Iskhodzhanov 3d6c6fbef2 Cast an argument to mprotect syscall to uptr to fix X32
llvm-svn: 234748
2015-04-13 12:13:03 +00:00
Dimitry Andric 66749021d4 Make check_custom_wrappers.sh work on FreeBSD
Summary:
When running the compiler-rt testsuite on FreeBSD (it didn't matter which version), I always got the same error result:

    FAILED: cd /home/dim/obj/llvm-234092-trunk-freebsd10-amd64-ninja-rel-1/projects/compiler-rt/lib && LLVM_CHECKOUT=/home/dim/src/llvm/trunk SILENT=1 TMPDIR= PYTHON_EXECUTABLE=/usr/local/bin/python2.7 COMPILER_RT=/home/dim/src/llvm/trunk/projects/compiler-rt /home/dim/src/llvm/trunk/projects/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh
    The following differences between the implemented custom wrappers and the tests have been found:
    --- /tmp/tmp.vPFEefvclf 2015-04-04 17:11:44.996734563 +0200
    +++ /tmp/tmp.NbIuvjxKEe 2015-04-04 17:11:45.044734647 +0200
    @@ -1,52 +0,0 @@
    -calloc
    -clock_gettime
    -ctime_r
    -dfsan_set_write_callback
    -dl_iterate_phdr
    -dlopen
    -fgets
    -fstat
    -get_current_dir_name
    -getcwd
    -gethostname
    -getpwuid_r
    -getrlimit
    -getrusage
    -gettimeofday
    -inet_pton
    -localtime_r
    -memchr
    -memcmp
    -memcpy
    -memset
    -nanosleep
    -poll
    -pread
    -pthread_create
    -read
    -sched_getaffinity
    -select
    -sigaction
    -sigemptyset
    -snprintf
    -socketpair
    -sprintf
    -stat
    -strcasecmp
    -strchr
    -strcmp
    -strcpy
    -strdup
    -strlen
    -strncasecmp
    -strncmp
    -strncpy
    -strrchr
    -strstr
    -strtod
    -strtol
    -strtoll
    -strtoul
    -strtoull
    -time
    -write

After some investigation, it turns out to be due to the regex used for search test_ symbols in lib/dfsan/scripts/check_customer_wrappers.sh:

    grep -E "^\\s*test_.*\(\);" ${DFSAN_CUSTOM_TESTS}

This uses \s to search for whitespace at start of line, but support for \s was only introduced in GNU grep v2.5.4-112-gf979ca0, while both FreeBSD and OSX only have grep 2.5.1 (the last version released under GPLv2).

I propose to change \s into [[:space:]], which is the more portable notation.

Test Plan: Run regression tests, and see that they work now. :)

Reviewers: pcc, samsonov, emaste

Reviewed By: emaste

Subscribers: llvm-commits, emaste

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

llvm-svn: 234704
2015-04-12 10:54:46 +00:00
Kuba Brecka 93c6a668fc [Sanitizer] Merge POSIXSymbolizer and WinSymbolizer
The two subclasses of Symbolizer now only define two virtual functions, PlatformDemangle and PlatformPrepareForSandboxing. Let's make these non-virtual and directly defined by individual platforms.

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

llvm-svn: 234690
2015-04-11 17:16:25 +00:00
Alexander Kornienko d829812f65 Use 'override/final' instead of 'virtual' for overridden methods
The patch is generated using clang-tidy misc-use-override check.

This command was used:

  tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
    -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix \
    -format

llvm-svn: 234680
2015-04-11 02:44:24 +00:00
Lorenzo Martignoni 4879003022 Extend s{,n}printf custom wrappers to support '*' in the format specifiers
Differential Revision: http://reviews.llvm.org/D8966

llvm-svn: 234633
2015-04-10 20:58:28 +00:00
Timur Iskhodzhanov bd989e78f1 [ASan] Use a better name for a function parameter
llvm-svn: 234604
2015-04-10 15:31:16 +00:00
Timur Iskhodzhanov ea1f332b79 Split Mprotect into MmapNoAccess and MprotectNoAccess to be more portable
On Windows, we have to know if a memory to be protected is mapped or not.
On POSIX, Mprotect was semantically different from mprotect most people know.

llvm-svn: 234602
2015-04-10 15:02:19 +00:00
Dmitry Vyukov 4bf08947a1 [sanitizer][MIPS] Fix warnings on MIPS
Fixed:
- stack frame size warning.
- msse3 flag unused warning.
- GoTsanRuntimeCheck dependency warning reported by cmake.

Change by Sagar Thakur
Reviewed in http://reviews.llvm.org/D8963

llvm-svn: 234579
2015-04-10 09:45:22 +00:00
Peter Collingbourne 8f9a3f2d7e Revert r234477, "Differential Revision: http://reviews.llvm.org/D7249"
Should unbreak fuzzer buildbot.

llvm-svn: 234542
2015-04-09 22:42:01 +00:00
Timur Iskhodzhanov 8f40f03024 [ASan/Win] Add a test that makes sure coverage works at least in the simple cases
llvm-svn: 234496
2015-04-09 15:58:38 +00:00
Timur Iskhodzhanov 007435c1b7 [ASan/Win] Add more support for file operations
llvm-svn: 234494
2015-04-09 15:25:21 +00:00
Timur Iskhodzhanov 4eb084cda3 Use error_t rather than int in a couple of places where we handle files
llvm-svn: 234491
2015-04-09 14:49:53 +00:00
Timur Iskhodzhanov a6600a974a Use RenameFile instead of internal_rename in non-POSIX code
llvm-svn: 234490
2015-04-09 14:45:17 +00:00
Timur Iskhodzhanov e8a6fbbfd3 Use WriteToFile instead of internal_write in non-POSIX code
llvm-svn: 234487
2015-04-09 14:11:25 +00:00
Timur Iskhodzhanov 2b391694bf Use ReadFromFile instead of internal_read in non-POSIX code
llvm-svn: 234485
2015-04-09 13:38:14 +00:00
Timur Iskhodzhanov 5df4d0471f Move more POSIX-specific functions to sanitizer_posix.h
llvm-svn: 234482
2015-04-09 12:54:06 +00:00
Timur Iskhodzhanov 864308a78d Introduce CloseFile to be used instead of internal_close on non-POSIX
llvm-svn: 234481
2015-04-09 12:37:05 +00:00
Timur Iskhodzhanov 1b2ff68408 Replace a hard-coded constant with a named one
llvm-svn: 234479
2015-04-09 12:20:02 +00:00
Lorenzo Martignoni 59886f3c1a Differential Revision: http://reviews.llvm.org/D7249
llvm-svn: 234477
2015-04-09 11:42:33 +00:00
Kuba Brecka 2aa8c8fd17 [Sanitizer] Get rid of PlatformGetListOfModules
Moving the implementation of several functions from sanitizer_symbolizer.cc into sanitizer_symbolizer_libcdep.cc.

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

llvm-svn: 234472
2015-04-09 09:37:46 +00:00
Yury Gribov 8e49b47e0a [ASan] Only include rpc headers if they are available.
Reviewed at http://reviews.llvm.org/D8698

llvm-svn: 234470
2015-04-09 08:06:49 +00:00
Mohit K. Bhakkad 0eccfdc655 [Compiler-rt][MIPS] Fix for asan test suite build on mips64/mips64el
Patch by Sagar Thakur

Reviewers: dsanders
llvm-svn: 234468
2015-04-09 06:58:32 +00:00
Timur Iskhodzhanov c2c9ea5525 [Sanitizer RT] Get rid of internal_isatty
llvm-svn: 234423
2015-04-08 17:42:57 +00:00
Timur Iskhodzhanov 3745303c5b Move some POSIX-specific functions from sanitizer_libc.h to a new sanitizer_posix.h
llvm-svn: 234418
2015-04-08 17:08:24 +00:00
Timur Iskhodzhanov daa9e2d4e8 [Sanitizers] Make OpenFile more portable
llvm-svn: 234410
2015-04-08 16:03:22 +00:00
Dmitry Vyukov 8e39c404a0 tsan: handle async signals while blocked in pthread_cond_wait
Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=91

llvm-svn: 234394
2015-04-08 07:48:52 +00:00
Dmitry Vyukov 1e5b9f4131 sanitizer: new "strict_string_checks" run-time flag
This patch is related to Issue 346: moar string interceptors: strstr, strcasestr, strcspn, strpbrk
As was suggested in original review http://reviews.llvm.org/D6056 a new "strict_string_checks" run-time flag introduced.
The flag support applied for existing common, asan, msan and tsan interceptors. New asan tests added.

Change by Maria Guseva reviewed in http://reviews.llvm.org/D7123

llvm-svn: 234187
2015-04-06 18:00:26 +00:00
Timur Iskhodzhanov 1931b62632 Minor follow-up fix to r234150
llvm-svn: 234151
2015-04-06 12:54:06 +00:00
Timur Iskhodzhanov b97bcc4981 [ASan] Unify handling of loaded modules between POSIX and Windows
Reviewed at http://reviews.llvm.org/D8805

llvm-svn: 234150
2015-04-06 12:49:30 +00:00
Sergey Dmitrouk f3206d6278 Add hard float versions of FP to LL conversions
This adds hard-float implementation for the following builtins:

* __fixdfdi()
* __fixsfdi()
* __fixunsdfdi()
* __fixunssfdi()

The soft-float implementation does never raise floating point
exceptions, which doesn't allow clients to detect floating point
conversion errors.

I must mention that I had to refer to libgcc's implementation to
write these functions.

Related unit-tests of compiler-rt passed with these changes.

Patch was somewhat out-dated, so was updated locally without any
functional changes.

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

llvm-svn: 234148
2015-04-06 11:54:51 +00:00
Alexander Potapenko d403b29254 [ASan] Do not print thread IDs and stacks for unknown threads.
llvm-svn: 234147
2015-04-06 10:32:45 +00:00
Dmitry Vyukov 19300f856b tsan: fix munmap interceptor
MetaMap::ResetRange/FreeRange rounds the range up to at least kMetaShadowSize.
This is requried for e.g. free(malloc(0)). However, munmap returns EINVAL
and do not unmap any memory when length arguments is equal to 0.
So don't free meta shadow in this case as well.

llvm-svn: 234145
2015-04-06 07:57:32 +00:00
Justin Bogner 7759f1899e Add missing include
llvm-svn: 234037
2015-04-03 19:10:35 +00:00
Justin Bogner 8e1a2a3277 profile: Protect .gcda output with flock
This avoids crashing or corrupting data if multiple concurrent
processes write to the same .gcda file. This is hard to test, since
the previous behaviour was a data race that often worked out, and it
ignores errors in flock to fall back to the old racy behaviour so that
it won't degrade the behaviour on filesystems that don't support
flock.

llvm-svn: 234036
2015-04-03 18:55:44 +00:00
Evgeniy Stepanov e2a8241f84 [sancov] Shrink pc array on Android back to 2**24.
Address space is a lot more constrained on 32-bit Android compared to Linux.

llvm-svn: 234010
2015-04-03 12:59:39 +00:00
Timur Iskhodzhanov ad3ec82bb1 [ASan/Win] Minor improvements towards enabling coverage
llvm-svn: 233918
2015-04-02 14:48:08 +00:00
Alexey Samsonov d4273ebbf3 Add missing " at the end of the #error directive.
llvm-svn: 233879
2015-04-02 01:13:43 +00:00
Peter Collingbourne 7881648a4e Add tests for non-virtual call checking.
Differential Revision: http://reviews.llvm.org/D8792

llvm-svn: 233876
2015-04-02 00:33:36 +00:00
Alexey Samsonov 9c2116d912 [CMake] Fixup for r233861: don't build standalone UBSan on unsupported platforms.
llvm-svn: 233865
2015-04-01 23:00:02 +00:00
Alexey Samsonov 09dce3b7e5 [UBSan] Embed UBSan into ASan runtime (compiler-rt part).
Summary:
Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan
into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on
a platform, all UBSan sources are just compiled into dummy empty object
files. UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.

This mirrors the approach we already use for ASan+LSan. This change
doesn't modify the way we use standalone UBSan.

Test Plan: regression test suite

Reviewers: kubabrecka, zaks.anna, rsmith, kcc

Subscribers: llvm-commits

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

llvm-svn: 233861
2015-04-01 22:42:36 +00:00
Alexander Potapenko 0ae78444e7 [ASan] Make the remaining coverage tests pass on Darwin, move them to Posix/
This CL:
 - moves PrepareForSandboxing() to sanitizer_posix_libcdep.cc
 - fixes the coverage tests to use flag substitutions defined in r233802 and not rely on hardcoded shared library names
 - moves those tests to TestCases/Posix so that they can be executed on Darwin

llvm-svn: 233828
2015-04-01 17:56:29 +00:00
Bill Seurer f1b82e3ad1 Remove XFAILs from cast-overflow.cpp
My fix for power also fixed armv7l-unknown-linux-gnueabihf and aarch64

llvm-svn: 233827
2015-04-01 17:50:39 +00:00
Alexander Potapenko 9be2c6544b [ASan] Speculative fix for TestCases/Posix/interception-in-shared-lib-test.cc and TestCases/suppressions-library.cc on FreeBSD.
r233802 has moved the tests above to Posix/ and introduced %ld_flags_rpath_so and %ld_flags_rpath_exe,
which haven't been defined for FreeBSD.
We expect the flags to be the same on Linux and FreeBSD. If there's another reason for the tests to fail on FreeBSD,
they'll need to be disabled.

llvm-svn: 233822
2015-04-01 17:07:50 +00:00
Bill Seurer 4c41366510 [PPC64]This activates UBSan for the power architecture.
One test case is updated to allow for differences between power and other architectures in behavior when returning from main in certain instances

http://reviews.llvm.org/D8743

llvm-svn: 233813
2015-04-01 15:33:22 +00:00
Timur Iskhodzhanov 882bc56ff1 [Sanitizers Coverage] Make sancov.py work with wildcards from Windows CMD shell
Reviewed at http://reviews.llvm.org/D8724

llvm-svn: 233809
2015-04-01 14:46:10 +00:00
Alexander Potapenko 8db9e77ba7 [ASan] Deduplicate interception-in-shared-lib-test.cc by introducing platform-specific substitutions for rpath linker flags
Also make suppressions-library.cc use the same flags to avoid warnings about unused -rpath flags.
The same substitutions will be used to make coverage tests work on both Linux and Darwin without duplicating the code.

llvm-svn: 233802
2015-04-01 12:13:03 +00:00
Alexey Samsonov c4ed548b40 [Sanitizer] Be consistent about separating ==%PID== and logged data.
See https://code.google.com/p/address-sanitizer/issues/detail?id=385.

llvm-svn: 233720
2015-03-31 18:16:42 +00:00
Timur Iskhodzhanov 89608af26d [ASan/Win] UnmapOrDie should not fail on zero address / size
llvm-svn: 233707
2015-03-31 16:39:20 +00:00
Timur Iskhodzhanov 6c66ad0d75 [Sanitizer RT] Put the Symbolizer module name string ownership in order
Reviewed at http://reviews.llvm.org/D8666

llvm-svn: 233687
2015-03-31 12:50:05 +00:00