Commit Graph

11557 Commits

Author SHA1 Message Date
Vitaly Buka 0d973a5311 Revert "[NFC][Sanitizer] Cleanup ASan's GetStackTrace implementation"
I've missed that UnwindSlow was removed from ScopedUnwinding.

This reverts commit 4ce918e394.

llvm-svn: 355369
2019-03-05 02:35:49 +00:00
Manman Ren ff4bb36d7c Revert compiler-rt diffs for order file instrumentation to get bot green!
This caused issues on Linux/Windows and other platforms.

r355343 355350 355350

llvm-svn: 355363
2019-03-05 01:21:40 +00:00
Manman Ren 31b31e5111 Attemp to fix windows profile-rt build breakage.
Followup to D57530.

llvm-svn: 355357
2019-03-05 00:52:00 +00:00
Julian Lettner 4ce918e394 [NFC][Sanitizer] Cleanup ASan's GetStackTrace implementation
Cleanup ASan's  __sanitizer::BufferedStackTrace::UnwindImpl (formerly
GetStackTrace) implementation. Start with ASan because it is the most
complex implementation.

GetStackTrace implementations seem to have started out as exact copies
of the original implementation in ASan, but have diverged in subtle
ways. My goal is to parameterize this algorithm (via templating or
callbacks) so we can share the implementation and get rid of the
inversed dependency (sanitizer_common depends on concrete
implementations in asan, ubsan, etc.). This should also help us to avoid
those pesky linker errors caused by undefined, duplicate, and weak
symbols on Windows.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D58861

llvm-svn: 355355
2019-03-05 00:41:15 +00:00
Manman Ren 03d5348132 Attemp to fix build brokage due to D57530.
By adding implementations for __llvm_profile_begin_orderfile for non-Darwin platforms.

llvm-svn: 355350
2019-03-04 23:41:57 +00:00
Evgeniy Stepanov 53d7c5cd44 [msan] Instrument x86 BMI intrinsics.
Summary:
They simply shuffle bits. MSan needs to do the same with shadow bits,
after making sure that the shuffle mask is fully initialized.

Reviewers: pcc, vitalybuka

Subscribers: hiraditya, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58858

llvm-svn: 355348
2019-03-04 22:58:20 +00:00
Evgeniy Stepanov 8cee2e8539 [sanitizer] Intercept bzero.
Summary:
Intercept bzero and enable existing __bzero interceptor in Linux.
bzero is deprecated but still used occasionally.

Reviewers: vitalybuka

Subscribers: srhines, kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58850

llvm-svn: 355347
2019-03-04 22:58:11 +00:00
Manman Ren 4737abc71c Order File Instrumentation: dump the data in compiler-rt
The profile data will be dumped in a file default_xxx.profraw.order.

Differential Revision: https://reviews.llvm.org/D57530

llvm-svn: 355343
2019-03-04 22:28:38 +00:00
Shoaib Meenai 5be71faf4b [build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].

I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html

Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille

Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits

Tags: #clang, #sanitizers, #lldb, #openmp, #llvm

Differential Revision: https://reviews.llvm.org/D58791

llvm-svn: 355340
2019-03-04 21:19:53 +00:00
Evgeniy Stepanov 02a913367a Revert "[sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors."
Breaks TSan on Mac, which does
  return REAL(func)(...
in COMMON_INTERCEPTOR_ENTER, which is not OK when REAL(func) has return
type of void.

llvm-svn: 355256
2019-03-02 01:33:52 +00:00
Vlad Tsyrklevich a8af6ca065 Revert "Revert "[sanitizers] Don't use Windows Trace Logging on MinGW""
This reverts my orignal revert in r355250, I misread the buildbot logs.
Volodymyr's commit in r355244 fixed the build.

llvm-svn: 355251
2019-03-02 00:46:54 +00:00
Vlad Tsyrklevich a75077bc73 Revert "[sanitizers] Don't use Windows Trace Logging on MinGW"
This reverts commits r355236 and r355244, they broke the Linux sanitizer
build.

llvm-svn: 355250
2019-03-02 00:39:36 +00:00
Volodymyr Sapsai 738f697a19 [sanitizers] Fix build on macOS with LogFullErrorReport redefinition error.
macOS has implementation of LogFullErrorReport and

    INLINE void LogFullErrorReport(const char *buffer) {}

was causing

> compiler-rt/lib/sanitizer_common/sanitizer_mac.cc:658:6: error: redefinition of 'LogFullErrorReport'

Fixup for r355236.

rdar://problem/48526020

llvm-svn: 355244
2019-03-02 00:05:04 +00:00
Julian Lettner a30b116e6f [NFC][Sanitizer] Replace last uses of old Unwind API
Replace remaining uses of old Unwind API in unit tests.

Allows us to remove the old API and WillUseFastUnwind can be made
private.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D58754

llvm-svn: 355242
2019-03-01 23:50:47 +00:00
Julian Lettner f6ca8cba5c [NFC][Sanitizer] Test unexpectedly passes on ppc64be bot
llvm-svn: 355239
2019-03-01 22:35:40 +00:00
Martin Storsjo ad596c8d8c [CMake] Don't use llvm_replace_compiler_option
Building compiler-rt standalone outside of the main llvm
tree is supported, and in this case, the llvm cmake modules
are unavailable. (And even if they are available, it requires
including LLVMProcessSources.cmake, which currently isn't
included.)

This fixes building compiler-rt standalone with MSVC/clang-cl.

Differential Revision: https://reviews.llvm.org/D58767

llvm-svn: 355237
2019-03-01 22:30:17 +00:00
Martin Storsjo 05394af3ff [sanitizers] Don't use Windows Trace Logging on MinGW
mingw-w64 currently is lacking the headers for this feature.

Make the include lowercase at the same time. We consistently
use lowercase for windows header includes, as windows itself is
case insensitive, the SDK headers (in general, not necessarily
considering this particular header) aren't consistent among themselves
about what the proper canonical capitalization for headers are,
and MinGW uses all lowercase names for the headers (as it is often
used on case sensitive filesystems).

In case mingw-w64 later gets this header, we can revert this
(but keep the include lowercased).

Differential Revision: https://reviews.llvm.org/D58765

llvm-svn: 355236
2019-03-01 22:30:14 +00:00
Julian Lettner 628472dde2 [NFC][Sanitizer][Windows] Fix refactoring oversight
Fix mistake in previous commit: 9fe3b4906f

llvm-svn: 355234
2019-03-01 22:26:45 +00:00
Julian Lettner 9fe3b4906f [NFC][Sanitizer] Make GetStackTrace a private method of BufferedStackTrace
GetStackTrace is a implementation detail of BufferedStackTrace. Make it
a private method.

Reviewed By: vitalybuka

Differential-Revision: https://reviews.llvm.org/D58753
llvm-svn: 355232
2019-03-01 22:10:49 +00:00
Evgeniy Stepanov ddc4b7c1d6 [sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors.
llvm-svn: 355231
2019-03-01 21:59:18 +00:00
Evgeniy Stepanov 72e83488f3 Revert "[sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors."
This change is incomplete.

llvm-svn: 355230
2019-03-01 21:49:40 +00:00
Evgeniy Stepanov 3bbac856f9 [sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors.
They return void, unlike memset/memcpy/memmove.

llvm-svn: 355225
2019-03-01 20:54:16 +00:00
Evgeniy Stepanov c7b322a3d9 [msan] Add an interceptor for ttyname().
llvm-svn: 355214
2019-03-01 18:22:44 +00:00
Clement Courbet dd885eaf5f Reland "[compiler-rt] Intercept the bcmp() function."
Fix test issues on darwin: The REQUIRES for the test should be the same as the
guard for whether we intercept bcmp.

llvm-svn: 355204
2019-03-01 16:42:08 +00:00
Kostya Kortchinsky 6b79f3b1e2 [scudo][standalone] Fix tests makefile
Summary:
A missing `STATIC` entailed some annoying to debug failures wrt 32 vs 64
binaries. Additionally I noticed I was using the wrong variable (the Scudo
one as opposed to the Scudo Standalone one).

See https://reviews.llvm.org/D58184#1412417 and below for discussion.

Reviewers: vitalybuka, eugenis, brzycki

Reviewed By: vitalybuka, brzycki

Subscribers: mgorny, delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58794

llvm-svn: 355203
2019-03-01 15:46:23 +00:00
Martin Storsjo 90641b5581 [sanitizers] Explicitly use GetModuleFileNameW with wchar_t
Alternatively we could define the string as TCHAR.

Differential Revision: https://reviews.llvm.org/D58766

llvm-svn: 355180
2019-03-01 08:08:11 +00:00
Julian Lettner 13c4bc5671 [NFC][Sanitizer] Add new BufferedStackTrace::Unwind API
Retrying without replacing call sites in sanitizer_common (which might
not have a symbol definition).

Add new Unwind API. This is the final envisioned API with the correct
abstraction level. It hides/slow fast unwinder selection from the caller
and doesn't take any arguments that would leak that abstraction (i.e.,
arguments like stack_top/stack_bottom).

GetStackTrace will become an implementation detail (private method) of
the BufferedStackTrace class.

Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D58741

> llvm-svn: 355168

llvm-svn: 355172
2019-03-01 04:03:38 +00:00
Julian Lettner e6ec6bd8e0 Revert "[NFC][Sanitizer] Add new BufferedStackTrace::Unwind API"
This reverts commit 6112f37e75.

llvm-svn: 355171
2019-03-01 03:35:05 +00:00
Julian Lettner 6112f37e75 [NFC][Sanitizer] Add new BufferedStackTrace::Unwind API
Add new Unwind API. This is the final envisioned API with the correct
abstraction level. It hides/slow fast unwinder selection from the caller
and doesn't take any arguments that would leak that abstraction (i.e.,
arguments like stack_top/stack_bottom).

GetStackTrace will become an implementation detail (private method) of
the BufferedStackTrace class.

Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D58741

llvm-svn: 355168
2019-03-01 03:08:34 +00:00
Evgeniy Stepanov dc3870d64d [hwasan] Disable vfork code when building w/o interceptors.
Don't define vfork when OMPILER_RT_HWASAN_WITH_INTERCEPTORS=OFF.

llvm-svn: 355165
2019-03-01 02:06:58 +00:00
Evgeniy Stepanov 9ca1755f76 [sanitizer] Build everything whereever possible with -z text.
Reviewers: pcc, phosek

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58755

llvm-svn: 355164
2019-03-01 01:45:01 +00:00
Nico Weber 77d972b94c cfi: Rename source file from cc to cpp
See discussion on https://reviews.llvm.org/D58620 for the review.

llvm-svn: 355144
2019-02-28 22:03:41 +00:00
Dan Liew d14f1b26fb [CMake][LibFuzzer] Match symbol visibility setting between LibFuzzer object files and unit tests.
Summary:
This fixes inconsistent symbol visibility. This shows up as a linker
warning if r336238 (43f633564e338a6dde83d49a48e5bfcbfdce292c) is
reverted.

```
ld: warning: direct access in function 'fuzzer::CleanseCrashInput(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, fuzzer::FuzzingOptions const&)' from file '/Volumes/data/dev/llvm/upstream/master/builds/projects/compiler-rt/lib/fuzzer/tests/libRTFuzzerTest.x86_64.a(FuzzerDriver.cpp.o)' to global weak symbol 'fuzzer::Command::ignoreRemainingArgs()::kIgnoreRemaining' from file 'FuzzerTestObjects.FuzzerUnittest.cpp.x86_64.o' means the weak symbol cannot be overridden
 at runtime. This was likely caused by different translation units being compiled with different visibility settings.
```

r336238 just hid the issue rather than fixing the real issue. On macOS
and other platforms we usually compile with `-fvisibility=hidden` but
the unit tests were compiled without this flag.

Reviewers: george.karpenkov, kubamracek, kcc, yln

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58055

llvm-svn: 355143
2019-02-28 21:57:58 +00:00
Evgeniy Stepanov ecb2c1fd5b [hwasan] Fix vfork handling with large stack limit.
Remove the maximum stack cleanup size check. With ulimit -s unlimited
main thread stack can be very large, but we don't really have a choice
other than cleaning all of it. It should be reasonably fast - hwasan
cleans large shadow ranges with a single madvise call.

This change fixes check-hwasan after ulimit -s unlimited.

llvm-svn: 355137
2019-02-28 20:43:24 +00:00
H.J. Lu fadb22f4e2 Revert "Revert "[sanitizers] Restore internal_readlink for x32""
This reverts revision 354601 and disables ReadBinaryNameCached check on
Windows since Windows has no working ReadBinaryName.

Differential Revision: https://reviews.llvm.org/D58788

llvm-svn: 355129
2019-02-28 19:34:01 +00:00
Julian Lettner b79f1f2e2a [Sanitizer] lit test config: Respect existing parallelism_group
llvm-svn: 355128
2019-02-28 19:26:53 +00:00
Evgeniy Stepanov 37ce064082 [sanitizer] Fix vfork interceptor on i386 w/ dynamic runtime.
PLT calls on i386 expect GOT base address in %ebx.
This call does not need to go through PLT strictly speaking, but I'd
rather avoid future surprises and implement the most general case.

llvm-svn: 355125
2019-02-28 19:21:25 +00:00
Rong Xu 23452e1c85 [PGO] Update InstrProfData.inc to sync with llvm
llvm-svn: 355119
2019-02-28 19:06:02 +00:00
Julian Lettner ce65261fae [NFC][Sanitizer] Weak linkage is not available on Windows
The concept of weak linkage is not available on Windows. The available
workarounds in LLVM/sanitizer runtimes have their own problems. Define a
separte symbol ubsan_GetStackTrace to work around the issue now. At lest
this way it is painfully obvious that we still have to do more cleanup.

Follow-up to revision: https://reviews.llvm.org/D58651

llvm-svn: 355113
2019-02-28 18:42:14 +00:00
Evgeniy Stepanov d4b4e17d2c [sanitizer] Got rid of text relocations in i386 vfork interceptor.
llvm-svn: 355064
2019-02-28 01:54:55 +00:00
Douglas Yung 83663fd989 Add username to TODO comment in sanitizer to satisfy sanitizer lint check. NFC
llvm-svn: 355062
2019-02-28 01:20:38 +00:00
Julian Lettner 22efccf9ab [NFC][TSan] Don't define GetStackTrace when compiling for Go
rdar://48455255

llvm-svn: 355053
2019-02-28 00:43:43 +00:00
Julian Lettner a7171b2e47 [NFC][Sanitizer] Use correct WEAK annotation to make Windows work
The previous fix didn't work for Windows:
52b751088b

llvm-svn: 355052
2019-02-28 00:43:40 +00:00
Julian Lettner 52b751088b [Sanitizer] Attempt to fix linker error on ARM variants
Previous commit:
a0884da62a

llvm-svn: 355046
2019-02-27 23:47:00 +00:00
Matthew G McGovern 8edffdb4f0 [compiler-rt] Windows Trace Logging for error reports.
Adds option for collecting sanitixer dumps via trace logging.
    - Set log_to_syslog=1 to enable this output.
    - Consult https://aka.ms/windowstracelogging for details on use.

llvm-svn: 355045
2019-02-27 23:43:50 +00:00
Reid Kleckner 4fb3502bc9 [InstrProf] Use separate comdat group for data and counters
Summary:
I hadn't realized that instrumentation runs before inlining, so we can't
use the function as the comdat group. Doing so can create relocations
against discarded sections when references to discarded __profc_
variables are inlined into functions outside the function's comdat
group.

In the future, perhaps we should consider standardizing the comdat group
names that ELF and COFF use. It will save object file size, since
__profv_$sym won't appear in the symbol table again.

Reviewers: xur, vsk

Subscribers: eraman, hiraditya, cfe-commits, #sanitizers, llvm-commits

Tags: #clang, #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58737

llvm-svn: 355044
2019-02-27 23:38:44 +00:00
Evgeniy Stepanov f6b0a14bff [sanitizer] Fix compilation errors in r355030.
Disable hwasan interceptor on non-linux, non-x86-or-arm platforms.
Add @plt to the asm call that clang intergrated-as infers but gcc does
not.

llvm-svn: 355041
2019-02-27 22:23:51 +00:00
Julian Lettner a0884da62a [NFC][Sanitizer] Pull up GetStackTrace into sanitizer_common
We already independently declare GetStackTrace in all (except TSan)
sanitizer runtime headers. Lets move it to sanitizer_stacktrace.h to
have one canonical way to fill in a BufferedStackFrame. Also enables us
to use it in sanitizer_common itself.

This patch defines GetStackTrace for TSan and moves the function from
ubsan_diag.cc to ubsan_diag_standalone.cc to avoid duplicate symbols
for the UBSan-ASan runtime.

Other than that this patch just moves the code out of headers and into
the correct namespace.

Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D58651

llvm-svn: 355039
2019-02-27 22:16:02 +00:00
James Y Knight f33b1f49b7 Fixup compilation/test failures after r354960 and r355013.
llvm-svn: 355034
2019-02-27 21:47:35 +00:00
Evgeniy Stepanov f46a52b536 [hwasan, asan] Intercept vfork.
Summary:
Intercept vfork on arm, aarch64, i386 and x86_64.

Reviewers: pcc, vitalybuka

Subscribers: kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58533

llvm-svn: 355030
2019-02-27 21:11:50 +00:00
Evgeniy Stepanov c6bcc18533 [hwasan] Fix tests after .cc->.cpp renaming.
llvm-svn: 355028
2019-02-27 20:50:35 +00:00
Julian Lettner 46e1b16e36 [NFC][Sanitizer] Hard-code fast/slow unwinder at call site
Also assert that the caller always gets what it requested.

This purely mechanical change simplifies future refactorings and
eventual removal of BufferedStackTrace::Unwind.

Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D58557

llvm-svn: 355022
2019-02-27 20:01:04 +00:00
Jonathan Metzman 518514e81d [libFuzzer][Windows] Port fork mode to Windows
Summary:
Port libFuzzer's fork mode to Windows.
Implement Windows versions of MkDir, RmDir, and IterateDirRecursive to do this.
Don't print error messages under new normal uses of FileSize (on a non-existent file).
Implement portable way of piping output to /dev/null.
Fix test for Windows and comment fork-sigusr.test on why it won't be ported to Win.

Reviewers: zturner

Reviewed By: zturner

Subscribers: kcc, zturner, jdoerfert, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58513

llvm-svn: 355019
2019-02-27 19:27:16 +00:00
Julian Lettner 6eef7d0524 [Darwin][NFC] Refactor throttling of 64bit sanitizer tests on Darwin
Underlying condition for throttling is "has large mmap'd regions" (i.e.,
shadow memory) and not sanitizers in general (e.g., UBSan does not need
to be throttled).

Rename parallelism group `darwin-64bit-sanitizer` to `shadow-memory` and
apply it unconditionally to all tests which require it. We can then have
all the Darwin throttling logic in one place in the commen lit config.

Throttle sanitizer_common unit tests. Configuration was previously
missing from sanitizer_common/Unit/lit.site.cfg.

Reviewed by: kubamracek

Differential Revision: https://reviews.llvm.org/D58677

llvm-svn: 355018
2019-02-27 19:06:20 +00:00
Alexey Lapshin d89d638055 Attempt to fix buildbot after r354972 [#1]. NFCI.
llvm-svn: 355013
2019-02-27 18:36:46 +00:00
Kostya Kortchinsky b3a924afd6 [scudo][standalone] Add a standalone vector class
Summary:
This CL adds a standalone vector class that will be used by the scoped
strings when they land. We reimplement our own vector class because we
can't use the std library one.

It's mostly borrowed from the current sanitizer_common one, with LLVM
code style changes.

Additionnally a casing change in a function name that slipped through
the previous review (the function isn't used yet).

Reviewers: vitalybuka, eugenis, flowerhack, dmmoore415, mcgrathr, morehouse

Reviewed By: vitalybuka

Subscribers: mgorny, delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58689

llvm-svn: 354999
2019-02-27 16:30:05 +00:00
Nico Weber e3b6d11038 hwasan: Rename source files from cc to cpp
As discussed elsewhere: LLVM uses cpp as its C++ source extension; the
sanitizers should too. This updates files in hwasan.

Patch generated by

    for f in lib/hwasan/*.cc ; do svn mv $f ${f%.cc}.cpp; done

followed by

    for f in lib/hwasan/*.cpp ; do sed -i '' -e '1s/\.cc -/.cpp /' $f; done

CMakeLists.txt updated manually.

Differential Revision: https://reviews.llvm.org/D58620

llvm-svn: 354989
2019-02-27 15:44:03 +00:00
Julian Lettner c4eff2111a [NFC][Sanitizer] Add TODO comments
llvm-svn: 354947
2019-02-27 01:38:54 +00:00
Craig Topper 938d3f461b [X86] Add 'znver2' and 'cascadelake' support to __cpu_indicator_init.
For 'cascadelake' this is adding a 'avx512vnni' feature check to the 0x55 skylake-avx512 model check. These CPUs use the same model number and only differ in the stepping number. But the feature flag is simpler than collecting all the stepping numbers.

For 'znver2' this is just syncing with LLVM's Host.cpp.

llvm-svn: 354927
2019-02-26 21:51:05 +00:00
Vitaly Buka 9b6135bf2a [libFuzzer] fix missing close on opened file
Summary:
When running the standalone main on a large corpus, I eventually get a
EMFILE error ("Too many open files").

Patch by Paul Chaignon

Reviewers: kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: lebedev.ri, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58622

llvm-svn: 354918
2019-02-26 19:33:00 +00:00
Mitch Phillips c0ffe705c5 Fixed a minor merge error with this patch.
llvm-svn: 354908
2019-02-26 18:41:55 +00:00
Mitch Phillips 83899d1f39 [compiler-rt] Provide better llvm-lit failure when llvm-config fails.
Summary:
The current error message can cause confusion if llvm-config can't be
executed for reasons other than "not found". In my example, cross
compiling generated an llvm-config binary for aarch64 which couldn't be
executed natively. Instead of telling me that the error was with the
file architecture, it reports the file as not being present.

Reviewers: pcc

Subscribers: dberris, javed.absar, kristof.beyls, jdoerfert, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58647

llvm-svn: 354907
2019-02-26 18:41:54 +00:00
Vlad Tsyrklevich 443e00a51b Revert "[compiler-rt] Intercept the bcmp() function."
This reverts commits r354851, 354852, 354853 and r354888. They were
causing build failures on the android sanitizer bot.

llvm-svn: 354906
2019-02-26 18:28:15 +00:00
Jonathan Metzman 7821f892bf [libFuzzer] Remove extra semicolons
Summary:
Remove extra semicolons so that libFuzzer can compile with
-Werror -Wextra-semi

Reviewers: Dor1s, morehouse, thakis

Reviewed By: Dor1s, morehouse

Subscribers: jdoerfert, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58674

llvm-svn: 354902
2019-02-26 17:46:13 +00:00
Kostya Kortchinsky 41aba567d9 [scudo][standalone] Introduce platform specific code & mutexes
Summary:
This CL adds the platform specific code for Fuchsia, Linux & Android,
as well as some tests related to those (more tests to come later).
While some of it is pretty much a straight port of the existing scudo &
sanitizer_common code, the memory mapping functions have been reworked
a bit to fit the limited usage scenario that Scudo has for them.

For Fuchsia, I can now track the Vmar/Vmo pair for memory mappings if
there is an intent to grow or decommit some mapping (that will be
useful for the Primary).

Reviewers: eugenis, vitalybuka, mcgrathr, phosek, flowerhack, morehouse, dmmoore415

Reviewed By: vitalybuka, morehouse

Subscribers: kcc, dvyukov, srhines, mgorny, delcypher, jfb, jdoerfert, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58184

llvm-svn: 354895
2019-02-26 16:47:25 +00:00
Clement Courbet ea7bd2f016 [compiler-rt] Disable failing test on darwin during investigation.
/Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/projects/compiler-rt/test/asan/TestCases/Posix/bcmp_test.cc:14:12: error: CHECK: expected string not found in input
 // CHECK: {{#1.*bcmp}}
           ^
<stdin>:2:57: note: scanning from here
==34677==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffee93777c4 at pc 0x0001068a7285 bp 0x7ffee9377770 sp 0x7ffee9376ef8
                                                        ^
<stdin>:6:20: note: possible intended match here
 #2 0x106888e77 in main bcmp_test.cc:12
                   ^

llvm-svn: 354888
2019-02-26 15:25:04 +00:00
Pavel Labath 89ae290b58 [Sanitizer] Add interceptor for pthread_sigmask
Summary:
pthread_sigmask is just like sigprocmask, except that its behavior in
multithreaded programs is explicitly specified. Sanitizers were lacking
a common interceptor for pthread_sigmask (although some specific
sanitizers defined custom version), which lead to false positives
(at least in msan) when using this function.

The interceptor implementation, and its test are based on the equivalent
code for sigprocmask.

Reviewers: eugenis, vitalybuka

Subscribers: kubamracek, delcypher, jfb, jdoerfert, llvm-commits, #sanitizers

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58382

llvm-svn: 354874
2019-02-26 13:38:23 +00:00
Clement Courbet e6f22596e5 [compiler-rt] disable asan bcmp tests on android.
Android does not have bcmp.

sanitizer-x86_64-linux-android: run instrumented asan tests [arm/aosp_marlin-userdebug/PI] -  stdio

llvm-svn: 354853
2019-02-26 09:16:51 +00:00
Clement Courbet cb6b499fe6 [compiler-rt] Fix test broken by r354851.
error: CHECK: expected string not found in input
// CHECK: Uninitialized bytes in __interceptor_memcmp at offset 3

llvm-svn: 354852
2019-02-26 08:17:49 +00:00
Clement Courbet 02b9b4e18d [compiler-rt] Intercept the bcmp() function.
Summary:
I have not introduced a separate hook for `bcmp()` as I don't think there
should be any reason for a sanitizer to treat it differently from `memcmp()`.

This is only enabled when building on POSIX with GNU extensions.

Context: this is to avoid losing coverage when emitting `bcmp() == 0` instead
of `memcmp() == 0` in llvm, see https://reviews.llvm.org/D56593.

Reviewers: mgorny, krytarowski, vitalybuka, dvyukov

Subscribers: kubamracek, dberris, delcypher, jdoerfert, #sanitizers, llvm-commits, jyknight

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58379

llvm-svn: 354851
2019-02-26 07:43:01 +00:00
Reid Kleckner 8b6af00173 [llvm-cov] Fix llvm-cov on Windows and un-XFAIL test
Summary:
The llvm-cov tool needs to be able to find coverage names in the
executable, so the .lprfn and .lcovmap sections cannot be merged into
.rdata.

Also, the linker merges .lprfn$M into .lprfn, so llvm-cov needs to
handle that when looking up sections. It has to support running on both
relocatable object files and linked PE files.

Lastly, when loading .lprfn from a PE file, llvm-cov needs to skip the
leading zero byte added by the profile runtime.

Reviewers: vsk

Subscribers: hiraditya, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58661

llvm-svn: 354840
2019-02-26 02:30:00 +00:00
David Major b4e16e6ad1 [winasan] Unpoison stack memory when threads exit (redux)
This is a second attempt at r342652 using a TLS callback instead of an
interceptor.

In long-running builds we've seen some ASan complaints during thread creation
that we suspect are due to leftover poisoning from previous threads whose
stacks occupied that memory. This patch adds a callback that unpoisons the
stack memory when a thread exits.

Differential Revision: https://reviews.llvm.org/D58641

llvm-svn: 354836
2019-02-26 01:35:48 +00:00
Evgeniy Stepanov 7429228f20 [sanitizer] Re-disable a few tests on android.
Tests were accidentally enabled r354829.

llvm-svn: 354834
2019-02-26 00:22:22 +00:00
Evgeniy Stepanov f3b8c8509b [sanitizer] Remove "-android" from test_arch.
Summary:
ASan and Scudo tests are adding "-android" to test arch.
There are no tests that depend on it as far as I can see.
If necessary, do this instead:
  REQUIRES: aarch64-target-arch && android

Reviewers: pcc, vitalybuka

Subscribers: srhines, kubamracek, mgorny, javed.absar, kristof.beyls, cryptoad, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58532

llvm-svn: 354829
2019-02-25 22:32:30 +00:00
Richard Trieu 1bf3a09b3d Remove overly broad assert from r354717.
llvm-svn: 354720
2019-02-23 05:48:50 +00:00
Julian Lettner beb33eb3cf [NFC][Sanitizer] Comment out argument checks
These break clang-ppc64 bots.

llvm-svn: 354718
2019-02-23 03:24:10 +00:00
Julian Lettner 7c99328cf4 [NFC][Sanitizer] Add argument checks to BufferedStackTrace::Unwind* functions
Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D58555

llvm-svn: 354717
2019-02-23 02:36:23 +00:00
Julian Lettner 9af9ab47b7 [NFC][Sanitizer] Re-enable test on Darwin
This unexpectedly passes on our CI, although it still fails on my
machine.

llvm-svn: 354701
2019-02-22 23:37:46 +00:00
Julian Lettner 1e4f073582 [NFC][Sanitizer] Rename BufferedStackTrace::FastUnwindStack
FastUnwindStack -> UnwindFast
SlowUnwindStack -> UnwindSlow
Stack is redundant, verb should come first.

SlowUnwindStackWithContext(uptr pc, void *context, u32 max_depth) ->
SlowUnwindStack
WithContext is redundant, since it is a required parameter.

Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D58551

llvm-svn: 354696
2019-02-22 22:03:09 +00:00
Julian Lettner de7626985f [Sanitizer] Fix uses of stack->Unwind(..., fast)
Apply StackTrace::WillUseFastUnwind(fast) in a few more places missed by
my previous patch (https://reviews.llvm.org/D58156).

Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D58550

llvm-svn: 354695
2019-02-22 22:00:13 +00:00
Evgeniy Stepanov a2062b222d [sanitizer] Common macro for .note.GNU-stack directives (NFC)
llvm-svn: 354632
2019-02-21 22:59:29 +00:00
Evgeniy Stepanov 45eea20d2a Revert "[asan] Fix vfork handling.", +1
Revert r354625, r354627 - multiple build failures.

llvm-svn: 354629
2019-02-21 22:02:24 +00:00
Evgeniy Stepanov b5321d7d0b [asan] Fix vfork handling.
__asan_handle_vfork was unpoisoning the wrong part of the stack.
Adjust the test to catch this reliably (current failure is
non-deterministic).

llvm-svn: 354627
2019-02-21 21:55:06 +00:00
Evgeniy Stepanov df91386806 [hwasan,asan] Intercept vfork.
Summary: AArch64 only for now.

Reviewers: vitalybuka, pcc

Subscribers: srhines, kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, jdoerfert, #sanitizers, llvm-commits, kcc

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58313

llvm-svn: 354625
2019-02-21 21:32:24 +00:00
Matt Morehouse 9b900dc7de Revert "[sanitizers] Restore internal_readlink for x32"
This reverts r354451 since it broke the Windows sanitizer bot.

llvm-svn: 354601
2019-02-21 17:06:23 +00:00
Julian Lettner 65e9f98861 [LSan] Fix `__sanitizer_print_stack_trace` via fast unwinder
Summary: Quick follow-up to: https://reviews.llvm.org/D58156

Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D58358

llvm-svn: 354522
2019-02-20 22:28:11 +00:00
Vitaly Buka e4a7a46151 Fix license headers
llvm-svn: 354500
2019-02-20 18:55:52 +00:00
H.J. Lu 6716f4af81 [sanitizers] Restore internal_readlink for x32
r316591 has

@@ -389,13 +383,11 @@ uptr internal_dup2(int oldfd, int newfd) {
 }

 uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
-#if SANITIZER_NETBSD
-  return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize);
-#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
+#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
   return internal_syscall(SYSCALL(readlinkat), AT_FDCWD,
                           (uptr)path, (uptr)buf, bufsize);
 #else
-  return internal_syscall(SYSCALL(readlink), (uptr)path, (uptr)buf, bufsize);
+  return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize);
 #endif
 }

which dropped the (uptr) cast and broke x32.  This patch puts back the
(uptr) cast to restore x32 and fixes:

https://bugs.llvm.org/show_bug.cgi?id=40783

Differential Revision: https://reviews.llvm.org/D58413

llvm-svn: 354451
2019-02-20 11:43:43 +00:00
Evgeniy Stepanov bdbbfdc8c2 [msan] Fix name_to_handle_at test on overlayfs.
Udev supports name_to_handle_at. Use /dev/null instead of /bin/cat.

llvm-svn: 354402
2019-02-19 23:41:42 +00:00
Vitaly Buka 8ca98c2bc2 [msan] Remove cxa_atexit_race.cc
Summary:
The goal of the test to check that msan does not crash when code is racy on __cxa_atexit. Original crash was caused by race condition in the glibc. With
the msan patch the msan does not crashes however the race is still there and the test triggers it.

Because the test relies on triggering of undefined behavior results are not
very predictable and it may occasionally crashes or hangs.

I don't see how to reasonably improve the test, so I remove it.

Reviewers: eugenis, peter.smith

Subscribers: jfb, jdoerfert, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58396

llvm-svn: 354377
2019-02-19 20:36:52 +00:00
Kostya Serebryany 64c7b060bc [sanitizers] add a regression test for the bug fixed in r354366
llvm-svn: 354373
2019-02-19 19:28:08 +00:00
Kostya Serebryany 6bde702ac9 [sanitizer] fix a memory safety bug (!!!) in sanitizer suppressions code, discovered by Aaron Jacobs
llvm-svn: 354366
2019-02-19 18:43:24 +00:00
Petr Hosek a94e6d70f1 [compiler-rt][CMake] Set project for the custom libc++
This is another follow up to r354212 which is broken on Darwin when
cross-compiling runtimes to Linux when it ignores the -fuse-ld=lld
linker flag and attempts to use the host linker when performing the
compiler identification. Upon investigation, I noticed that setting
the project with appropriate list of languages makes the error go
away and it shouldn't hurt either.

Differential Revision: https://reviews.llvm.org/D58372

llvm-svn: 354350
2019-02-19 16:53:33 +00:00
Julian Lettner 9f14d169cc [LSan][Darwin][NFC] Add comment explaining test failure
llvm-svn: 354290
2019-02-18 22:29:17 +00:00
Julian Lettner eb3bcc1c95 [Sanitizer] On Darwin `__sanitizer_print_stack_trace` only prints topmost frame
In compiler-rt we have the notion of a `fast` and a `slow` stack
unwinder. Darwin currently only supports the fast unwinder.

From reading the code, my understanding is that
`BufferedStackTrace::Unwind` can be called with `bp=0, stack_top=0,
stack_bottom=0, request_fast_unwind=false`. If
`request_fast_unwind=true`, then we alos need to supply bp, stack_top,
and stack_bottom.

However, `BufferedStackTrace::Unwind` uses
`StackTrace::WillUseFastUnwind` which will adapt `request_fast_unwind`
if the requested unwinder is not supported. On Darwin, the result is
that we don't pass actual values for bp, stack_top, and stack_bottom,
but end up using the fast unwinder. The tests then fail because we only
print the topmost stack frame.

This patch adds a check to `WillUseFastUnwind` at the point of usage to
avoid the mismatch between `request_fast_unwind` and what `Unwind`
actually does. I am also interested in cleaning up the
`request_fast_unwind` machinery so this patch just the simplest thing
possible so I can enable the tests.

Reviewers: vitalybuka, vsk

Differential Revision: https://reviews.llvm.org/D58156

llvm-svn: 354282
2019-02-18 18:47:49 +00:00
Jonas Hahnfeld 0a9cb239a6 [compiler-rt] Fix broken sanitizer bots (hopefully)
According to the logs and local debugging there were two issues:
1) tsan tests listed libc++.a before the source file. That's usually
   ok for shared libraries, but the linker will not add symbols from
   a static library unless needed at that time. As a result the tests
   that rely upon symbols from the library (and not only include the
   headers) had undefined references.
   To solve this I'm adding a new substitution %link_libcxx_tsan which
   expands to libc++.a if available.
2) The target Fuzzer-x86_64-Test linked in SANITIZER_TEST_CXX_LIBRARIES
   which defaults to -lstdc++. This resulted in error messages like
     hidden symbol '_ZdlPv' is not defined locally
     hidden symbol '_Znwm' is not defined locally
   when using GNU gold (ld.bfd and lld are fine). Removing the linkage
   is fine because we build a custom libc++ for that purpose.

llvm-svn: 354231
2019-02-17 18:47:33 +00:00
Jonas Hahnfeld 66c60d9d71 [compiler-rt] Build custom libcxx with libcxxabi
This changes add_custom_libcxx to also build libcxxabi and merges
the two into a static and hermetic library.
There are multiple advantages:
1) The resulting libFuzzer doesn't expose C++ internals and looks
   like a plain C library.
2) We don't have to manually link in libstdc++ to provide cxxabi.
3) The sanitizer tests cannot interfere with an installed version
   of libc++.so in LD_LIBRARY_PATH.

Differential Revision: https://reviews.llvm.org/D58013

llvm-svn: 354212
2019-02-17 12:16:20 +00:00
Jonas Hahnfeld a05d442391 [compiler-rt] Cleanup usage of C++ ABI library
Add missed value "libcxxabi" and introduce SANITIZER_TEST_CXX for linking
unit tests. This needs to be a full C++ library and cannot be libcxxabi.

Recommit r354132 which I reverted in r354153 because it broke a sanitizer
bot. This was because of the "fixes" for pthread linking, so I've removed
these changes.

Differential Revision: https://reviews.llvm.org/D58012

llvm-svn: 354198
2019-02-16 08:34:26 +00:00
Kostya Serebryany b6ca1e7259 [libFuzzer] make len_control less agressive: set the initial max len to the length of the largest seed. This was the original intent, but... Now, with a test, to ensure it stays this way
llvm-svn: 354191
2019-02-16 01:23:41 +00:00
Kostya Serebryany 312af158b0 [libFuzzer] fork mode: try harder to cleanup after itself
llvm-svn: 354186
2019-02-16 00:14:16 +00:00
Julian Lettner 68c6764c20 [Sanitizer] iOS: Pull up parallelism_group handling into common.lit.config
Serial execution on iOS devices is not specific to sanitizers. We want
to throttle all on-device tests. Pull the setting of the
parallelism_group up into the common lit configuration file.

Rename `darwin-ios-device-sanitizer` to `ios-device`. This group is not
specific to sanitizers and (theoretically) independent from the host OS.

Note that we don't support running unit tests on-device (there are no
configurations generated for that). If that ever changes, we also need
this configuration in `unittests/lit.common.unit.cfg`.

Reviewers: delcypher

Differential Revision: https://reviews.llvm.org/D58209

llvm-svn: 354179
2019-02-15 22:12:36 +00:00
Kostya Serebryany 9982ee5472 [libFuzzer] form mode: add -ignore_crashes flag, honor the max_total_time flag, print the number of ooms/timeouts/crashes, fix a typo
llvm-svn: 354175
2019-02-15 21:51:15 +00:00
Richard Smith 1dcff8d17c Fix invalid code that Clang trunk will soon diagnose.
There is an ambiguity between ::SizeClassMap (the typedef declared near
the start of this file) and __sanitizer::SizeClassMap (found by the
'using namespace __sanitizer;' near the start of this file).

Historically a Clang bug has meant that the error was not diagnosed, but
soon Clang will start diagnosing it. Explicitly qualify this use of
SizeClassMap so that it finds __sanitizer::SizeClassMap rather than
being ill-formed due to ambiguity.

llvm-svn: 354174
2019-02-15 21:48:57 +00:00
Evgeniy Stepanov 360163f671 Fix unsymbolized stack history printing.
Summary:
When symbols are unavailable, the current code prints
  sp: ... pc: ... (null) (null)
instead of module name + offset.

Change the output to include module name and offset, and also to match
the regular sanitizer stack trace format so that it is recognized by
symbolize.py out of the box.

Reviewers: kcc, pcc

Subscribers: kubamracek, jdoerfert, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58267

llvm-svn: 354157
2019-02-15 18:38:23 +00:00
Evgeniy Stepanov a70d88c7a3 Runtime flags for malloc bisection.
Reviewers: kcc, pcc

Subscribers: kubamracek, mgorny, jdoerfert, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58162

llvm-svn: 354156
2019-02-15 18:38:14 +00:00
Evgeniy Stepanov 2c0483f5a6 Fix false positive when tag_in_malloc=0,tag_in_free=1.
Summary:
With tag_in_free=1, malloc() can not assume that the memory is untagged,
and needs to retag is to 0.

Reviewers: pcc, kcc

Subscribers: kubamracek, jfb, jdoerfert, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D58158

llvm-svn: 354155
2019-02-15 18:38:03 +00:00
Jonas Hahnfeld ea686e2845 Revert "[compiler-rt] Cleanup usage of C++ ABI library"
This reverts r354132 because it breaks sanitizer-x86_64-linux:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/19915

llvm-svn: 354153
2019-02-15 18:25:26 +00:00
Jonas Hahnfeld 77d0e63c1e [compiler-rt] Let CMake search for thread support
This is an educated guess to fix sanitizer-x86_64-linux after r354132.

llvm-svn: 354143
2019-02-15 16:27:52 +00:00
Jonas Hahnfeld 3cc63cfaa7 [compiler-rt] Cleanup usage of C++ ABI library
Add missed value "libcxxabi" and introduce SANITIZER_TEST_CXX for linking
unit tests. This needs to be a full C++ library and cannot be libcxxabi.

Differential Revision: https://reviews.llvm.org/D58012

llvm-svn: 354132
2019-02-15 14:30:18 +00:00
Kostya Serebryany 77cbc62544 [libFuzzer] print new functions as they are discovered in the fork mode
llvm-svn: 354092
2019-02-15 01:22:00 +00:00
Kostya Serebryany b96b10d1a3 [libFuzzer] fix the unit tests
llvm-svn: 354088
2019-02-15 00:15:13 +00:00
Kostya Serebryany 8c2791469d [libFuzzer] when doing the merge, keep track of the coveraged edges, not just features
llvm-svn: 354087
2019-02-15 00:08:16 +00:00
Kostya Serebryany 96f81bc679 [libFuzzer] when doing the merge, keep track of the coveraged edges, not just features
llvm-svn: 354076
2019-02-14 23:12:33 +00:00
Ana Pazos bbb8129b2c Set hidden attribute on lprofMergeValueProfData
Summary:
The changes in https://reviews.llvm.org/D44847 cause load time failure
due to lprofMergeValueProfData in Android libs enabled with profile generation:

"dlopen failed: cannot locate symbol "lprofMergeValueProfData" referenced by..."

Marking lprofMergeValueProfData as hidden so the correct in-module definition
 is picked by the linker.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: efriedma, xur, davidxl, llvm-commits

Differential Revision: https://reviews.llvm.org/D55893

llvm-svn: 354064
2019-02-14 21:38:40 +00:00
Kostya Serebryany 8e918d6ead [libFuzzer] better stats for the fork mode
llvm-svn: 354061
2019-02-14 21:09:32 +00:00
Douglas Yung 7f95f96391 Revert "Temporarily disable calls to getgrnam/getgrnam_r in test due to it hitting unrelated issues in EGLIBC 2.19."
This reverts commit r353594.

We have updated our internal build bot to a newer version of LIBC which does not have this problem.

llvm-svn: 354014
2019-02-14 10:39:11 +00:00
Vitaly Buka 9a370ccca2 [msan] Don't delete MSanAtExitRecord
Summary:
Pre 2.27 libc can run same atexit handler twice
We will keep MSanAtExitRecord and reset fun to mark it as executed.

Fix PR40162

Reviewers: eugenis

Subscribers: jfb, jdoerfert, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58221

llvm-svn: 354005
2019-02-14 02:51:55 +00:00
Kostya Serebryany debf0af71d [libFuzzer] trying to fix the bot (can't reproduce the build failure locally)
llvm-svn: 354000
2019-02-14 01:11:29 +00:00
Kostya Serebryany 60c5ded269 [libFuzzer] add threads to the fork mode: now you can pass -fork=N to run N concurrent workers. Fork mode is still work-in-progress.
llvm-svn: 353997
2019-02-14 00:25:43 +00:00
Dmitry Vyukov 76e961207b tsan: add fiber support
This patch adds functions for managing fibers:

__tsan_get_current_fiber()
__tsan_create_fiber()
__tsan_destroy_fiber()
__tsan_switch_to_fiber()
__tsan_set_fiber_name()

See the added tests for use examples.

Author: yuri (Yuri Per)
Reviewed in: https://reviews.llvm.org/D54889

[The previous commit of this change was reverted,
this is a resubmit with a squashed fix for check_analyze.sh
and COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED]

llvm-svn: 353947
2019-02-13 13:21:24 +00:00
Diana Picus d3f13f1608 Revert "tsan: update check_analyze.sh"
This reverts commit r353820, to go with the revert of r353817.

llvm-svn: 353942
2019-02-13 12:06:13 +00:00
Diana Picus 4152a09e55 Revert "tsan: add fiber support"
This reverts commit r353817 because we think it broke AARch64 and
PowerPC buildbots.

llvm-svn: 353939
2019-02-13 11:32:56 +00:00
Martin Storsjo 7eb4ec2879 [profile] Provide lprofGetHostName for all windows environments
This function doesn't use anything MSVC specific but works fine
for any _WIN32 target.

Differential Revision: https://reviews.llvm.org/D58106

llvm-svn: 353918
2019-02-13 07:27:05 +00:00
Petr Hosek 38c723b004 [CMake] Avoid clang dependencies in the runtimes build
Dependencies like clang aren't available in the runtimes build, this
was accidentally omitted in D57992.

llvm-svn: 353914
2019-02-13 06:49:47 +00:00
Kostya Serebryany d085748484 [libFuzzer] a bit of refactoring of the fork mode
llvm-svn: 353910
2019-02-13 04:04:45 +00:00
Julian Lettner 55fb5314b3 [Sanitizer][NFC] Darwin: limit parallism for sanitizer_common tests
Many sanitizer_common tests (ASan, TSan) run with a "sanitized process
space" so we need to limit their parallism.

llvm-svn: 353909
2019-02-13 01:56:53 +00:00
Hubert Tong a9f91c810c [xray][tests][RHDTS] Add -lstdc++ after LLVM libs, resolving link error with RHDTS
Summary:
A link error was encountered when using the Red Hat Developer Toolset.
In the RHDTS, `libstdc++.so` is a linker script that may resolve symbols
to a static library. This patch places `-lstdc++` later in the ordering.

Reviewers: sfertile, nemanjai, tstellar, dberris

Reviewed By: dberris

Subscribers: dberris, mgorny, delcypher, jdoerfert, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

Differential Revision: https://reviews.llvm.org/D58144

llvm-svn: 353905
2019-02-13 00:55:30 +00:00
Evgeniy Stepanov 8bb5d7e76a [tsan] #undef one-letter macros
buildgo.sh puts most of sanitizer_common together in a single source
file. These single-letter macros end up affecting a lot of unrelated
code; #undef them as early as possible.

llvm-svn: 353902
2019-02-12 23:49:02 +00:00
Kostya Serebryany 5c08e811de [libFuzzer] move the implementation of the fork mode into a separate file
llvm-svn: 353891
2019-02-12 22:48:55 +00:00
Dmitry Vyukov 19e41fb0ca tsan: update check_analyze.sh
Update numbers after 353817.
This was extensively benchmarked in https://reviews.llvm.org/D54889

llvm-svn: 353820
2019-02-12 10:18:27 +00:00
Dmitry Vyukov 6e7089ad40 tsan: add fiber support
This patch adds functions for managing fibers:

__tsan_get_current_fiber()
__tsan_create_fiber()
__tsan_destroy_fiber()
__tsan_switch_to_fiber()
__tsan_set_fiber_name()

See the added tests for use examples.

Author: yuri (Yuri Per)
Reviewed in: https://reviews.llvm.org/D54889

llvm-svn: 353817
2019-02-12 10:11:58 +00:00
Dmitry Vyukov ca524b19c1 tsan: Introduce in_symbolizer() function for Thread sanitizer
This change is preparation for fiber support.

Author: yuri (Yuri Per)
Reviewed in: https://reviews.llvm.org/D58104

llvm-svn: 353805
2019-02-12 08:11:07 +00:00
Petr Hosek 61b513351c [CMake] Avoid internal dependencies in the runtimes build
When performing runtimes build, dependencies like clang and
clang-headers aren't available. This was accidentally omitted in D57992.

llvm-svn: 353796
2019-02-12 04:13:58 +00:00
Kostya Serebryany 2b9a8f37a4 [libFuzzer] make the fork mode less verbose
llvm-svn: 353794
2019-02-12 03:12:40 +00:00
Kostya Serebryany cdbb9dc962 [libFuzzer] teach the fork mode to ignore OOMs and timeouts
llvm-svn: 353792
2019-02-12 02:18:53 +00:00
Petr Hosek 26eec703f7 [sanitizer] Don't compile GetPathAssumingFileIsRelativeToExec on Fuchsia
This avoids the unused function warning during compilation.

Differential Revision: https://reviews.llvm.org/D58082

llvm-svn: 353787
2019-02-12 01:36:08 +00:00
Petr Hosek 47de76b0d4 [CMake][XRay] Silence llvm-config error when checking library support
Otherwise this propagates all the way to CMake and results in an error
during configuration. We check and handle the result and report warning
separately so this is not changing the behavior.

Differential Revision: https://reviews.llvm.org/D58086

llvm-svn: 353784
2019-02-12 01:09:07 +00:00
Kostya Serebryany 73bf6d5b35 [libFuzzer] replace slow std::mt19937 with a much faster std::minstd_rand; second attempt after failed r352732, this time with a fix for cmake
llvm-svn: 353782
2019-02-12 01:00:08 +00:00
Kostya Serebryany 56b2d57cbf [libFuzzer] simplify the code for print_coverage=1 so that it doesn't fail on broken debug info
llvm-svn: 353781
2019-02-12 00:52:11 +00:00
Julian Lettner ee82db57ec [libFuzzer] Make coverage.test work on ARM64
Summary:
This test instruments the following code with coverage, runs the fuzzer
once, and asserts that there are uncovered PCs. The ARM64 backend
optimizes this code using the `csel` (Conditional select) instruction,
which removes all branching from the resulting machine code. The test
then fails because we do not have any uncovered PCs. The easiest
solution for now is to turn off optimization for the DSOs used in this
test.

```
int DSO1(int a) {
  if (a < 123456)
    return 0;
  return 1;
}
```

rdar://47646400

Reviewers: kcc

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D58087

llvm-svn: 353780
2019-02-12 00:37:40 +00:00
Kostya Serebryany 8cc38effe2 [libFuzzer] run the -fork=1 tests only on linux
llvm-svn: 353777
2019-02-12 00:29:51 +00:00
Kostya Serebryany 63f48717b5 [libFuzzer] extend the -fork=1 functionality. Still not fully usable, but good enough for the first unit test
llvm-svn: 353775
2019-02-12 00:12:33 +00:00
Julian Lettner 6142bf2c51 [NFC] Re-enable XFAILed fuzzer test on iOS
llvm-svn: 353737
2019-02-11 19:33:01 +00:00
Vitaly Buka 86a8d50965 tsan: Implement pthread_exit() interceptor for Thread sanitizer
This change is preparation for fiber support.

Author: yuri (Yuri Per)
Reviewed in: https://reviews.llvm.org/D57876
Context: https://reviews.llvm.org/D54889

> llvm-svn: 353385

llvm-svn: 353627
2019-02-09 22:08:31 +00:00
Vitaly Buka 4fefb72019 [tsan] Remove debug logging and disable test on ppc64be
llvm-svn: 353624
2019-02-09 19:28:52 +00:00
Vitaly Buka 3eca7f5139 [tsan] Remove debug logging and disable test on ppc64be
llvm-svn: 353623
2019-02-09 18:43:24 +00:00
Vitaly Buka 9419b5bd04 [tsan] Debug failing test on PPC bot
llvm-svn: 353617
2019-02-09 16:28:41 +00:00
Vitaly Buka 2abcb30f8c [tsan] Remove pthread_exit interceptor
Crashes PPC bot

llvm-svn: 353604
2019-02-09 09:58:57 +00:00
Petr Hosek 3ef9918d25 [CMake] Don't set <PROJECT>_STANDALONE_BUILD
We shouldn't be treating runtimes builds as standalone builds since
we have enough of the context loaded into the runtimes environment.

Differential Revision: https://reviews.llvm.org/D57992

llvm-svn: 353601
2019-02-09 03:06:56 +00:00
David L. Jones 6218b8e783 [Fuzzer] Fix function prototype in fuzzer::ExternalFunctions. [NFC]
The __sanitizer_acquire_crash_state function has int return type, but the
fuzzer's external function definitions give it bool.

Places where __sanitizer_acquire_crash_state is declared:

  include/sanitizer_common/sanitizer_interface_defs.h
  lib/sanitizer_common/sanitizer_interface_internal.h
  lib/sanitizer_common/sanitizer_common.cc
  lib/fuzzer/FuzzerExtFunctions.def (this is the only bool)

llvm-svn: 353596
2019-02-09 01:45:29 +00:00