Commit Graph

3900 Commits

Author SHA1 Message Date
Alexey Samsonov 425314a65f [TSan] Fix a rare deadlock on multithreaded fork.
If a multi-threaded program calls fork(), TSan ignores all memory accesses
in the child to prevent deadlocks in TSan runtime. This is OK, as child is
probably going to call exec() as soon as possible. However, a rare deadlocks
could be caused by ThreadIgnoreBegin() function itself.

ThreadIgnoreBegin() remembers the current stack trace and puts it into the
StackDepot to report a warning later if a thread exited with ignores enabled.
Using StackDepotPut in a child process is dangerous: it locks a mutex on
a slow path, which could be already locked in a parent process.

The fix is simple: just don't put current stack traces to StackDepot in
ThreadIgnoreBegin() and ThreadIgnoreSyncBegin() functions if we're
running after a multithreaded fork. We will not report any
"thread exited with ignores enabled" errors in this case anyway.

Submitting this without a testcase, as I believe the standalone reproducer
is pretty hard to construct.

llvm-svn: 205534
2014-04-03 12:51:26 +00:00
Alexey Samsonov b4525218d4 [TSan] Fix a typo ThreadIgnoreSyncEnd. Found by inspection
llvm-svn: 205531
2014-04-03 12:28:16 +00:00
Alexey Samsonov 11ff0a26a4 [ASan] Fix incompatible runtimes check: don't iterate /proc/self/maps on every call to __asan_init
llvm-svn: 205418
2014-04-02 13:09:22 +00:00
Evgeniy Stepanov 6cc687541f [msan] Add missing test for r205413.
llvm-svn: 205417
2014-04-02 12:38:13 +00:00
Evgeniy Stepanov 2dcb5c0a2c [msan] Kill __msan_print_param_shadow.
It does not do what it's name says, and what it actually does is hard to
describe, and is not useful at all.

llvm-svn: 205415
2014-04-02 11:55:24 +00:00
Evgeniy Stepanov 80cb930c09 [msan] Add __msan_check_mem_is_initialized.
An assert()-like function that checks that a memory range is fully initialized.

llvm-svn: 205413
2014-04-02 11:50:42 +00:00
Evgeniy Stepanov a55fcd35e9 [msan] Precise origin handling in __unaligned_(load|store)*.
llvm-svn: 205412
2014-04-02 11:06:35 +00:00
Alexey Samsonov 2c66a22e56 [ASan] One more attempt to fix Android build
llvm-svn: 205411
2014-04-02 09:36:36 +00:00
Evgeniy Stepanov 8dbf3faa16 [msan] clang-format several unit tests
llvm-svn: 205410
2014-04-02 09:17:55 +00:00
Greg Fitzgerald c744492f7c Allow the user to override the compiler used for testing
Change-Id: I76d4708a26f17185efb746f4b836aa32f3f8a44f
llvm-svn: 205362
2014-04-01 21:54:56 +00:00
Joerg Sonnenberger a350ba4883 Move __addsf3 and __adddf3 into the corresponding blocks that define
fp_t.

llvm-svn: 205344
2014-04-01 18:39:58 +00:00
Duncan P. N. Exon Smith dd690a2ca4 InstrProfile: Use SANITIZER_COMMON_LIT_TEST_DEPS
Take advantage of the SANITIZER_COMMON_LIT_TEST_DEPS variable.

<rdar://problem/16458307>

llvm-svn: 205321
2014-04-01 16:05:15 +00:00
Duncan P. N. Exon Smith 48e24c7355 InstrProf: Turn on test for Linux
Enabling test/profile on Linux to get feedback from the buildbots.  I'm
hoping this just works...

<rdar://problem/16458307>

llvm-svn: 205319
2014-04-01 15:56:05 +00:00
Duncan P. N. Exon Smith a5f806e599 InstrProf: Remove LTO dependency from test
The -flto flag relies on linker features that are not available on all
platforms.

<rdar://problem/16458307>

llvm-svn: 205318
2014-04-01 15:29:27 +00:00
Alexander Potapenko f3e92a9e71 [tsan] Remove an accidentally committed debug print.
llvm-svn: 205316
2014-04-01 15:07:09 +00:00
Joerg Sonnenberger 6530149704 Add support for IEEE754 quad precision comparison functions.
From GuanHong Liu.

Differential Revision: http://llvm-reviews.chandlerc.com/D2797

llvm-svn: 205312
2014-04-01 13:42:56 +00:00
Alexey Samsonov 107e4abfd0 [ASan] Fix Android build
llvm-svn: 205311
2014-04-01 13:42:16 +00:00
Alexey Samsonov 56b6ee9833 [ASan] Optional support for dynamic ASan runtime on Linux.
Based on http://llvm-reviews.chandlerc.com/D3042 by Yuri Gribov!

llvm-svn: 205308
2014-04-01 13:16:30 +00:00
Alexey Samsonov 28f30b4176 [TSan] Make this test more portable
llvm-svn: 205300
2014-04-01 11:51:50 +00:00
Kostya Serebryany 432c46bf70 [sanitizer] one more stress test for the deadlock detector; this one stresses the slow path with a global lock
llvm-svn: 205299
2014-04-01 11:35:55 +00:00
Viktor Kutuzov 7fedc179d2 Add FreeBSD support to sanitizers' procmaps facilities
llvm-svn: 205291
2014-04-01 10:34:21 +00:00
Viktor Kutuzov 3ece65b894 Fix definition of the __sanitizer_passwd structure on FreeBSD
llvm-svn: 205290
2014-04-01 10:29:42 +00:00
Duncan P. N. Exon Smith da91cbdfa8 InstrProf: lit.cfg magic for running tests from source
Implement magic in compiler-rt to enable llvm-lit to be invoked on the
source tree in lib/profile.  This relies on a paired commit in the llvm
tree that exposes a new built-in parameter.

<rdar://problem/16458307>

llvm-svn: 205263
2014-03-31 23:14:28 +00:00
Duncan P. N. Exon Smith ae2f0bbcf1 InstrProf: Add simple compiler-rt test
Add the test infrastructure for testing lib/profile and a single test.
This initial commit only enables the tests on Darwin, but they'll be
enabled on Linux soon after.

<rdar://problem/16458307>

llvm-svn: 205256
2014-03-31 22:45:37 +00:00
Evgeniy Stepanov 3c95744de8 [msan] Remove an extra top frame from track-origins=2 reports.
llvm-svn: 205192
2014-03-31 14:18:55 +00:00
Evgeniy Stepanov ff127bff89 [sanitizer] Test that we can compile C++ code on the target platform.
llvm-svn: 205184
2014-03-31 13:50:13 +00:00
Alexey Samsonov 78a8435fd6 [CMake] Rename add_compiler_rt_static_runtime to add_compiler_rt_runtime.
Soon there will be an option to build compiler-rt parts as shared libraries
on Linux. Extracted from http://llvm-reviews.chandlerc.com/D3042
by Yuri Gribov.

llvm-svn: 205183
2014-03-31 13:45:36 +00:00
Alexander Potapenko 0315b52444 [TSan] Follow-up for r205175: typo fix in the test.
llvm-svn: 205176
2014-03-31 10:51:13 +00:00
Alexander Potapenko 0426176940 [TSan] Replace several Printf() calls with Report() to ease debugging.
llvm-svn: 205175
2014-03-31 10:46:07 +00:00
Kostya Serebryany 683d55f50e [sanitizer] speed up the bitvector-based deadlock detector by ~15% (iterate over the currently held locks using the array, not the bitvector. Bitvector is not the best data structure to iterate over)
llvm-svn: 205168
2014-03-31 07:23:50 +00:00
Evgeniy Stepanov 6f34082590 [sanitizer] Fix Mac build.
llvm-svn: 205006
2014-03-28 14:01:40 +00:00
Evgeniy Stepanov 86a4d2c32b [sanitizer] Intercept fgetpwent / fgetgrent.
These interceptors require deep unpoisoning of return values.
While at it, we do the same for all other pw/gr interceptors to
reduce dependency on libc implementation details.

llvm-svn: 205004
2014-03-28 13:03:55 +00:00
Evgeniy Stepanov 163ee4efb5 [sanitizer] Intercept setpwent/endpwent.
It's hard to write a reliable test for this code because they
work with unpredictable memory locations. But this change should
fix current failures in getpwent() tests on the sanitizer bots.

llvm-svn: 205002
2014-03-28 11:46:35 +00:00
Evgeniy Stepanov 92bee36b3e [sanitizer] Intercept rand_r.
llvm-svn: 205001
2014-03-28 11:21:45 +00:00
Evgeniy Stepanov 74e77756ef [sanitizer] Intercept getpwent/getgrent.
llvm-svn: 205000
2014-03-28 10:56:07 +00:00
Joerg Sonnenberger ea1f8fb775 Add instrastructure for IEEE quad precision.
Based on patch from GuanHong Liu.

Differential Revision: http://llvm-reviews.chandlerc.com/D2796

llvm-svn: 204999
2014-03-28 10:29:31 +00:00
Evgeniy Stepanov 2e972f63b5 [sanitizer] Intercept mktime.
llvm-svn: 204994
2014-03-28 09:02:57 +00:00
Evgeniy Stepanov 7b44e1ad42 [sanitizer] Intercept ftime.
llvm-svn: 204991
2014-03-28 08:33:32 +00:00
Evgeniy Stepanov a6eb1bb59e [sanitizer] Intercept __bzero on Mac.
This should make memset_test pass on Mac.

llvm-svn: 204929
2014-03-27 14:20:34 +00:00
Evgeniy Stepanov 1189734413 [sanitizer] Fix Android build.
llvm-svn: 204927
2014-03-27 14:06:15 +00:00
Evgeniy Stepanov 89602651e8 [msan] Implement __msan_set_death_callback.
llvm-svn: 204926
2014-03-27 14:04:58 +00:00
Timur Iskhodzhanov e6303d1224 Add support for _expand[_dbg] so we don't crash when _aligned_* allocation functions are used
llvm-svn: 204925
2014-03-27 14:01:11 +00:00
Evgeniy Stepanov 9dcd5a353a [msan] Intercept several malloc-related functions.
llvm-svn: 204923
2014-03-27 13:29:29 +00:00
Kostya Serebryany d093b5ac43 [asan] add a test case for r204897.
llvm-svn: 204903
2014-03-27 08:51:32 +00:00
Kostya Serebryany 88d0eac412 [asan] Do not sanitize kernel area on 32-bit targets, patch by Yuri Gribov
llvm-svn: 204897
2014-03-27 07:36:26 +00:00
Greg Fitzgerald ffa4b7993f Revert r204877 "Allow the user to override the compiler used for testing"
Unbreak the sanitizer-x86_64-linux bot.

Change-Id: Ie03f1b93fae45c54b142003731ff4f5d4f6b62f8
llvm-svn: 204886
2014-03-27 01:11:12 +00:00
Greg Fitzgerald 6ff4f89af3 Allow the user to override the compiler used for testing
Change-Id: Ida62c2d85f541260f505c3dbd5d71a4b2a6004f4
llvm-svn: 204877
2014-03-26 23:51:44 +00:00
Peter Collingbourne 5d167dae7d Add function to get the number of DFSan labels allocated.
Expose the number of DFSan labels allocated by adding function dfsan_get_label_count().

Patch by Sam Kerner!

Differential Revision: http://llvm-reviews.chandlerc.com/D3109

llvm-svn: 204854
2014-03-26 21:09:53 +00:00
Dmitry Vyukov e31dd3473e tsan: deflake test
llvm-svn: 204824
2014-03-26 15:51:11 +00:00
Rafael Espindola 5e46070516 Avoid aliases to weak aliases in interceptors.
The interceptors had code that after macro expansion ended up looking like

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("memalign")));

That is,
* __interceptor_memalign is a function
* memalign is a weak alias to __interceptor_memalign
* __interceptor___libc_memalign is an alias to memalign

Both gcc and clang produce assembly that look like

__interceptor_memalign:
...
        .weak   memalign
memalign = __interceptor_memalign
        .globl  __interceptor___libc_memalign
__interceptor___libc_memalign = memalign

What it means in the end is that we have 3 symbols pointing to the
same position in the file, one of which is weak:

     8: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor_memalign
     9: 0000000000000000     1 FUNC    WEAK   DEFAULT    1 memalign
    10: 0000000000000000     1 FUNC    GLOBAL DEFAULT    1
__interceptor___libc_memalign

In particular, note that __interceptor___libc_memalign will always
point to __interceptor_memalign, even if we do link in a strong symbol
for memalign. In fact, the above code produces exactly the same binary
as

extern "C" void memalign()
    __attribute__((weak, alias("__interceptor_memalign")));
extern "C" void __interceptor_memalign() {}
extern "C" void __interceptor___libc_memalign()
    __attribute__((alias("__interceptor_memalign")));

If nothing else, this patch makes it more obvious what is going on.

llvm-svn: 204823
2014-03-26 15:48:59 +00:00