Commit Graph

5452 Commits

Author SHA1 Message Date
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
Nick Lewycky 816e0eabb7 Add another sanity check for swapcontext, which is currently unsupported. Patch by Alexey Samsonov!
llvm-svn: 233413
2015-03-27 20:40:23 +00:00
Viktor Kutuzov eff2d98ecc [Tsan] Do not sanitize memset() and other functions during initialization
Differential Revision: http://reviews.llvm.org/D8544

llvm-svn: 233378
2015-03-27 14:12:28 +00:00
Dmitry Vyukov 2034ce665a tsan: don't write to meta shadow unnecessarily
If user does malloc(1<<30), the write to meta shadow
can cause excessive memory consumption.

llvm-svn: 233373
2015-03-27 12:22:44 +00:00
Alexey Samsonov 0781e98cc7 [UBSan] Explicitly list all supported OS/arch pairs supported by UBSan.
llvm-svn: 233295
2015-03-26 17:26:04 +00:00
Timur Iskhodzhanov fd3241528d [Sanitizer] Plug a leak in POSIXSymbolizer::FindModuleForAddress
It was happening when we looked up a PC for a module that was dlopen'ed/dlclose'd
after the last time we fetched the list of modules

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

llvm-svn: 233257
2015-03-26 07:14:29 +00:00
Alexey Samsonov 1c1407395f [LSan] Don't explicitly exclude LSan from Windows build - it should just produce dummy object files. NFC.
llvm-svn: 233231
2015-03-25 23:26:49 +00:00
Kuba Brecka b47f4ef508 On OS X, explicitly use libc++
For OS X builds, both Make and CMake, let's be very explicit about using
libc++ and libc++abi with:

1) -stdlib=libc++ in CFLAGS and LDFLAGS for all platforms
2) -lc++ in LDFLAGS for all platforms
3) switch from -undefined dynamic_lookup to -lc++abi for UBSan in
   Makefile-based builds

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

llvm-svn: 233215
2015-03-25 21:07:20 +00:00
Timur Iskhodzhanov 3e8d392e9a [Sanitizers coverage] Minor cleanup: reduce scope and visibility of one method and one variable
llvm-svn: 233212
2015-03-25 20:19:51 +00:00
Bill Seurer 92760a3551 [PowerPC]Fix sancov.py to once again support big endian
Some recent changes to sancov.py broke ASAN for big endian.  This fixes it.

http://reviews.llvm.org/D8594

llvm-svn: 233189
2015-03-25 14:56:02 +00:00
Alexander Potapenko 2dee295a89 [ASan] Suppress the deprecation warning from atos that breaks AtosSymbolizer on OSX 10.9
On OS X 10.9 /usr/bin/atos prints the following warning upon invocation:

 --
Warning: /usr/bin/atos is moving and will be removed from a future OS X release.
It is now available in the Xcode developer tools to be invoked via: `xcrun atos`
To silence this warning, pass the '-d' command-line flag to this tool.
 --

AtosSymbolizer treats the warning as the symbolization result for the first PC passed to the symbolizer. As a result, for each of the following PCs the file:line info for the previous PC is printed, e.g.:

==97926==ERROR: AddressSanitizer: attempting double-free on 0x60200000dfb0 in thread T0:
==97926==Using atos at user-specified path: /usr/bin/atos
==97926==Using dladdr symbolizer.
   #0 0x1007407e0 in  --  (+0x427e0)
   #1 0x1006f6f25 in wrap_free asan_malloc_mac.cc:114
   #2 0x7fff916e05fc in main atos-symbolizer.cc:17
   #3 0x0  (<unknown module>)

Unfortunately atos doesn't accept the -d switch on OSX versions other than 10.9, thus we have to check for the OSX version.

llvm-svn: 233180
2015-03-25 11:01:33 +00:00
Alexey Samsonov ee449b68d0 Revert "Revert "[UBSan] Use shared library for UBSan on OS X" and its followup"
Fix the build/tests by providing -lc++abi for UBSan runtime only.

llvm-svn: 233122
2015-03-24 21:57:07 +00:00
Justin Bogner cc7e7cabd5 Revert "[UBSan] Use shared library for UBSan on OS X" and its followup
This change caused test failures on darwin, and the followup which was
meant to fix those caused compiler-rt to start failing to link.
Reverting to get the build working again.

This reverts r233071 and r233036.

llvm-svn: 233097
2015-03-24 17:43:31 +00:00
Alexander Potapenko f7d32ccc00 [ASan] Do not link ASan OSX runtime with -lc++abi (which was added in r233036)
This should fix the OSX Jenkins build at http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/

llvm-svn: 233071
2015-03-24 13:10:55 +00:00
Alexey Samsonov 6279a07eaa [TSan] Disable -Wno-maybe-uninitialized in yet another place.
llvm-svn: 233044
2015-03-24 00:38:43 +00:00
Alexey Samsonov 58e4835779 [TSan] Fixup for r233038: restrict the -Wno-maybe-uninitialized flag to GCC only.
llvm-svn: 233042
2015-03-23 23:44:38 +00:00
Alexey Samsonov 705c449af5 [ASan] Remove XFAIL from now passing test.
llvm-svn: 233040
2015-03-23 23:37:39 +00:00
Alexey Samsonov 543e966142 [TSan] Disable noisy GCC warning.
llvm-svn: 233038
2015-03-23 23:29:39 +00:00
Kostya Serebryany cd019f3655 [sanitizer] instead of comparing pointers to module_names while initializing coverage do a proper strcmp and strdup. NFC
llvm-svn: 233037
2015-03-23 23:19:13 +00:00
Alexey Samsonov c4eb977b0f [UBSan] Use shared library for UBSan on OS X (compiler-rt part).
Summary:
Switch to shared library for UBSan. Add support for building
UBSan on OSX and iossim by cargo-culting ASan build rules.

Test Plan: regression test suite

Reviewers: zaks.anna, kubabrecka

Subscribers: llvm-commits

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

llvm-svn: 233036
2015-03-23 23:14:16 +00:00
Alexey Samsonov 6a7ee6f460 [UBSan] Introduce "ubsan_standalone" library (compiler-rt part).
Get rid of "libclang_rt.san" library that used to contain
sanitizer_common pieces required by UBSan if it's used in a standalone
mode. Instead, build two variants of UBSan runtime: "ubsan" and
"ubsan_standalone" (same for "ubsan_cxx" and "ubsan_standalone_cxx").

Later "ubsan" and "ubsan_cxx" libraries will go away, as they will
embedded it into corresponding ASan runtimes.

llvm-svn: 233011
2015-03-23 20:05:53 +00:00
Viktor Kutuzov 60f0aa8a42 [Sanitizers] Fix internal_ftruncate() to work on FreeBSD
Differential Revision: http://reviews.llvm.org/D8551

llvm-svn: 233003
2015-03-23 19:44:35 +00:00
Viktor Kutuzov 838ea617d6 [Tsan] Fix the mmap_large.cc test to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D8545

llvm-svn: 233001
2015-03-23 19:40:59 +00:00
Alexander Potapenko f0581dda03 [sanitizer] Fix file access modes in SanitizerCommon.InternalMmapWithOffset and SanitizerCommon.FileOps
llvm-svn: 232972
2015-03-23 17:55:19 +00:00