Commit Graph

12006 Commits

Author SHA1 Message Date
Nico Weber f9e0df071e compiler-rt: Rename .cc file in test/hwasan to .cpp
Like r367463, but for test/hwasan.

llvm-svn: 367849
2019-08-05 13:10:50 +00:00
Fangrui Song 97ccf6b8c1 compiler-rt: Rename .cc file in test/lsan to .cpp
Like r367463, but for test/lsan.

llvm-svn: 367803
2019-08-05 07:04:42 +00:00
Rainer Orth f98a153c8d [sanitizer_common][tests] Fix SanitizerCommon-Unit :: ./Sanitizer-*-Test/SanitizerCommon.PthreadDestructorIterations on Solaris
SanitizerCommon.PthreadDestructorIterations currently FAILs on Solaris:

  [ RUN      ] SanitizerCommon.PthreadDestructorIterations
  /vol/llvm/src/compiler-rt/local/lib/sanitizer_common/tests/sanitizer_posix_test.cc:58: Failure
  Value of: destructor_executed
    Actual: true
  Expected: false
  [  FAILED  ] SanitizerCommon.PthreadDestructorIterations (1 ms)

It turns out that destructor is called 4 times after the first call to SpawnThread, but
5 times after the second.  While PTHREAD_DESTRUCTOR_ITERATIONS is 4 in
<limits.h>, the Solaris pthread_key_create(3C) man page documents

  If, after all the destructors have been called for all keys  with  non-
  null  values,  there  are  still  some  keys  with non-null values, the
  process will be repeated. POSIX requires that this process be  executed
  at   least   PTHREAD_DESTRUCTOR_ITERATIONS  times.  Solaris  calls  the
  destructors repeatedly until all values with associated destructors are
  NULL. Destructors that set new values can cause an infinite loop.

The patch adjusts the test case to allow for this.

Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 367705
2019-08-02 18:55:22 +00:00
Fangrui Song bcaeed49cb compiler-rt: Rename .cc file in test/tsan to .cpp
Like r367463, but for test/tsan.

llvm-svn: 367656
2019-08-02 07:18:07 +00:00
Fangrui Song d21b3d346a compiler-rt: Rename .cc file in test/msan to .cpp
Like r367463, but for test/msan.

llvm-svn: 367653
2019-08-02 06:07:05 +00:00
Fangrui Song 6db8c59f21 compiler-rt: Rename .cc file in test/xray to .cpp
Like r367463, but for test/xray.

Update test/xray/lit.cfg.py config.suffixes to remove .cc (we actually
don't have .c tests now)

llvm-svn: 367652
2019-08-02 05:49:58 +00:00
Vitaly Buka 74296c99b3 Fix flaky test caused by PR42868
llvm-svn: 367642
2019-08-02 02:27:04 +00:00
Nico Weber 4a1a113a99 Remove a few straggler ".cc"s in compiler-rt/lib
llvm-svn: 367589
2019-08-01 17:53:25 +00:00
Nico Weber 4ef767dfe9 try to fix bots more after r367562
llvm-svn: 367587
2019-08-01 17:31:49 +00:00
Nico Weber 558ee6544e try to fix bots after r367562
llvm-svn: 367586
2019-08-01 17:30:41 +00:00
Nico Weber 267d63f80a compiler-rt: Call a generated c++ file in hwasan .cpp instead of .cc
llvm-svn: 367572
2019-08-01 14:48:16 +00:00
Nico Weber 3fa3831830 compiler-rt: Rename .cc file in lib/scudo/standalone/tests to .cpp
Like r367463, but for scudo/standalone/tests.

With this, all files in compiler-rt/lib have extension cpp.

llvm-svn: 367569
2019-08-01 14:38:49 +00:00
Nico Weber 6d46ebefb7 compiler-rt: Rename .cc file in lib/scudo/standalone to .cpp
Like r367463, but for scudo/standalone.

llvm-svn: 367568
2019-08-01 14:36:38 +00:00
Nico Weber d11b16e1fe compiler-rt: Rename .cc file in lib/tsan/{benchmarks,dd,go} to .cpp
Like r367463, but for tsan/{benchmarks,dd,go}.

The files benchmarks aren't referenced in the build anywhere and where added
in 2012 with the comment "no Makefiles yet".

llvm-svn: 367567
2019-08-01 14:30:49 +00:00
Nico Weber 5de29a4b0e compiler-rt: Rename .cc file in lib/tsan/tests/{rtl,unit} to .cpp
Like r367463, but for tsan/tests/{rtl,unit}.

llvm-svn: 367566
2019-08-01 14:26:37 +00:00
Nico Weber 5a3bb1a4d6 compiler-rt: Rename .cc file in lib/tsan/rtl to .cpp
Like r367463, but for tsan/rtl.

llvm-svn: 367564
2019-08-01 14:22:42 +00:00
Nico Weber 1265d0f44c compiler-rt: Rename .cc file in lib/msan/tests to .cpp
Like r367463, but for msan/tests.

llvm-svn: 367563
2019-08-01 14:09:37 +00:00
Nico Weber 60c66db476 compiler-rt: Rename .cc file in lib/msan to .cpp
Like r367463, but for msan.

llvm-svn: 367562
2019-08-01 14:08:18 +00:00
Nico Weber ae1fc9baae compiler-rt: Rename .cc file in lib/lsan to .cpp
Like r367463, but for lsan.

llvm-svn: 367561
2019-08-01 14:01:30 +00:00
Nico Weber 9642e337eb compiler-rt: Rename .cc file in lib/{interception/tests,safestack} to .cpp
Like r367463, but for interception/tests and safestack.

llvm-svn: 367560
2019-08-01 13:56:52 +00:00
Nico Weber b47455b573 compiler-rt: Rename .cc file in lib/asan/tests to .cpp
Like r367463, but for asan/tests

llvm-svn: 367559
2019-08-01 13:48:31 +00:00
Nico Weber 217222abea compiler-rt: Rename .cc file in lib/asan to .cpp
Like r367463, but for asan.

llvm-svn: 367558
2019-08-01 13:43:28 +00:00
Nico Weber c58c1c5350 Try to heal bots more after r367551
llvm-svn: 367555
2019-08-01 13:10:43 +00:00
Nico Weber 208ebc9e8b Try to heal bots after r367551
llvm-svn: 367552
2019-08-01 12:42:28 +00:00
Nico Weber a9aa813792 compiler-rt: Rename .cc file in lib/{dfsan,stats,ubsan_minimal} to .cpp
Like r367463, but for dfsan, stats, ubsan_minimal.

llvm-svn: 367551
2019-08-01 12:41:23 +00:00
Nico Weber bc0d697db9 compiler-rt: Rename .cc file in lib/xray/tests/unit to .cpp
Like r367463, but for xray/texts/unit.

llvm-svn: 367550
2019-08-01 12:35:27 +00:00
Nico Weber b301860321 compiler-rt: Rename .cc file in lib/xray to .cpp
Like r367463, but for xray.

llvm-svn: 367546
2019-08-01 12:30:58 +00:00
Nico Weber 45ff4868c4 compiler-rt: Try to appease lint script.
A bot complains:

/b/sanitizer-x86_64-linux-autoconf/build/llvm/projects/compiler-rt/lib/sanitizer_common/tests/malloc_stress_transfer_test.cpp:2:  Streams are highly discouraged.  [readability/streams] [3]
/b/sanitizer-x86_64-linux-autoconf/build/llvm/projects/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp:11:  Streams are highly discouraged.  [readability/streams] [3]
lib/CMakeFiles/SanitizerLintCheck.dir/build.make:57: recipe for target 'lib/CMakeFiles/SanitizerLintCheck' failed

I do not know why this apparently wasn't a problem when the files
had extension .cc.

llvm-svn: 367493
2019-07-31 23:34:07 +00:00
Nico Weber 0e86e7fda3 Attempt to heal bots after r367467
llvm-svn: 367473
2019-07-31 20:12:19 +00:00
Nico Weber c940adeddb compiler-rt: Rename .cc file in lib/sanitizer_common/symbolizer to .cpp
llvm-svn: 367471
2019-07-31 19:41:02 +00:00
Nico Weber f724b460bd Attempt to heal tsan bot after r367463
llvm-svn: 367469
2019-07-31 19:31:36 +00:00
Nico Weber d6d569fc06 compiler-rt: Rename .cc file in lib/sanitizer_common/tests to .cpp
See https://reviews.llvm.org/D58620 for discussion, and for the commands
I ran. In addition I also ran

  for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $(basename $f) . ; done

and manually updated references to renamed files found by that.

llvm-svn: 367467
2019-07-31 19:11:14 +00:00
Nico Weber 65492d959b compiler-rt: Rename .cc file in lib/sanitizer_common to .cpp
See https://reviews.llvm.org/D58620 for discussion, and for the commands
I ran. In addition I also ran

  for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done

and manually updated (many) references to renamed files found by that.

llvm-svn: 367463
2019-07-31 18:51:27 +00:00
Nico Weber b42a1c6967 Attempt to heal bots after r367456
llvm-svn: 367462
2019-07-31 18:43:27 +00:00
Nico Weber 62a0585530 compiler-rt: Rename .cc file in lib/profile to .cpp
See https://reviews.llvm.org/D58620 for discussion.

Note how the comment in the file already said ".cpp" :)

llvm-svn: 367460
2019-07-31 18:21:08 +00:00
Nico Weber ebbce04c14 compiler-rt: Rename .cc files in lib/interception to .cpp.
See https://reviews.llvm.org/D58620 for discussion, and for the commands
I ran. In addition I also ran

  for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done

and manually updated references to renamed files found by that.

llvm-svn: 367456
2019-07-31 18:01:55 +00:00
Nico Weber 46ba969752 compiler-rt: Rename .cc files in lib/ubsan to .cpp.
See https://reviews.llvm.org/D58620 for discussion, and for the commands
I ran. In addition I also ran

  for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done

and manually updated references to renamed files found by that.

llvm-svn: 367452
2019-07-31 17:51:05 +00:00
Nico Weber b206c3e3e4 gn build: Add build files for compiler-rt/lib/profile
Differential Revision: https://reviews.llvm.org/D65518

llvm-svn: 367450
2019-07-31 17:15:32 +00:00
Nico Weber e4001bacc2 gn build: Fix redundant object files in builtin lib.
compiler-rt's builtin library has generic implementations of many
functions, and then per-arch optimized implementations of some.

In the CMake build, both filter_builtin_sources() and an explicit loop
at the end of the build file (see D37166) filter out the generic
versions if a per-arch file is present.

The GN build wasn't doing this filtering. Just do the filtering manually
and explicitly, instead of being clever.

While here, also remove files from the mingw/arm build that are
redundantly listed after D39938 / r318139 (both from the CMake and the
GN build).

While here, also fix a target_os -> target_cpu typo.

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

llvm-svn: 367448
2019-07-31 17:08:34 +00:00
Alexander Richardson a4ea27de92 [Sanitizer][ASAN][MSAN] Fix infinite recursion on FreeBSD
Summary:
MSAN was broken on FreeBSD by https://reviews.llvm.org/D55703: after this
change accesses to the key variable call __tls_get_addr, which is
intercepted. The interceptor then calls GetCurrentThread which calls
MsanTSDGet which again calls __tls_get_addr, etc...
Using the default implementation in the SANITIZER_FREEBSD case fixes MSAN
for me.

I then applied the same change to ASAN (introduced in https://reviews.llvm.org/D55596)
but that did not work yet. In the ASAN case, we get infinite recursion
again during initialization, this time because calling pthread_key_create() early on
results in infinite recursion. pthread_key_create() calls sysctlbyname()
which is intercepted but COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED returns
true, so the interceptor calls internal_sysctlbyname() which then ends up
calling the interceptor again. I fixed this issue by using dlsym() to get
the libc version of sysctlbyname() instead.

This fixes https://llvm.org/PR40761

Reviewers: vitalybuka, krytarowski, devnexen, dim, bsdjhb, #sanitizers, MaskRay

Reviewed By: MaskRay

Subscribers: MaskRay, emaste, kubamracek, jfb, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 367442
2019-07-31 16:31:55 +00:00
Dan Liew 62a8728750 [asan_symbolize] More debugging output
When a line fails to match the stackframe regex we now report
it in the log.

rdar://problem/49476995

llvm-svn: 367380
2019-07-31 00:59:10 +00:00
Dan Liew 51b1d858d3 [asan_symbolize] Add `--skip-uuid-validation` option to `ModuleMapPlugIn`.
This option disables the validation of binary UUIDs. This is useful
in environments where the `otool` binary is not available.

rdar://problem/49476995

llvm-svn: 367379
2019-07-31 00:59:10 +00:00
Dan Liew 23fd828d4e [asan_symbolize] Provide better error message when extracting the UUID of a binary fails
rdar://problem/49476995

llvm-svn: 367378
2019-07-31 00:59:09 +00:00
Reid Kleckner c41b58fd40 Remove cmake checks for MSVC 1900 / VS 2013
Our minimum Visual C++ version is 19.10 from Visual Studio 2017.

llvm-svn: 367362
2019-07-30 22:49:11 +00:00
Rainer Orth 63d9605091 [builtins][test] XFAIL two SPARC tests
Two SPARC builtins tests are currently FAILing due to codegen bugs:

  Builtins-sparc-sunos :: divtc3_test.c
  Builtins-sparcv9-sunos :: compiler_rt_logbl_test.c
  Builtins-sparcv9-sunos :: divtc3_test.c

I'd like to XFAIL them to reduce testsuite noise. 
  
Done as follows, tested on sparcv9-sun-solaris2.11 and x86_64-pc-solaris2.11.

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

llvm-svn: 367295
2019-07-30 08:05:14 +00:00
Rainer Orth 58aa6a87a6 [ASan][test] XFAIL AddressSanitizer-*-sunos :: TestCases/intercept-rethrow-exception.cc on Solaris
AddressSanitizer-*-sunos :: TestCases/intercept-rethrow-exception.cc currently FAILs
on Solaris.  This happens because std::rethrow_exception cannot be intercepted, as
detailed in Bug 42703.

To account for this and reduce testsuite noise, this patch XFAILs the test.

Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 367293
2019-07-30 07:59:43 +00:00
Francis Visoiu Mistrih fb3c53af34 Revert "[compiler-rt] Appending COMPILER_RT_LIBCXX_PATH -isystem include for xray (2)"
This reverts commit r367250. It's failing on green dragon:
http://lab.llvm.org:8080/green/job/clang-stage1-RA/482/console.

llvm-svn: 367265
2019-07-29 22:08:12 +00:00
Puyan Lotfi a9c59b2873 [compiler-rt] Appending COMPILER_RT_LIBCXX_PATH -isystem include for xray (2)
Second attempt.

Haven't found a better way to pass the libcxx include path for building
compiler-rt with libcxx; this seems to be missing only for xray.

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

llvm-svn: 367250
2019-07-29 19:21:58 +00:00
Puyan Lotfi 5bf16ec02b [compiler-rt] Reverting r367239 (xray include path) to fix bot build breakage.
llvm-svn: 367246
2019-07-29 17:50:39 +00:00
Puyan Lotfi ba7b7f1de4 Appending COMPILER_RT_LIBCXX_PATH include path to -isystem for compiler-rt xray
Haven't found a better way to pass the libcxx include path for building
compiler-rt with libcxx; this seems to be missing only for xray.

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

llvm-svn: 367239
2019-07-29 16:46:35 +00:00
Eugene Leviant 45d910de99 Don't initialize interceptor_metadata_map unless SI_POSIX is set
Differential revision: https://reviews.llvm.org/D64794

llvm-svn: 367188
2019-07-28 08:58:44 +00:00
Alexander Richardson 51bfb84852 [compiler-rt] Fix running tests on macOS when XCode is not installed
Summary:
If XCode is not installed, `xcodebuild -version -sdk macosx Path` will give
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
In this case the variable OSX_SYSROOT will be empty and
OSX_SYSROOT_FLAG is set to "-isysroot" (without a path).
This then causes the CompilerRTUnitTestCheckCxx target failed to for me
because "${COMPILER_RT_TEST_COMPILER} ${OSX_SYSROOT_FLAG} -E" expanded to
"clang -isysroot -E". This results in a warning "sysroot -E does not exist"
and the target fails to run because the C++ headers cannot be found.

Reviewers: beanz, kubamracek

Reviewed By: beanz

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

Tags: #sanitizers, #llvm

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

llvm-svn: 367170
2019-07-27 12:30:15 +00:00
Pirama Arumuga Nainar 6caa8da072 [profile] In Android, do not mkdir() dirs in GCOV_PREFIX
Summary:
In Android, attempting to mkdir() or even stat() top-level directories
like /data causes noisy selinux denials.  During whole-system coverage
instrumentation, this causes a deluge of noisy messages that drown out
legitimate selinux denials, that should be audited and fixed.

To avoid this, skip creating any directory in GCOV_PREFIX (thereby
assuming that it exists).

- Android platform ensures that the GCOV_PREFIX used in Android is
created and read/writable by all processes.
- This only affects the Android platform (by checking against
__ANDROID_API_FUTURE__) and for apps built with Clang coverage, the
runtime will still create any non-existent parent directories for the
coverage files.

Reviewers: srhines, davidxl

Subscribers: krytarowski, #sanitizers, danalbert, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 367064
2019-07-25 22:10:56 +00:00
Julian Lettner 758f6da687 [sanitizer_common] Allow customization of StartSymbolizerSubprocess
Summary:
Make SymbolizerProcess::StartSymbolizerSubprocess virtual and protected
to allow subclasses to customize it via "override and call".

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 366967
2019-07-25 00:19:02 +00:00
Kostya Kortchinsky 419f1a4185 [scudo][standalone] Optimization pass
Summary:
This introduces a bunch of small optimizations with the purpose of
making the fastpath tighter:
- tag more conditions as `LIKELY`/`UNLIKELY`: as a rule of thumb we
  consider that every operation related to the secondary is unlikely
- attempt to reduce the number of potentially extraneous instructions
- reorganize the `Chunk` header to not straddle a word boundary and
  use more appropriate types

Note that some `LIKELY`/`UNLIKELY` impact might be less obvious as
they are in slow paths (for example in `secondary.cc`), but at this
point I am throwing a pretty wide net, and it's consistant and doesn't
hurt.

This was mosly done for the benfit of Android, but other platforms
benefit from it too. An aarch64 Android benchmark gives:
- before:
```
  BM_youtube/min_time:15.000/repeats:4/manual_time_mean              445244 us       659385 us            4
  BM_youtube/min_time:15.000/repeats:4/manual_time_median            445007 us       658970 us            4
  BM_youtube/min_time:15.000/repeats:4/manual_time_stddev               885 us         1332 us            4
```
- after:
```
  BM_youtube/min_time:15.000/repeats:4/manual_time_mean       415697 us       621925 us            4
  BM_youtube/min_time:15.000/repeats:4/manual_time_median     415913 us       622061 us            4
  BM_youtube/min_time:15.000/repeats:4/manual_time_stddev        990 us         1163 us            4
```

Additional since `-Werror=conversion` is enabled on some platforms we
are built on, enable it upstream to catch things early: a few sign
conversions had slept through and needed additional casting.

Reviewers: hctim, morehouse, eugenis, vitalybuka

Reviewed By: vitalybuka

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

Tags: #llvm, #sanitizers

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

llvm-svn: 366918
2019-07-24 16:36:01 +00:00
Max Moroz 374398afb7 [libFuzzer] Fix __sanitizer_print_memory_profile return type in ExtFunctions.def
Summary:
Looks like a typo, as that function actually returns void and is used
as such in libFuzzer code as well.

Reviewers: kcc, Dor1s

Reviewed By: Dor1s

Subscribers: delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 366834
2019-07-23 18:26:53 +00:00
Rainer Orth 569f92f1e1 [compiler-rt][builtins] Provide __clear_cache for SPARC
While working on https://reviews.llvm.org/D40900, two tests were failing since __clear_cache
aborted.  While libgcc's __clear_cache is just empty, this only happens because
gcc (in gcc/config/sparc/sparc.c (sparc32_initialize_trampoline, sparc64_initialize_trampoline))
emits flush insns directly.

The following patch mimics that.

Tested on sparcv9-sun-solaris2.11.

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

llvm-svn: 366822
2019-07-23 16:33:54 +00:00
Lei Huang 686cee0945 [NFC][ASAN] Add brackets around not command
Under certain execution conditions, the `not` command binds to the command the
output is piped to rather than the command piping the output. In this case, that
flips the return code of the FileCheck invocation, causing a failure when
FileCheck succeeds.

llvm-svn: 366805
2019-07-23 13:10:29 +00:00
Julian Lettner 2ef9ec4050 [TSan] Enable fiber tests on iOS simulator
These tests *do not* work on device, but they *do* work in the
simulator.

rdar://53403778

llvm-svn: 366738
2019-07-22 21:13:19 +00:00
Serge Guelton a30a4a35ec Fix asan infinite loop on undefined symbol
Fix llvm#39641

Recommit of r366413

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

> llvm-svn: 366632

llvm-svn: 366638
2019-07-20 17:44:30 +00:00
Serge Guelton 7a3d4c15a7 Revert "Fix asan infinite loop on undefined symbol"
This reverts commit cbd28cd05b.

Buildbot fail: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/22434/steps/64-bit%20check-asan-dynamic/

llvm-svn: 366634
2019-07-20 13:00:12 +00:00
Serge Guelton cbd28cd05b Fix asan infinite loop on undefined symbol
Fix llvm#39641

Recommit of r366413

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

llvm-svn: 366632
2019-07-20 12:01:18 +00:00
Matthew Voss 407e837540 Revert "Fix asan infinite loop on undefined symbol"
This reverts commit 8e46275488.

This was failing on sanitizer-x86_64-linux and our internal CI.

llvm-svn: 366618
2019-07-19 21:41:07 +00:00
Serge Guelton 8e46275488 Fix asan infinite loop on undefined symbol
Fix llvm#39641

Recommit of r366413

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

llvm-svn: 366588
2019-07-19 15:20:36 +00:00
Yi Kong c12f29948d [libFuzzer] Set Android specific ALL_FUZZER_SUPPORTED_ARCH
Build libFuzzer for all Android supported architectures.

llvm-svn: 366525
2019-07-19 02:07:46 +00:00
Julian Lettner be7a7ae0c3 [ASan] Support `{f}puts(NULL)` on Darwin, part 2
Add braces around macro `{ MACRO(); }` to guard against macros that
expand to multiple statements.

llvm-svn: 366488
2019-07-18 20:14:50 +00:00
Matthew Voss 892758a526 [compiler-rt] Complete revert of r366413
Incomplete revert. Mea culpa. This test is failing on sanitizer-x86_64-linux
and our internal CI.

llvm-svn: 366482
2019-07-18 18:39:06 +00:00
Matthew Voss 3e93131dd2 Revert "Fix asan infinite loop on undefined symbol"
This reverts commit 63719119c7.

The tests in this commit were failing on a Linux sanitizer bot
and our internal CI.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/22401/steps/test%20standalone%20compiler-rt%20with%20symbolizer/logs/stdio

llvm-svn: 366472
2019-07-18 17:43:44 +00:00
Jonas Devlieghere a5359b1b07 [CMake] Don't set Python_ADDITIONAL_VERSIONS
Until recently, Python_ADDITIONAL_VERSIONS was used to limit LLVM's
Python support to 2.7. Now that both LLVM and LLDB both support Python
3, there's no longer a need to put an arbitrary limit on this.

However, instead of removing the variable, r365692 expanded the list,
which has the (presumably unintentional) side-effect of expression
preference for Python 3.

Instead, as Michal proposed in the original code review, we should just
not set the list at all, and let CMake pick whatever Python interpreter
you have in your path.

This patch removes the Python_ADDITIONAL_VERSIONS variable in llvm,
clang and lld. I've also updated the docs with the default behavior and
how to force a different Python version to be used.

Differential revision: https://reviews.llvm.org/D64894

llvm-svn: 366447
2019-07-18 15:17:42 +00:00
Serge Guelton ec2a7c463e Restrict asan + dlopen testcase to x86
llvm-svn: 366436
2019-07-18 13:47:28 +00:00
Serge Guelton 6a61bea4d6 Relax regexp to detect failed interception by asan
This should fix failed detection on aarch64/ppc64/thumbv8...

llvm-svn: 366432
2019-07-18 13:13:29 +00:00
Serge Guelton 63719119c7 Fix asan infinite loop on undefined symbol
Fix llvm#39641

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

llvm-svn: 366413
2019-07-18 08:09:31 +00:00
Peter Collingbourne 749f556bbd hwasan: Use C++ driver for cfi.cc test.
It turns out that this test was only passing by accident. It was relying on
the optimizer to remove the only reference to A's vtable by realizing that
the CFI check will always fail. The vtable contains a reference to RTTI in
libc++, which will be unresolved because the C driver won't link against it.

This was found by my prototype implementation of HWASAN for globals, which
happens to end up preserving the reference.

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

llvm-svn: 366389
2019-07-17 23:35:15 +00:00
Julian Lettner 9a050f92bb [ASan] Support `{f}puts(NULL)` on Darwin
On Darwin, the man page states that "both fputs() and puts() print
`(null)' if str is NULL."

rdar://48227136

Reviewed By: Lekensteyn

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

llvm-svn: 366342
2019-07-17 16:09:25 +00:00
Julian Lettner d069a19210 [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.6
Cleanup ARM64 assembly after removing unnecessary computation of mangled
stack pointer in previous commit.

llvm-svn: 366258
2019-07-16 20:41:04 +00:00
Mitch Phillips b157dcacb5 [GWP-ASan] Add thread ID to PRNG seed.
Summary:
Adds thread ID to PRNG seed for increased entropy. In particular, this allows
multiple runs in quick succession that will have different PRNG seeds, allowing
for better demos/testing.

Reviewers: kcc

Reviewed By: kcc

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 366253
2019-07-16 20:06:17 +00:00
Mitch Phillips 97b4d7a8e1 Removed -mno-omit-leaf-frame-pointer from flags.
Removes -mno-omit-leaf-frame-pointer from Scudo and GWP-ASan's CFlags. Attempt to fix
the sanitizer buildbots.

llvm-svn: 366228
2019-07-16 17:13:02 +00:00
Julian Lettner e6e33cf9f5 [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.10
Remove now-unused assembly code for determining xor key on
Linux/AArch64. This is the final commit of this refactoring.

llvm-svn: 366225
2019-07-16 16:22:04 +00:00
Stephan Bergmann e215996a29 Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"
i.e., recent 5745eccef54ddd3caca278d1d292a88b2281528b:

* Bump the function_type_mismatch handler version, as its signature has changed.

* The function_type_mismatch handler can return successfully now, so
  SanitizerKind::Function must be AlwaysRecoverable (like for
  SanitizerKind::Vptr).

* But the minimal runtime would still unconditionally treat a call to the
  function_type_mismatch handler as failure, so disallow -fsanitize=function in
  combination with -fsanitize-minimal-runtime (like it was already done for
  -fsanitize=vptr).

* Add tests.

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

llvm-svn: 366186
2019-07-16 06:23:27 +00:00
Julian Lettner c48162db99 [TSan] Fix asm token error (again)
llvm-svn: 366150
2019-07-15 23:05:14 +00:00
Matt Morehouse 8528b1951c [ASan] Fix >80 character line.
llvm-svn: 366136
2019-07-15 22:07:56 +00:00
Julian Lettner 228f80d92d [TSan] Fix asm token error
llvm-svn: 366131
2019-07-15 21:22:57 +00:00
Julian Lettner 39d888c1e4 [TSan] Improve handling of stack pointer mangling in {set,long}jmp, pt.9
Switch over to computing the xor key in C, instead of assembly for
Linux/AArch64.

llvm-svn: 366126
2019-07-15 20:22:27 +00:00
Matthew G McGovern 4885978e23 [sanitizers][windows][mingw32] Mingw32 RTL fixes
RTL interception broke mingw32, this should fix those builds by
removing dependency on windows.h

reviewed in https://reviews.llvm.org/D64694

llvm-svn: 366105
2019-07-15 18:42:14 +00:00
Diana Picus 0bf0b8ff7c [libFuzzer] Disable fork.test on AArch64
This crashes sporadically on our AArch64 buildbots. Disable for now.

llvm-svn: 366055
2019-07-15 11:33:41 +00:00
Julian Lettner 4f519b6919 [TSan] Tiny cleanup of UnmangleLongJmpSp for Linux/x86_64
NFC.

llvm-svn: 365982
2019-07-13 00:55:06 +00:00
Nikita Popov a205ebb09c [builtins] Fix assembly in arm sync-ops.h
This assembly is part of a macro that was reformatted in D60351.
The missing space between push and { results in:

    Error: bad instruction `push{r4, r5,r6,lr}'

llvm-svn: 365957
2019-07-12 20:52:02 +00:00
Rainer Orth 4a9a772f44 Enable compiler-rt on SPARC
This patch enables compiler-rt on SPARC targets. Most of the changes are straightforward:

- Add 32 and 64-bit sparc to compiler-rt

- lib/builtins/fp_lib.h needed to check if the int128_t and uint128_t types exist (which they don't on sparc)

There's one issue of note: many asan tests fail to compile on Solaris/SPARC:

fatal error: error in backend: Function "_ZN7testing8internal16BoolFromGTestEnvEPKcb": over-aligned dynamic alloca not supported.

Therefore, while asan is still built, both asan and ubsan-with-asan testing is disabled. The
goal is to check if asan keeps compiling on Solaris/SPARC. This serves asan in gcc,
which doesn't have the problem above and works just fine.

With this patch, sparcv9-sun-solaris2.11 test results are pretty good:

Failing Tests (9):
    Builtins-sparc-sunos :: divtc3_test.c
    Builtins-sparcv9-sunos :: compiler_rt_logbl_test.c
    Builtins-sparcv9-sunos :: divtc3_test.c
[...]
    UBSan-Standalone-sparc :: TestCases/TypeCheck/misaligned.cpp
    UBSan-Standalone-sparcv9 :: TestCases/TypeCheck/misaligned.cpp

The builtin failures are due to Bugs 42493 and 42496. The tree contained a few additonal
patches either currently in review or about to be submitted.

Tested on sparcv9-sun-solaris2.11.

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

llvm-svn: 365880
2019-07-12 08:30:17 +00:00
Rainer Orth 56f2f1cdb3 [Sanitizers] Fix SanitizerCommon-Unit :: ./Sanitizer-*-Test/MemoryMappingLayout.DumpListOfModules on Solaris
The MemoryMappingLayout.DumpListOfModules currently FAILs on Solaris:

  [ RUN      ] MemoryMappingLayout.DumpListOfModules
  /vol/llvm/src/compiler-rt/local/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc:52: Failure
  Value of: found
    Actual: false
  Expected: true
  [  FAILED  ] MemoryMappingLayout.DumpListOfModules (22 ms)

The problem is that the test expects the executable name from modules[i].full_name(),
however the pr_mapname field of struct prmap is just the entry in /proc/<pid>/object,
which is "a.out" instead of "Sanitizer-i386-Test".  Fortunately, the real name can
be determined by looking in proc/<pid>/path where "a.out" is a symlink to the
real path.

Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 365879
2019-07-12 08:27:50 +00:00
Artem Dergachev 8bd441af8b NFC: Unforget a colon in a few CHECK: directives.
Differential Revision: https://reviews.llvm.org/D64526

llvm-svn: 365863
2019-07-12 02:16:56 +00:00
Reid Kleckner 1a285c27fd Use clang driver for libfuzzer tests on Windows
Summary:
There's no real reason to use clang-cl on Windows, the clang driver
works just as well. This fixes a test which uses the -O0 flag, which was
recently removed from clang-cl to match MSVC, which lacks this flag.

While I'm here, remove the explicit -std=c++11 flag. Previously, this
flag was necessary when the default C++ standard was C++98. Now that the
default is C++14, this is no longer necessary. It's problematic on
Windows, because the Visual C++ standard library relies on C++14
features, and attempting to compile it with C++11 results in errors.
Rather than adding logic to conditionally set the standard to C++11 only
on non-Win, this flag can be removed.

See http://lab.llvm.org:8011/builders/clang-x64-windows-msvc and
https://reviews.llvm.org/D64506.

Reviewers: morehouse, thakis

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 365841
2019-07-11 23:20:04 +00:00
Kostya Kortchinsky 8f18a4c980 [scudo][standalone] NFC corrections
Summary:
A few corrections:
- rename `TransferBatch::MaxCached` to `getMaxCached` to conform with
  the style guide;
- move `getBlockBegin` from `Chunk::` to `Allocator::`: I believe it
  was a fallacy to have this be a `Chunk` method, as chunks'
  relationship to backend blocks are up to the frontend allocator. It
  makes more sense now, particularly with regard to the offset. Update
  the associated chunk test as the method isn't available there
  anymore;
- add a forgotten `\n` to a log string;
- for `releaseToOs`, instead of starting at `1`, start at `0` and
  `continue` on `BatchClassId`: in the end it's identical but doesn't
  assume a particular class id for batches;
- change a `CHECK` to a `reportOutOfMemory`: it's a clearer message

Reviewers: hctim, morehouse, eugenis, vitalybuka

Reviewed By: hctim

Subscribers: delcypher, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 365816
2019-07-11 19:55:53 +00:00
Julian Lettner 9d41429ff7 [TSan] Move DECLARE_REAL macro outside of namespace
This should fix the "undefined reference to
tsan::interception::real_setjmp" linker errors.

llvm-svn: 365806
2019-07-11 18:26:33 +00:00
Rainer Orth 9512c0a1d1 [profile][test] Fix Profile-* :: instrprof-merge.c etc. on SPARC
While working on https://reviews.llvm.org/D40900 (which effectively is about enabling compiler-rt on sparc these days), I came across two failing profile testcases:

  Profile-sparc :: instrprof-merge-match.test
  Profile-sparc :: instrprof-merge.c
  Profile-sparcv9 :: instrprof-merge-match.test
  Profile-sparcv9 :: instrprof-merge.c

All of them crashed with a SIGBUS in __llvm_profile_merge_from_buffer:

  Thread 2 received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 1 (LWP 1)]
  0x00012368 in __llvm_profile_merge_from_buffer (
      ProfileData=0x2384c <main.Buffer> "\377lprofR\201", ProfileSize=360)
      at /vol/llvm/src/llvm/local/projects/compiler-rt/lib/profile/InstrProfilingMerge.c:95
  95        SrcDataEnd = SrcDataStart + Header->DataSize;

where Header is insufficiently aligned for a strict-alignment target like SPARC.

Fixed by forcing the alignment to uint64_t, the members of struct __llvm_profile_header,
in the callers.

Tested on sparcv9-sun-solaris2.11.

https://reviews.llvm.org/D64498

llvm-svn: 365805
2019-07-11 18:26:24 +00:00
Mitch Phillips af3dc759e7 Explicitly define __STDC_FORMAT_MACROS for PRIu64
Summary:
Builds are failing on RHEL machines because of PRIu64.

lvm/projects/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp:420:50: error: expected ')'

`snprintf(ThreadBuffer, kThreadBufferLen, "%" PRIu64, ThreadID);`
inttypes.h in RHEL uses PRIu64 macros only when __STDC_FORMAT_MACROS is defined.

Author: DTharun

Reviewers: hctim

Reviewed By: hctim

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

llvm-svn: 365801
2019-07-11 18:07:03 +00:00
Kostya Kortchinsky aeb3826228 [scudo][standalone] Merge Spin & Blocking mutex into a Hybrid one
Summary:
We ran into a problem on Fuchsia where yielding threads would never
be deboosted, ultimately resulting in several threads spinning on the
same TSD, and no possibility for another thread to be scheduled,
dead-locking the process.

While this was fixed in Zircon, this lead to discussions about if
spinning without a break condition was a good decision, and settled on
a new hybrid model that would spin for a while then block.

Currently we are using a number of iterations for spinning that is
mostly arbitrary (based on sanitizer_common values), but this can
be tuned in the future.

Since we are touching `common.h`, we also use this change as a vehicle
for an Android optimization (the page size is fixed in Bionic, so use
a fixed value too).

Reviewers: morehouse, hctim, eugenis, dvyukov, vitalybuka

Reviewed By: hctim

Subscribers: srhines, delcypher, jfb, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 365790
2019-07-11 15:32:26 +00:00
Petr Hosek 274ad9c371 [ASan] Use __sanitizer_fill_shadow for FastPoisonShadow on Fuchsia
This is the optimized implementation for Fuchsia provided by the libc.

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

llvm-svn: 365739
2019-07-11 07:30:11 +00:00
Kamil Rytarowski 983d7ddd0b Add NetBSD LSan support
Summary:
Combine few relatively small changes into one:

 - implement internal_ptrace() and internal_clone() for NetBSD
 - add support for stoptheworld based on the ptrace(2) API
 - define COMPILER_RT_HAS_LSAN for NetBSD
 - enable tests for NetBSD/amd64

Inspired by the original implementation by Christos Zoulas in netbsd/src for GCC.

The implementation is in theory CPU independent through well defined macros
across all NetBSD ports, however only the x86_64 version was tested.

Reviewers: mgorny, dvyukov, vitalybuka, joerg, jfb

Reviewed By: vitalybuka

Subscribers: dexonsmith, jfb, srhines, kubamracek, llvm-commits, christos

Tags: #llvm

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

llvm-svn: 365735
2019-07-11 06:22:35 +00:00
Nico Weber e837847ec6 Change another test I missed in r365724
llvm-svn: 365725
2019-07-11 01:21:17 +00:00
Nico Weber da233838c9 clang-cl: Remove -O0 option
cl.exe doesn't understand it; there's /Od instead. See also the review
thread for r229575.

Update lots of compiler-rt tests to use -Od instead of -O0.
Ran `rg -l 'clang_cl.*O0' compiler-rt/test/ | xargs sed -i -c 's/-O0/-Od/'`

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

llvm-svn: 365724
2019-07-11 01:18:05 +00:00