Commit Graph

1976 Commits

Author SHA1 Message Date
Evgeniy Stepanov 610816f268 [asan] alloc_dealloc_mismatch=0 by default on Android.
All known (to me) Android deployments are disabling this flag anyway.
The in-tree script (asan_device_setup) does that, too.

llvm-svn: 281410
2016-09-13 22:25:44 +00:00
Evgeniy Stepanov 15934b86a1 [asan] Remove lit -j5 flag for android tests.
It makes the tests extremely slow due to high latency of the test launcher.
The main reason for -j5 was high memory usage with handle_abort=1, which
is now disabled in the test runner.

llvm-svn: 281409
2016-09-13 22:25:41 +00:00
Evgeniy Stepanov b48348fec5 [asan] Re-poison all redzones on activation.
When running with start_deactivated=1 in ASAN_OPTIONS, heap redzones
are not poisoned until the first instrumented module is loaded. This
can cause false negatives even on memory allocated after activation,
because redzones are normally poisoned only once when a new allocator
region is mapped.

This change attempts to fix it by iterating over all existing
allocator chunks and poisoning their redzones.

llvm-svn: 281364
2016-09-13 18:38:40 +00:00
Jonas Hahnfeld 161c7f8661 [asan] Add missing include for rand()
llvm-svn: 281342
2016-09-13 14:42:40 +00:00
Keno Fischer 8dc0e0943b [sanitizer] Add interceptor for ttyname_r
Reviewers: eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 281116
2016-09-09 23:09:34 +00:00
Evgeniy Stepanov 627d78f6c2 [asan] Disable handle_abort in Android tests.
The same thing is already done on Mac. handle_abort slows down tests
significantly because it triggers tombstone collection on Android;
also, it changes failed test outcome from "not-crash" to "crash" (as
in "bin/not --crash").

This change adds handle_abort=0 to asan options on android (test
only!), and also tweaks android_run.py to semi-correctly pass the
crash/no-crash status to the caller.

llvm-svn: 281075
2016-09-09 18:43:24 +00:00
Filipe Cabecinhas e3c7f54e93 [asan] Since r280945 fixed the OS X abort() problem, merge scariness_score_test.cc and make it a general test.
Summary: Merges back both scariness_score_test.cc files, since the Linux-specific version shouldn't be needed any more.

Reviewers: kcc, eugenis, vitalybuka

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 281048
2016-09-09 14:18:22 +00:00
Kostya Serebryany d77e8c0269 [sanitizer] fix a potential buffer overflow due to __sanitizer_symbolize_pc (need to put a zero after strncmp). LOL
llvm-svn: 281015
2016-09-09 02:13:27 +00:00
Qin Zhao 0ab52b97e8 Revert "[ESan][MIPS] Adds support for MIPS64"
Summary:
This reverts commit 62b3eecdbe72af0255f0639b0446087a47efbf48. (D23799)

The CL cause 13 ESan test failure on x86_64:
Failing Tests (13):
    EfficiencySanitizer-x86_64 :: TestCases/large-stack-linux.c
    EfficiencySanitizer-x86_64 :: TestCases/libc-intercept.c
    EfficiencySanitizer-x86_64 :: TestCases/mmap-shadow-conflict.c
    EfficiencySanitizer-x86_64 :: TestCases/struct-simple.cpp
    EfficiencySanitizer-x86_64 :: TestCases/verbose-simple.c
    EfficiencySanitizer-x86_64 :: TestCases/workingset-early-fault.c
    EfficiencySanitizer-x86_64 :: TestCases/workingset-memset.cpp
    EfficiencySanitizer-x86_64 :: TestCases/workingset-midreport.cpp
    EfficiencySanitizer-x86_64 :: TestCases/workingset-samples.cpp
    EfficiencySanitizer-x86_64 :: TestCases/workingset-signal-posix.cpp
    EfficiencySanitizer-x86_64 :: TestCases/workingset-simple.cpp
    EfficiencySanitizer-x86_64 :: Unit/circular_buffer.cpp
    EfficiencySanitizer-x86_64 :: Unit/hashtable.cpp

  Unexpected Failures: 13

Reviewers: bruening, slthakur

Subscribers: sdardis, kubabrecka, beanz

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

llvm-svn: 280954
2016-09-08 16:09:46 +00:00
Kuba Brecka 419ebb2891 [tsan] Support C++11 call_once in TSan on Darwin
This patch adds a wrapper for call_once, which uses an already-compiled helper __call_once with an atomic release which is invisible to TSan. To avoid false positives, the interceptor performs an explicit atomic release in the callback wrapper.

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

llvm-svn: 280920
2016-09-08 10:15:20 +00:00
Vitaly Buka b638c48819 [asan] Test that asan does not report use-after-scope if program jumped over variable declaration.
Summary:
Test to check if PR28267 workaround works.

PR28267
PR27453

Reviewers: eugenis

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 280908
2016-09-08 06:43:02 +00:00
Evgeniy Stepanov 337e40f157 [sanitizer] Fix a conflict between abort_on_error and handle_abort.
Reset the SIGABRT signal handler before calling abort().

Also, change the error message when catching SIGABRT to say "ABRT"
instead of "SEGV".

llvm-svn: 280885
2016-09-07 23:40:53 +00:00
Sagar Thakur 41f08b4422 [ESan][MIPS] Adds support for MIPS64
With this patch 10 out of 13 tests are passing.

Following is the list of failing tests:

    struct-simple.cpp
    workingset-signal-posix.cpp
    mmap-shadow-conflict.c

Reviewed by bruening
Differential: D23799

llvm-svn: 280795
2016-09-07 09:09:03 +00:00
Filipe Cabecinhas 3121ddf7fa [asan] Move scariness_score_test.cc to a common subdirectory
Summary:
Only one of the tests in it doesn't work on OS X.
On Windows it seems that everything that is being moved is also
supported.

The abort() test wasn't copied over (original case 22). This is because
it doesn't work on OS X.

Reviewers: kcc, eugenis, vitalybuka

Subscribers: kubabrecka, llvm-commits
llvm-svn: 280469
2016-09-02 07:18:35 +00:00
Reid Kleckner 0c4dd8de47 Un-XFAIL cfi/stats.cpp, it passes since fixing llvm-symbolizer to look for dwarf again
llvm-svn: 280422
2016-09-01 22:46:26 +00:00
Filipe Cabecinhas d2fb1e4a6c Revert "Copy over most of the scariness_score test to the general tests"
This reverts commit r280361 until we have the proper change in place.

llvm-svn: 280398
2016-09-01 18:40:12 +00:00
Chris Bieneman 5f2546273d [CMake] Adding compiler-rt-test-depends target
This exposes a target for building the compiler-rt test dependencies and matches llvm-test-depends.

llvm-svn: 280393
2016-09-01 18:26:51 +00:00
Renato Golin fbd3de7851 Try to fix another profile test
Another CFG optimisation patch (280364) has broken bad profile tests, and this
is a similar attempt to fix the test without changing the semantics.

llvm-svn: 280373
2016-09-01 14:44:02 +00:00
Renato Golin 0f298a2655 Fix profile test assuming dumb compiler
Commit r280364 has introduced some call-graph optmisations making a profiler
test "fail" due to not expecting the compiler to be "smart", and fold constants
across functions. This commit works around the issue, leaving the origial
semantics intact.

llvm-svn: 280365
2016-09-01 13:45:47 +00:00
Filipe Cabecinhas 6e903def8b Copy over most of the scariness_score test to the general tests
The abort() test wasn't copied over (original case 22). This is because
it doesn't work on OS X.

If theres no buildbot problem with this test later today, I will
minimize the Linux version.

llvm-svn: 280361
2016-09-01 12:29:13 +00:00
Reid Kleckner c213685f69 XFAIL cfi/stats.cpp on Windows until we fix our DIA usage
llvm-svn: 280106
2016-08-30 16:13:07 +00:00
Vasileios Kalintiris 7931529905 [mips][tsan] XFAIL on every MIPS platform an x86_64-specific test.
The map32bit.cc test uses the MMAP_32BIT flag which is supported only
on x86-64.

llvm-svn: 280084
2016-08-30 13:01:04 +00:00
Akira Hatanaka c80f7b866e [asan] Mark failing test as UNSUPPORTED.
llvm-svn: 280055
2016-08-30 03:10:19 +00:00
Vitaly Buka c84d4f5905 [asan] Disable test on darwin bot
According logs asan detects the bug but string with file name is not found.
I will investigate and fix the test.

llvm-svn: 280038
2016-08-30 00:57:40 +00:00
Vitaly Buka 98c3245dc9 [asan] Attempt to fix test on darwin bot
llvm-svn: 280026
2016-08-29 22:59:02 +00:00
Vitaly Buka ac644fa917 [asan] Remove runtime flag detect_stack_use_after_scope
Summary:
We are going to use store instructions to poison some allocas.
Runtime flag will require branching in instrumented code on every lifetime
intrinsic. We'd like to avoid that.

Reviewers: eugenis

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 279981
2016-08-29 17:16:59 +00:00
Akira Hatanaka 0b2628df1a [asan] Disable tests more selectively.
Add "target-arch+host-os" to the feature list to enable disabling the
tests I committed in r279614 and r279880 more selectively.

llvm-svn: 279918
2016-08-27 16:06:36 +00:00
Akira Hatanaka 56658af2cb [asan] Use "REQUIRES: x86_64-target-arch" to disable the test on i386.
My attempt to disable this test on i386 by adding "UNSUPPORTED: i386-apple"
in r279880 wasn't succesful, so I'm using REQUIRES instead.

llvm-svn: 279916
2016-08-27 05:57:50 +00:00
Kostya Serebryany 42034d009d [asan] restrict release_to_os_test.cc to x86_64
llvm-svn: 279898
2016-08-27 00:36:20 +00:00
Kostya Serebryany b72479b84a [asan] first attempt at releasing free-d memory back to the system using madvise. Requires quite some tuning.
llvm-svn: 279887
2016-08-26 23:58:42 +00:00
Akira Hatanaka 0ac01607b6 [asan] Mark symbolize_pc.cc as UNSUPPORTED on i386-apple.
atos currently doesn't work well when loaded from 32-bit binaries, which
was causing some of the bots to fail. Disable this test until we can
come up with a better fix.

llvm-svn: 279880
2016-08-26 23:08:28 +00:00
Dean Michael Berris f50eb93da7 [compiler-rt][XRay] Initial per-thread inmemory logging implementation
Depends on D21612 which implements the building blocks for the compiler-rt
implementation of the XRay runtime. We use a naive in-memory log of fixed-size
entries that get written out to a log file when the buffers are full, and when
the thread exits.

This implementation lays some foundations on to allowing for more complex XRay
records to be written to the log in subsequent changes. It also defines the format
that the function call accounting tool in D21987 will start building upon.

Once D21987 lands, we should be able to start defining more tests using that tool
once the function call accounting tool becomes part of the llvm distribution.

Reviewers: echristo, kcc, rnk, eugenis, majnemer, rSerge

Subscribers: sdardis, rSerge, dberris, tberghammer, danalbert, srhines, majnemer, llvm-commits, mehdi_amini

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

llvm-svn: 279805
2016-08-26 06:39:33 +00:00
Dean Michael Berris 510911f7bd Include tests only if COMPILER_RT_BUILD_XRAY is ON.
This should un-break users that have not re-generated their CMake
configs when they ran it when this was defaulted to OFF. Related to
r277975 post-commit review.

llvm-svn: 279802
2016-08-26 02:39:09 +00:00
Kostya Serebryany 7c5ae7cbc6 [sanitizer] enable random shuffling the memory chunks inside the allocator, under a flag. Set this flag for the scudo allocator, add a test.
llvm-svn: 279793
2016-08-26 00:06:03 +00:00
Kostya Serebryany 9aab75f697 [sanitizer] add __sanitizer_symbolize_pc. https://github.com/google/sanitizers/issues/322
llvm-svn: 279780
2016-08-25 21:35:29 +00:00
Kostya Serebryany 3a46def40c [lsan] one more test fix to please the Debian Sid bot (this time, confirmed on the proper machine). Apparently, newer glibc uses slightly more stack
llvm-svn: 279768
2016-08-25 19:08:10 +00:00
Adhemerval Zanella 1005b7d90c msan: Enable 48-bit VMA support on aarch64
This patch adds 48-bits VMA support for msan on aarch64. As current
mappings for aarch64, 48-bit VMA also supports PIE executable. The
48-bits segments only cover the usual PIE/default segments plus some
more segments (262144GB total, 0.39% total VMA). Memory avaliability
can be increase by adding multiple application segments like 39 and
42 mapping (some mappings were added on this patch as well).

Tested on 39 and 48-bit VMA kernels on aarch64.

llvm-svn: 279752
2016-08-25 17:05:56 +00:00
Kostya Serebryany db0fcdb03b [lsan] give a test a bit more stack -- it started failing after r279664 on the debian bot, hopefully this is a fix.
llvm-svn: 279674
2016-08-24 22:10:35 +00:00
Kostya Serebryany 6d03d84fac [ubsan] fix the test to me more resistent against changes in the sanitizer allocator
llvm-svn: 279661
2016-08-24 21:03:28 +00:00
Akira Hatanaka 1164cae527 [asan] Mark asan-symbolize-sanity-test.cc as UNSUPPORTED on x86_64-apple
and x86_64h-apple.

Mark the test as UNSUPPORTED to fix a bot that is failing.

http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check

The bot is failing because asan_symbolize.py cannot tell whether the
reported address is from an x86_64 slice or an x86_64h slice by the
length of the address alone, so it ends up passing the wrong arch to
atos.

rdar://problem/27907889

llvm-svn: 279614
2016-08-24 06:49:28 +00:00
Vitaly Buka 8176ee9b5d [asan] Rename asan-instrument-allocas -> asan-instrument-dynamic-allocas
Summary: Depends on D23707.

Subscribers: kubabrecka

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

llvm-svn: 279377
2016-08-20 17:22:36 +00:00
Chris Bieneman 5968c3ac1f [CMake] Add check-compiler-rt target for runtimes build
Durning standalone builds (which includes runtimes builds) we want to create a target named check-compiler-rt. Additionally we also create check-all if it doesn't already exist as a convienence target that depends on check-compiler-rt.

This allows us to generate a single check target that invokes lit for all test suites in the runtimes projects, while avoiding name collision of check-all and not breaking existing workflows.

llvm-svn: 279334
2016-08-19 22:17:48 +00:00
Vitaly Buka 8075b82322 [asan] Temporarily mark test as broken on Windows
llvm-svn: 279318
2016-08-19 20:48:09 +00:00
Vitaly Buka 3efaaeb79d [asan] Add one more test for __asan_set_shadow_*
Reviewers: eugenis, filcab

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 279108
2016-08-18 18:15:15 +00:00
Oleg Ranevskyy 8a8b7b6df7 [compiler-rt][tests] cpu_model_test.c test fails to compile if X86 is not clang's default target
Summary:
test/builtins/Unit/cpu_model_test.c tests the X86 specific builtin `__builtin_cpu_supports`.
It fails if the clang's default target is not X86.

The proposed patch adds an additional requirement for the X86 target to the test, making lit ignore the test if the target is different.

Reviewers: asbirlea

Subscribers: dberris, llvm-commits

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

llvm-svn: 279071
2016-08-18 14:39:39 +00:00
Daniel Sanders 93c0f382b4 [mips][msan] Fix all the XPASSes following r278793 and r278795
All msan tests are now passing for mipsel and mips64el except for
allocator_mapping.cc which is marked unsupported.

llvm-svn: 279048
2016-08-18 10:50:46 +00:00
Sagar Thakur 49307c0297 [MSAN][MIPS] Changed memory mapping to support pie executable.
Reviewed by eugenis
Differential: D22993

llvm-svn: 278793
2016-08-16 12:49:54 +00:00
Sagar Thakur 19b84a0224 [TSan][MIPS] Implements setjmp assembly for MIPS64
Reviewed by dvyukov
Differential: https://reviews.llvm.org/D23494

llvm-svn: 278775
2016-08-16 05:06:56 +00:00
Daniel Sanders edfed3deeb [msan] Correct @LINE expression in obstack.cc
Summary:

[[@LINE-30]] only worked because the resulting 3 matches the first character of
30. With the additional blank lines the resulting 5 no longer matches 30.

Reviewers: eugenis

Subscribers: eugenis, llvm-commits

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

llvm-svn: 278715
2016-08-15 18:56:54 +00:00
Daniel Sanders dab0556112 [msan] Fix line number sensitivity in chained_origin.cc and chained_origin_memcpy.cc
Reviewers: eugenis

Subscribers: eugenis, llvm-commits

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

llvm-svn: 278712
2016-08-15 18:50:36 +00:00
Daniel Sanders 67f22ee24a [mips] XFAIL mips64el tests that fail on clang-cmake-mipsel
These tests were recently enabled and have never worked on this builder.

Three tests were sensitive to line number changes:
  test/msan/Linux/obstack.cc
  test/msan/chained_origin.cc
  test/msan/chained_origin_memcpy.cc
and this sensitivity will be addressed in a follow-up patch. Of these,
obstack.cc's sensitivity to line numbers is unexplained since it already uses
[[@LINE]].

llvm-svn: 278671
2016-08-15 15:14:08 +00:00
Ivan Krasin 88661f55c3 Add compiler-rt side test for no_sanitize("cfi") attribute
Summary: Add a test case for __attribute__((no_sanitize("cfi"))) being effective.

Reviewers: kcc

Subscribers: dberris

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

llvm-svn: 278530
2016-08-12 17:26:37 +00:00
Daniel Sanders 875671185e [mips] Remove obstack.cc XFAIL added in r278504 since it broke X86 and PPC somehow.
Adding the XFAIL has caused msan to report a different line number in the call
stack (@LINE-3 rather than @LINE-30). The new line number looks more correct
at first glance since it's the line that uses uninitialized memory rather than
the first non-whitespace line of the file but this needs investigating.

llvm-svn: 278516
2016-08-12 15:34:35 +00:00
Daniel Sanders 6a540c1f38 [mips] XFAIL the new mips64el compiler-rt tests that fail on clang-cmake-mipsel.
The mips64el compiler-rt build has recently been enabled. XFAIL the failing
tests to make the buildbot green again.

The two asan tests require the integrated assembler. This will be fixed soon
for Debian mips64el but not for any other mips64el targets since doing so
requires triple-related issues to be fixed..
The msan tests are largely failing because caused by a kernel update (a patch
has already been posted for this).
I'm not sure why the dfsan test fails yet.

llvm-svn: 278504
2016-08-12 11:56:36 +00:00
Evgeniy Stepanov 851378831e [asan] abort_on_error=1 by default on Android.
With this change, the default behavior on error is to call abort()
instead of _exit(). This should help the OS to capture a tombstone of
the error.

RAM usage of the lit test suite goes up because of all the tombstone
gathering, so I'm limiting the parallelism of the test target.
Previously it was based on the number of the CPUs on the host
machine, which is definitely wrong.

llvm-svn: 278308
2016-08-11 00:26:29 +00:00
Vedant Kumar 5e3c5e8065 [test] Update coverage tests to sync up with r278152
This should fix the following bot failure:

  http://lab.llvm.org:8011/builders/clang-ppc64le-linux/builds/6522

Patch by Ying Yi!

llvm-svn: 278164
2016-08-09 21:04:22 +00:00
Daniel Sanders dc213305e9 [sanitizers] Make it possible to XFAIL on the effective target, not just the default.
Summary:
The triple is not the right thing to XFAIL on since LIT only sees the default
triple and not the effective triple chosen by any -target option in the RUN
directives. This discrepancy is shown in the table below:

  Default Triple   | Options                           | XFAIL  | LIT's expected result | Desired expectation
  =================+===================================+========+=======================+====================
  mips-linux-gnu   | -target mips-linux-gnu            |        | Pass                  | Pass  
  mips-linux-gnu   | -target mips64-linux-gnu -mabi=64 |        | Pass                  | Pass  
  mips-linux-gnu   | -target mips-linux-gnu            | mips   | Fail                  | Fail  
  mips-linux-gnu   | -target mips64-linux-gnu -mabi=64 | mips   | Fail                  | Fail/Pass* (debatable**)
  mips-linux-gnu   | -target mips-linux-gnu            | mips-  | Fail                  | Fail  
  mips-linux-gnu   | -target mips64-linux-gnu -mabi=64 | mips-  | Fail                  | Pass* 
  mips-linux-gnu   | -target mips-linux-gnu            | mips64 | Pass                  | Pass  
  mips-linux-gnu   | -target mips64-linux-gnu -mabi=64 | mips64 | Pass                  | Fail* 
  mips64-linux-gnu | -target mips-linux-gnu            |        | Pass                  | Pass  
  mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 |        | Pass                  | Pass  
  mips64-linux-gnu | -target mips-linux-gnu            | mips   | Fail                  | Fail* 
  mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips   | Fail                  | Fail/Pass (debatable**)
  mips64-linux-gnu | -target mips-linux-gnu            | mips-  | Pass                  | Fail* 
  mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips-  | Pass                  | Pass  
  mips64-linux-gnu | -target mips-linux-gnu            | mips64 | Fail                  | Pass* 
  mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips64 | Fail                  | Fail  
  x64_64-linux-gnu | -target i386-linux-gnu            |        | Pass                  | Pass
  x64_64-linux-gnu | -target x86_64-linux-gnu          |        | Pass                  | Pass
  x64_64-linux-gnu | -target i386-linux-gnu            | i386   | Pass                  | Fail*
  x64_64-linux-gnu | -target x86_64-linux-gnu          | i386   | Pass                  | Pass
  x64_64-linux-gnu | -target i386-linux-gnu            | x86_64 | Fail                  | Pass
  x64_64-linux-gnu | -target x86_64-linux-gnu          | x86_64 | Fail                  | Fail*
  * These all differ from LIT's current behaviour.
  ** People's expectations vary depending on whether they know that LIT does a
   substring match on the default triple or think it's an exact match on an
   architecture.

This patch adds "target-is-${target_arch}" to the available features list and
updates the mips XFAIL's to use them. XFAIL'ing on these features will
correctly account for the target being tested. Making the table:

  Options                           | XFAIL            | LIT's expected result
  ==================================+==================+======================
  -target mips-linux-gnu            |                  | Pass
  -target mips64-linux-gnu -mabi=64 |                  | Pass
  -target mips-linux-gnu            | target-is-mips   | Fail
  -target mips64-linux-gnu -mabi=64 | target-is-mips   | Pass
  -target mips-linux-gnu            | target-is-mips64 | Pass
  -target mips64-linux-gnu -mabi=64 | target-is-mips64 | Fail
  -target i386-linux-gnu            |                  | Pass
  -target x86_64-linux-gnu          |                  | Pass
  -target i386-linux-gnu            | target-is-i386   | Fail
  -target x86_64-linux-gnu          | target-is-i386   | Pass
  -target i386-linux-gnu            | target-is-x86_64 | Pass
  -target x86_64-linux-gnu          | target-is-x86_64 | Fail

Reviewers: probinson

Subscribers: probinson, kubabrecka, llvm-commits, samsonov

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

llvm-svn: 278116
2016-08-09 11:50:53 +00:00
Xinliang David Li 3b2c002c6d [Profile] Implement new API __llvm_profile_dump
The API is intended to be used by user to do fine
grained (per-region) control of profile dumping.

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

llvm-svn: 278092
2016-08-09 04:21:14 +00:00
Derek Bruening 3ee803a895 [esan] Add iterator to esan's generic hashtable
Summary: Adds simple iterator support to the esan hashtable.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 278027
2016-08-08 17:37:19 +00:00
Derek Bruening 84df6be883 [esan] Add generic resizing hashtable
Summary:
Adds a new, generic, resizing hashtable data structure for use by esan
tools.  No existing sanitizer hashtable is suitable for the use case for
most esan tools: we need non-fixed-size tables, parameterized keys and
payloads, and write access to payloads.  The new hashtable uses either
simple internal or external mutex locking and supports custom hash and
comparision operators.  The focus is on functionality, not performance, to
catalyze creation of a variety of tools.  We can optimize the more
successful tools later.

Adds tests of the data structure.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 278024
2016-08-08 17:25:40 +00:00
Dean Michael Berris 97c363fbfe [compiler-rt][XRay] Only add xray dependency if XRay is built and is available for the platform
llvm-svn: 277983
2016-08-08 05:49:29 +00:00
Dean Michael Berris 26cc6628f7 [compiler-rt][XRay] Fix XRay test build dependencies
llvm-svn: 277974
2016-08-08 03:42:11 +00:00
Dean Michael Berris 68e74847bf [compiler-rt][XRay] Implement __xray_unpatch() and __xray_remove_handler()
Summary:
We also add one test (and the XRay testing infrastructure) to exercise
the patching and unpatching code. This uses the XRay API exported
through the headers as well, installing a custom log handler.

Depends on D23101 for the updated emitted code alignment for the
return/entry sleds.

Reviewers: rSerge, echristo, rnk

Subscribers: tberghammer, danalbert, srhines, mehdi_amini, llvm-commits

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

llvm-svn: 277971
2016-08-08 03:10:22 +00:00
Reid Kleckner c209664b07 Try to fix the ill.cc test on Linux
llvm-svn: 277898
2016-08-06 00:57:58 +00:00
Reid Kleckner 2a38531eca Use %stdcxx11 instead of -std=c++11 so the test passes with VS 2015
llvm-svn: 277894
2016-08-06 00:37:14 +00:00
Reid Kleckner 9cba2e2d97 Fix two tests in Win64 ASan
Go back to intercepting kernel32!RaiseException, and only go for
ntdll!RtlRaiseException if that fails. Fixes throw_and_catch.cc test.

Work around an issue in LLVM's win64 epilogues. We end up with an
epilogue that looks like this, and it drives the Win64 unwinder crazy
until stack overflow:
        call    ill_cc!__asan_handle_no_return
        xor     eax,eax
        add     rsp,40h // epilogue starts
        pop     rbp     // CSR
        ud2             // Trap here
        ret             // Ret?
        nop     word ptr [rax+rax]
        sub     rsp,28h // Next function

Will file a PR soon.

llvm-svn: 277874
2016-08-05 21:47:46 +00:00
Mike Aizatsky ef70ae9036 [sanitizers] remove failing test.
The test often fails on Windows because there are more branches
in the code that is generated.

llvm-svn: 277862
2016-08-05 20:48:48 +00:00
Mike Aizatsky 04897dcc3d [sanitizers] trace buffer API to use user-allocated buffer.
Subscribers: kubabrecka

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

llvm-svn: 277858
2016-08-05 20:09:42 +00:00
Reid Kleckner 628d6b5c81 Fix dumping of process module list and test it
I probably broke this a year ago in r243895.

llvm-svn: 277842
2016-08-05 17:55:00 +00:00
Ivan Krasin 8de920cf0e Reverting r277632 as it breaks the build on MacOS.
Reviewers: kcc

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

llvm-svn: 277798
2016-08-05 03:18:27 +00:00
Ivan Krasin a425623dd9 CFI: add XFAIL test for a future optimization of two vcalls.
Summary:
Often, a code will call multiple virtual methods of a given object.
If they go in a linear block, it should be possible to check vtable
before the first call, then store vtable pointer and reuse it for
the second vcall without any additional checks.

This is expected to have a positive performance impact on a hot
path in Blink, see https://crbug.com/634139.

Reviewers: kcc

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

llvm-svn: 277795
2016-08-05 01:45:54 +00:00
Bruno Cardoso Lopes 4e786cf3de [ASAN] Mark test/asan/TestCases/ill.cc as unsupported on darwin
Introduced in r277621, this test is currently failing all around in
public bots: http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/20787
and internal bots. Mark it as unsupported on darwin until we figure
out how it should behave.

llvm-svn: 277733
2016-08-04 15:57:30 +00:00
Bruno Cardoso Lopes 3076db8da0 [Darwin] Exclude interception union tests on Darwin and Android
Since the directory is empty on Darwin, disable the inclusion and avoid
the warning below. Exclude on Android as well to match the behavior from
lib/interception/tests/CMakeLists.txt

lit.py:
/Users/buildslave/jenkins/sharedspace/clang-R_master@2/llvm/utils/lit/lit/discovery.py:224:
warning: input
'/Users/buildslave/jenkins/sharedspace/clang-R_master@2/clang-build/Build/tools/clang/runtime/compiler-rt-bins/test/interception/Unit'
contained no tests

This fixes the above warning in some of public bots, like
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/8686

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

rdar://problem/27581108

llvm-svn: 277692
2016-08-04 04:46:39 +00:00
Reid Kleckner 15a3ce0f59 Only run ill.cc test on x86, 32 or 64 bit
llvm-svn: 277679
2016-08-03 23:24:06 +00:00
Ivan Krasin 9535cebb71 Add CFI tests for -lowertypetests-bitsets-level.
Summary:
-lowertypetests-bitsets-level controls which kinds of bitsets
are generated, as introduced in r277556. This change adds tests
to compiler-rt.

Reviewers: kcc

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

llvm-svn: 277632
2016-08-03 19:08:55 +00:00
Reid Kleckner 222610bf10 [ASan] Report illegal instruction exceptions in ASan
Summary:
Respect the handle_sigill common flag and handle_segv flags while we're
at it.

We still handle signals/exceptions differently on Unix and Windows. The
installation process is tricky on Windows, and difficult to push down
into sanitizer_common without concerning it with the different
static/dynamic CRT models on Windows.

Reviewers: kcc, etienneb

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 277621
2016-08-03 18:13:14 +00:00
Kostya Serebryany 707894b092 [sanitizer] Implement a __asan_default_options() equivalent for Scudo
Summary:
Currently, the Scudo Hardened Allocator only gets its flags via the SCUDO_OPTIONS environment variable.
With this patch, we offer the opportunity for programs to define their own options via __scudo_default_options() which behaves like __asan_default_options() (weak symbol).
A relevant test has been added as well, and the documentation updated accordingly.
I also used this patch as an opportunity to rename a few variables to comply with the LLVM naming scheme, and replaced a use of Report with dieWithMessage for consistency (and to avoid a callback).

Reviewers: llvm-commits, kcc

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

llvm-svn: 277536
2016-08-02 22:25:38 +00:00
Reid Kleckner d6371ea52a [asan] Intercept RtlRaiseException instead of kernel32!RaiseException
Summary:
On my install of Windows 10, RaiseException is a tail call to
kernelbase!RaiseException. Obviously, we fail to intercept that.
Instead, try hooking at the ntdll!RtlRaiseException layer. It is
unlikely that this layer will contain control flow.

Intercepting at this level requires adding a decoding for
'LEA ESP, [ESP + 0xXXXXXXXX]', which is a really obscure way to write
'SUB ESP, 0xXXXXXXXX' that avoids clobbering EFLAGS.

Reviewers: etienneb

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 277518
2016-08-02 20:36:29 +00:00
Reid Kleckner dabcee8b2c Remove stale CHECK lines that should have been included in r277478
We no longer assign ids to unregistered threads. We don't have any stack
trace for thread creation for these worker threads, so this shouldn't
affect report quality much.

llvm-svn: 277514
2016-08-02 20:26:59 +00:00
Reid Kleckner b0e4a86e05 [asan] Remove NtWaitForWorkViaWorkerFactory interceptor
Summary:
On Windows 10, this gets called after TLS has been torn down from NTDLL,
and we crash attempting to return fake_tsd. This interceptor isn't
needed after r242948 anyway, so let's remove it. The ASan runtime can
now tolerate unregistered threads calling __asan_handle_no_return.

Reviewers: vitalybuka, etienneb

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 277478
2016-08-02 16:17:32 +00:00
Kuba Brecka 3a748d6067 [tsan] Fix the behavior of OSAtomicTestAndClear
The system implementation of OSAtomicTestAndClear returns the original bit, but the TSan interceptor has a bug which always returns zero from the function. This patch fixes this and adds a test.

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

llvm-svn: 277461
2016-08-02 14:30:52 +00:00
Kuba Brecka b5a60ec7fe [tsan] Fix behavior of realloc(nullptr, 0) on Darwin
On Darwin, there are some apps that rely on realloc(nullptr, 0) returning a valid pointer. TSan currently returns nullptr in this case, let's fix it to avoid breaking binary compatibility.

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

llvm-svn: 277458
2016-08-02 14:22:12 +00:00
Xinliang David Li 24a927b3c2 improve test cases to fix bot failure
llvm-svn: 277403
2016-08-01 23:20:30 +00:00
Evgeniy Stepanov 6c25e57a56 [asan] Disable android-coverage test on anything other than arm.
llvm-svn: 277395
2016-08-01 21:58:34 +00:00
Xinliang David Li e594277683 Make test more robust with better matching
llvm-svn: 277387
2016-08-01 21:06:54 +00:00
Xinliang David Li 7380a0d4a6 [Profile] Add new test case to cover comdat renaming
Test checks that context specific profiles for comdat functions
are not lost.

llvm-svn: 277381
2016-08-01 20:28:26 +00:00
Maxim Ostapenko 9f0546b5a9 [asan] Reduce flakiness of heavy recovery mode tests.
When we run halt_on_error-torture.cc with 10 threads and 20 iterations with halt_on_error=false:suppress_equal_pcs=false, we write 200 reports to 10.txt file and sometimes have collisions.
We have CHECK-COLLISION check that greps 'AddressSanitizer: nested bug in the same thread, aborting' message in 10.txt, but it doesn't contain this line.
If I don't redirect stderr > 10.txt 'AddressSanitizer: nested bug in the same thread, aborting' is printed to my screen as expected.
Same happens for halt_on_error_suppress_equal_pcs.cc and halt_on_error-torture.cc. This happens because of kernel bug: https://lkml.org/lkml/2014/2/17/324
Furtunately, we can fix these tests by implicitly setting O_APPEND for opened files (use >> instead of > for stderr redirection).

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

llvm-svn: 277324
2016-08-01 07:24:36 +00:00
Xinliang David Li 52626f132c Fix a bug in lit var def: remove extra space
llvm-svn: 277312
2016-08-01 01:54:40 +00:00
Dimitry Andric 41d9b3640c Fix ASan alloca_constant_size.cc test on FreeBSD.
On FreeBSD <alloca.h> does not exist: alloca(3) is defined in <stdlib.h>
instead.

llvm-svn: 277300
2016-07-31 20:16:59 +00:00
Xinliang David Li f418bb8023 [Profile] Add a new test case
The end-end test checks that cs-profile counter update
is obtained as expected.

llvm-svn: 277276
2016-07-30 20:12:00 +00:00
Vitaly Buka 49dd9d23cc [asan] Enable the rest of use-after-scope tests
Summary:
Test where broken because of missing lifetime markers for temps and
because of aggressive optimization which removed markers in some cases.

PR27453

Reviewers: eugenis, kcc

Subscribers: llvm-commits, kubabrecka

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

llvm-svn: 277074
2016-07-28 23:03:27 +00:00
Etienne Bergeron a07ce512eb [compiler-rt] Activate interception unittests
Summary:
The unittests recently added were not running when executing 'check-all'.
Tests are stable on every archictetures and we can now turn them on.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, chrisha

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

llvm-svn: 276881
2016-07-27 15:29:49 +00:00
Dmitry Vyukov 246e0283d4 tsan: don't deliver signals when they are blocked
When we delay signals we can deliver them when the signal
is blocked. This can be surprising to the program.
Intercept signal blocking functions merely to process
pending signals. As the result, at worst we will delay
a signal till return from the signal blocking function.

llvm-svn: 276876
2016-07-27 14:34:21 +00:00
Xinliang David Li 6f6825fe13 Fix buildbot failure
llvm-svn: 276512
2016-07-23 03:34:30 +00:00
Xinliang David Li 54bb751a87 [Profile] Tighten test with expected profile count
llvm-svn: 276500
2016-07-22 23:53:00 +00:00
Xinliang David Li 544ae6c4f3 [Profile] Fix a fixme in the test
llvm-svn: 276494
2016-07-22 23:44:06 +00:00
Xinliang David Li 5a6dc4c9b8 [Profile] Add new test
To test that online merging is enabled by default.

llvm-svn: 276493
2016-07-22 23:38:58 +00:00
Reid Kleckner ff3ea5f4f8 Try to fix more Windows portability issues in sanitizer tests
Add a %stdcxx11 lit substitution for -std=c++11. Windows defaults to
-std=c++14 when VS 2015 is used because the STL requires it. Harcoding
-std=c++11 in the ASan tests actually downgrades the C++ standard level,
leading to test failures.

Relax a FileCheck pattern in use-after-scope-types.cc.

Disable the sanitizer_common OOM tests. They fail on bots with low swap,
and cause other concurrently running tests to OOM.

llvm-svn: 276454
2016-07-22 18:41:22 +00:00
Reid Kleckner 9b63e25de4 [sanitizers] Enable sanitizer_common tests on Win64
llvm-svn: 276440
2016-07-22 17:14:31 +00:00
Vitaly Buka 43efcced31 Fix test on windows, symbolizer returns invalid line
llvm-svn: 276381
2016-07-22 01:47:28 +00:00
Kostya Serebryany 8258686922 [asan] revert to using -std=c++11 on test/asan/TestCases/use-after-scope-capture.cc to fix Linux failures after r276332. This probably breaks the windows build, sorry, but returns to the earlier status quo.
llvm-svn: 276379
2016-07-22 01:34:32 +00:00
Vitaly Buka 60cb0b55c9 fix windows
llvm-svn: 276378
2016-07-22 01:34:12 +00:00
Vitaly Buka be6328b078 Fix test on windows
llvm-svn: 276376
2016-07-22 01:12:04 +00:00
Vitaly Buka 0a3e932e1d Add test to check detection of stack-use-after-scope on various types
Summary:
Test for D22657

PR27453

Reviewers: kcc, eugenis

Subscribers: kubabrecka

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

llvm-svn: 276375
2016-07-22 00:58:06 +00:00
Xinliang David Li e953933a9f [Profile] deprecate __llvm_profile_override_default_filename (part2)
This eliminates unncessary calls and init functions.

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

llvm-svn: 276355
2016-07-21 23:19:18 +00:00
Reid Kleckner 1558a2f3ee [asan] Fix Win64 test portability issues
The OOM test should really only run on 32-bits, since it's hard to OOM
on x64.

The operator_array_new_with_dtor_left_oob tests need to account for the
larger array cookie on x64 (8 bytes instead of 4).

Use -std=c++14 in use-after-scope-capture.cc to avoid errors in the MSVC
2015 STL on Windows. The default there is C++14 anyway.

llvm-svn: 276332
2016-07-21 21:04:34 +00:00
Etienne Bergeron 1acbc5207d Fix unsymbolize unittest. Adding win64 address.
llvm-svn: 276326
2016-07-21 20:02:03 +00:00
Etienne Bergeron 29539a0b7d [compiler-rt] Fix interception of memcpy/memmove on win64
Summary:
This patch is fixing running interception unittests for memcpy/memmove on
windows 64.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, kubabrecka, chrisha

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

llvm-svn: 276324
2016-07-21 19:49:11 +00:00
Etienne Bergeron c6b096572e [compiler-rt] Disable some unittests on windows that rely on shell command
Summary:
These unittests are not running on windows because they are using incorrect commands.
They were not failing on 32-bits because there is a requirement: asan-64-bits.

```
$ "nm" "C:\src\llvm\ninja64\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Output\no_asan_gen_globals.c.tmp.exe"
# command stderr:
'nm': command not found
error: command failed with exit status: 127
```

```
$ "rm" "-rf" "C:\src\llvm\ninja64\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Output/coverage-tracing"
$ "mkdir" "C:\src\llvm\ninja64\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Output/coverage-tracing"
$ "A=x"
# command stderr:
'A=x': command not found
error: command failed with exit status: 127
```


```
$ "DIR=C:\src\llvm\ninja64\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Output/coverage-order-pcs"
# command stderr:
'DIR=C:\\src\\llvm\\ninja64\\projects\\compiler-rt\\test\\asan\\X86_64WindowsConfig\\TestCases\\Output/coverage-order-pcs': command not found
error: command failed with exit status: 127
```

Reviewers: rnk

Subscribers: tberghammer, llvm-commits, danalbert, wang0109, srhines, kubabrecka, chrisha

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

llvm-svn: 276290
2016-07-21 14:55:17 +00:00
Etienne Bergeron 65e38a53b3 [compiler-rt] Fix broken unittest on win64
Summary:
This is an other tentative to fix:
https://reviews.llvm.org/D22588

It's less clever, but should work.

Turn out there is not an easy way to write a portable print
for a pointer in lowercase without the prefix 0x.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, kubabrecka, chrisha

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

llvm-svn: 276286
2016-07-21 14:36:25 +00:00
Xinliang David Li fa7c6f0d84 [Profile] Add new test to cover %m specifier with shared library (instrumented)
llvm-svn: 276229
2016-07-21 02:58:28 +00:00
Etienne Bergeron d4528b2ea1 [compiler-rt] Fix broken SymInitialize unittest
Summary:
By adding the initialisation of the symbolisation library (DbgHelp)
we are swapping the order in which both warnings are produced.

We can't use CHECK-NEXT as the dbghelp warning is multiline.

Reviewers: rnk

Subscribers: kubabrecka, llvm-commits, wang0109, chrisha

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

llvm-svn: 276228
2016-07-21 02:32:37 +00:00
Xinliang David Li ab8d32d53a [Profile] More test clean up to read profile from directory specified by -fprofile-generate=
llvm-svn: 276226
2016-07-21 02:14:55 +00:00
Xinliang David Li f6b2ba687b [Profile] Cleanup test to use new dir input feature
llvm-svn: 276225
2016-07-21 01:53:41 +00:00
Etienne Bergeron 913feb2a0d revert rL276179: [compiler-rt] Fix broken unittest related to 64-bit print format
llvm-svn: 276187
2016-07-20 21:38:02 +00:00
Etienne Bergeron 0e4cf2f6b3 [compiler-rt] Fix broken unittest related to 64-bit print format
Summary:
The printf is not working correctly on 64-bit MSVC.

The portable way to print "size_t" is to use "%zx" (size_t in hexa).

Reviewers: rnk

Subscribers: kubabrecka, llvm-commits, wang0109, chrisha

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

llvm-svn: 276179
2016-07-20 20:55:02 +00:00
Etienne Bergeron 055bdb96f5 fix flaky test on windows sanitizer bots
llvm-svn: 276143
2016-07-20 17:35:15 +00:00
Kostya Serebryany 018259cd9b [asan] trying to fix the android bot
llvm-svn: 276134
2016-07-20 15:59:34 +00:00
Reid Kleckner bcb927ffc2 Try to deflake Windows/dll_host.cc test by not using repeated echo appending
llvm-svn: 276130
2016-07-20 15:28:49 +00:00
Etienne Bergeron 6de4bd62b1 [compiler-rt/asan] Disable irrelevant unittest on win64
Summary:
This test is allocating a 1gig chunk to make shadow allocation failed,
but on 64-bits architecture the test is working.

Reviewers: rnk

Subscribers: kubabrecka, llvm-commits, wang0109, chrisha

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

llvm-svn: 276122
2016-07-20 14:53:17 +00:00
Xinliang David Li eaf238d494 [Profile] implement interface to get profile path prefix
Differential Revision:  http://reviews.llvm.org/D22546

llvm-svn: 276083
2016-07-20 04:26:09 +00:00
Xinliang David Li 5d2ea9dcf8 [Profile] Test cleanup -- use new lit var for IR PGO tests /NFC
llvm-svn: 276036
2016-07-19 22:12:00 +00:00
Xinliang David Li f26e1d9fb5 [Profile] Introduce lit test vars for IR based instrumentation
llvm-svn: 276034
2016-07-19 21:55:55 +00:00
Kostya Serebryany 1abc356e3e [asan] trying to fix the android bot
llvm-svn: 276031
2016-07-19 21:35:01 +00:00
Vitaly Buka 9f9c089fe2 Add detect_stack_use_after_scope runtime flag
Summary: This flag could be used to disable check in runtime.

Subscribers: kubabrecka

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

llvm-svn: 276004
2016-07-19 18:11:08 +00:00
Etienne Bergeron 83cc0622ec [compiler-rt] Fix Asan imports/exports unittest
Summary:
Avoid mismatch between imports/exports for 32-bit and 64-bits version.

The test is running grep over macros to detect which functions are
intercepted. Unfortunately, exception handlers differ in 32-bit and
64-bit.

This patch is removing the exception handlers from the test.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, kubabrecka, chrisha

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

llvm-svn: 275982
2016-07-19 15:27:23 +00:00
Derek Bruening 0fc992442c [esan|wset] Fix flaky sampling tests
Adds a new esan public interface routine __esan_get_sample_count() and uses
it to ensure that tests of sampling receive the minimum number of samples.

llvm-svn: 275948
2016-07-19 05:06:48 +00:00
Kostya Serebryany 4953a01461 [asan] trying to fix the windows build
llvm-svn: 275644
2016-07-15 23:13:03 +00:00
Kostya Serebryany ad0724692e [sanitizers] add interceptor for memmem; add weak hooks for strncasecmp, strcasecmp, strstr, strcasestr, memmem
llvm-svn: 275621
2016-07-15 21:28:58 +00:00
Maxim Ostapenko 26b0bc0bd6 [asan] Reduce flakiness of halt_on_error-torture.cc testcase.
It seems in some situations we have clashes on very first error so test only prints "nested bug in the same thread, aborting" rather than "use-after-poison", so remove corresponding " RUN: FileCheck %s < 10.txt" line.
Also, the two last " RUN: FileCheck --check-prefix=CHECK-COLLISION %s < 1.txt || FileCheck --check-prefix=CHECK-NO-COLLISION %s < 1.txt" look wrong, they should check 10.txt. Fix these lines too.

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

llvm-svn: 275539
2016-07-15 07:57:43 +00:00
Etienne Bergeron 47ea8f536d [compiler-rt] Fix missing argument in asan unittest
Summary:
Both test have the same command-line.
The second test is missing the /GS-.

Keep in mind that /GS is on by default.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, kubabrecka, chrisha

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

llvm-svn: 275491
2016-07-14 22:16:31 +00:00
Alina Sbirlea 36f57fbc66 Add runtime support for __cpu_model (__builtin_cpu_supports)
Summary:
    This aims to add support for __cpu_model and address Bug 25510. It uses
    the code from lib/Support/Host.cpp for cpu detection, and creates
    __cpu_model with that info.

    Tested on OSX and built on Linux as well (though libgcc is the default).
    The use of "asm" required -std=gnu99, hence the cmake change. Corrections
    on better addressing this are welcome.

    Previously reverted, up for review again to iron out outstanding issues.

Reviewers: llvm-commits, joerg, echristo, mehdi_amini

Subscribers: mehdi_amini

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

llvm-svn: 275484
2016-07-14 22:02:35 +00:00
Vitaly Buka 0ba360bd68 Replace -mllvm -asan-use-after-scope=1 with -fsanitize-address-use-after-scope
Summary:
When test was added we had no -fsanitize-address-use-after-scope in clang
so we had to use -mllvm -asan-use-after-scope=1.

Reviewers: eugenis

Subscribers: kubabrecka

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

llvm-svn: 275475
2016-07-14 21:18:06 +00:00
Kuba Brecka 9880bfda07 Disable the "gcd-io-race.mm" test to investigate bot hangs due to the test being deadlocked.
llvm-svn: 275182
2016-07-12 15:41:14 +00:00
Etienne Bergeron ab42f4ddba [compiler-rt] Fix VisualStudio virtual folders layout
Summary:
This patch is a refactoring of the way cmake 'targets' are grouped.
It won't affect non-UI cmake-generators.

Clang/LLVM are using a structured way to group targets which ease
navigation through Visual Studio UI. The Compiler-RT projects
differ from the way Clang/LLVM are grouping targets.

This patch doesn't contain behavior changes.

Reviewers: kubabrecka, rnk

Subscribers: wang0109, llvm-commits, kubabrecka, chrisha

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

llvm-svn: 275111
2016-07-11 21:51:56 +00:00
Kuba Brecka ddc3cc65cb [tsan] Add support for GCD IO channels on Darwin
This patch adds interceptors for dispatch_io_*, dispatch_read and dispatch_write functions. This avoids false positives when using GCD IO. Adding several test cases.

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

llvm-svn: 275071
2016-07-11 15:57:50 +00:00
Saleem Abdulrasool bcb8190f99 test: Use %clangxx in objc++ test files
These test in this change are objc++, but are built using %clang, not %clangxx.
The reason this works is the driver has been adding -lc++ for sanitizer enabled
builds. By making these tests use %clangxx, they no longer depend on the driver
linking to c++.  Doing so will allow us to prevent overlinking of libc++ for
applications.

llvm-svn: 274989
2016-07-09 21:14:36 +00:00
Derek Bruening dec4bd0838 [esan] Add __esan_report for mid-run data
Summary:
Adds a new public interface routine __esan_report() which can be used to
request profiling results prior to abnormal termination (e.g., for a server
process killed by its parent where the normal exit does not allow for
normal result reporting).

Implements this for the working-set tool.  The cache frag tool is left
unimplemented as it requires missing iteration capabilities.

Adds a new test.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 274964
2016-07-09 04:13:25 +00:00
Alina Sbirlea 0efdda0956 Revert "Add runtime support for __cpu_model (__builtin_cpu_supports)"
This reverts commit r274873 until additional fixes are resolved.

llvm-svn: 274944
2016-07-08 22:22:43 +00:00
Alina Sbirlea 9ebebce2df Add runtime support for __cpu_model (__builtin_cpu_supports)
Summary:
This aims to add support for __cpu_model and address Bug 25510. It uses
the code from lib/Support/Host.cpp for cpu detection, and creates
__cpu_model with that info.

Tested on OSX, it builts successfully, but the current version does
*not* resolve Bug 25510. The __cpu_model symbol is present in the
library but it only gets loaded with -all_load. This patch will not land
until this issue is clarified.

Built on Linux as well (though libgcc is the default). The use of "asm"
required -std=gnu99, hence the cmake change. Corrections on better
addressing this are welcome.

Note: See additional comments on D20988 (committed as r271921).

Reviewers: llvm-commits, joerg, echristo, mehdi_amini

Subscribers: mehdi_amini

Differential revision: http://reviews.llvm.org/D21033

llvm-svn: 274873
2016-07-08 16:28:54 +00:00
Alina Sbirlea fb11f27253 Revert r274865-r274870
llvm-svn: 274872
2016-07-08 16:28:52 +00:00
Alina Sbirlea 7847598113 Add default initialization. Add unit test.
llvm-svn: 274867
2016-07-08 16:18:38 +00:00
Kuba Brecka 4446c216f5 [tsan] Avoid false positives with GCD data callbacks
This patch adds synchronization between the creation of the GCD data object and destructor’s execution. It’s far from perfect, because ideally we’d want to synchronize the destruction of the last reference (via dispatch_release) and the destructor’s execution, but intercepting objc_release is problematic.

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

llvm-svn: 274749
2016-07-07 12:38:37 +00:00
Qin Zhao 7f92eab5af [esan|cfrag] Handle binaries built with -esan-aux-field-info=false
Summary:
Handles binaries built with -esan-aux-field-info=false and print less
information.

Updates test struct-simple.cpp.

Reviewers: aizatsky

Subscribers: llvm-commits, bruening, eugenis, kcc, zhaoqin, kubabrecka, vitalybuka

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

llvm-svn: 274727
2016-07-07 03:20:24 +00:00
Derek Bruening 34913f3beb [esan|wset] Ensure SIGSEGV is not blocked
Summary:
Adds interception of sigprocmask and pthread_sigmask to esan so that the
working set tool can prevent SIGSEGV from being blocked.  A blocked SIGSEGV
results in crashes due to our lazy shadow page allocation scheme.

Adds new sanitizer helper functions internal_sigemptyset and
internal_sigismember.

Adds a test to workingset-signal-posix.cpp.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 274672
2016-07-06 21:04:48 +00:00
Derek Bruening 24fe829825 [esan|wset] Further reduce flakiness of sampling test
Enhances the sampling test to try and reduce flakiness further by
increasing the workload to ensure a few samples are gathered.

llvm-svn: 274669
2016-07-06 20:27:44 +00:00
Kuba Brecka fd995fe654 [tsan] Fix false positives with GCD dispatch_source_*
We already have interceptors for dispatch_source API (e.g. dispatch_source_set_event_handler), but they currently only handle submission synchronization. We also need to synchronize based on the target queue (serial, concurrent), in other words, we need to use dispatch_callback_wrap. This patch implements that.

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

llvm-svn: 274619
2016-07-06 11:02:49 +00:00
David Majnemer 69898e6bc5 Attempt to reduce flakiness in workingset-samples.cpp
The test is matching against 'KB' but it looks like the output can be
'MB'.

llvm-svn: 274587
2016-07-06 00:12:43 +00:00
Ryan Govostes b395d7271d [asan] Update tests according to r274578
llvm-svn: 274579
2016-07-05 21:53:23 +00:00
Kuba Brecka c54b108cf8 [tsan] Synchronize leaving a GCD group with notifications
In the patch that introduced support for GCD barrier blocks, I removed releasing a group when leaving it (in dispatch_group_leave). However, this is necessary to synchronize leaving a group and a notification callback (dispatch_group_notify). Adding this back, simplifying dispatch_group_notify_f and adding a test case.

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

llvm-svn: 274549
2016-07-05 13:48:54 +00:00
Kuba Brecka 09d3e53a93 [tsan] dispatch_once interceptor will cause a crash/deadlock when the original dispatch_once is used
Because we use SCOPED_TSAN_INTERCEPTOR in the dispatch_once interceptor, the original dispatch_once can also be sometimes called (when ignores are enabled or when thr->is_inited is false). However the original dispatch_once function doesn’t expect to find “2” in the storage and it will spin forever (but we use “2” to indicate that the initialization is already done, so no waiting is necessary). This patch makes sure we never call the original dispatch_once.

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

llvm-svn: 274548
2016-07-05 13:39:54 +00:00
Qin Zhao 91ea3fb698 [esan|cfrag] Add struct array access report
Summary:
Adds struct array access counter report.

Updates test struct-simple.cpp.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, bruening, llvm-commits, kubabrecka

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

llvm-svn: 274421
2016-07-02 03:25:55 +00:00
Kuba Brecka 4357f021e3 [tsan] Relax the "ignored-interceptors.mm" testcase. The test has been flaky because it's detecting a false positive race (coming from a system library) and sometimes that race is detected after we're printing "Done".
llvm-svn: 274346
2016-07-01 12:55:36 +00:00
Etienne Bergeron e6f424460a [compiler-rt] Fix broken unittest using alloca on MSVC.
Summary:
The alloca header is not present on windows.

This test was committed recently:
  http://reviews.llvm.org/D21509
  http://reviews.llvm.org/rL273889

Reviewers: rnk

Subscribers: llvm-commits, wang0109, chrisha, kubabrecka

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

llvm-svn: 274230
2016-06-30 14:37:02 +00:00
Kuba Brecka 4d81bbdf53 [tsan] Stop extending the block’s lifetime in dispatch_group_async
The dispatch_group_async interceptor actually extends the lifetime of the executed block. This means the destructor of the block (and captured variables) is called *after* dispatch_group_leave, which changes the semantics of dispatch_group_async.  This patch fixes that.

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

llvm-svn: 274117
2016-06-29 10:30:50 +00:00
Evgeniy Stepanov 465651fe3d [msan] Fix handling of padding in sendmsg control data.
llvm-svn: 274074
2016-06-28 22:42:31 +00:00
Kuba Brecka f7b9075e52 Adapt the "objc-race.mm" test to use ignore_interceptors_accesses=1. All Obj-C/Darwin tests currently need this to avoid false positives.
llvm-svn: 274014
2016-06-28 13:56:09 +00:00
Kuba Brecka 2621dea6eb [tsan] Add HB edges for GCD barrier blocks
Adding support for GCD barrier blocks in concurrent queues.  This uses two sync object in the same way as read-write locks do.  This also simplifies the use of dispatch groups (the notifications act as barrier blocks).

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

llvm-svn: 273893
2016-06-27 16:49:23 +00:00
Kuba Brecka 7d1ebed0c5 [asan] fix false dynamic-stack-buffer-overflow report with constantly-sized dynamic allocas, compiler-rt part
See the bug report at https://github.com/google/sanitizers/issues/691. When a dynamic alloca has a constant size, ASan instrumentation will treat it as a regular dynamic alloca (insert calls to poison and unpoison), but the backend will turn it into a regular stack variable. The poisoning/unpoisoning is then broken. This patch will treat such allocas as static.

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

llvm-svn: 273889
2016-06-27 15:57:53 +00:00
Ryan Govostes d4492ee159 Move -ldl to the correct compiler invocation
llvm-svn: 273844
2016-06-27 05:44:47 +00:00
Kuba Brecka 30ad0c941a [tsan] Intercept libcxx __release_shared to avoid false positive with weak_ptrs and destructors in C++
There is a "well-known" TSan false positive when using C++ weak_ptr/shared_ptr and code in destructors, e.g. described at <https://llvm.org/bugs/show_bug.cgi?id=22324>. The "standard" solution is to build and use a TSan-instrumented version of libcxx, which is not trivial for end-users. This patch tries a different approach (on OS X): It adds an interceptor for the specific function in libc++.dylib, which implements the atomic operation that needs to be visible to TSan.

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

llvm-svn: 273806
2016-06-26 08:14:01 +00:00
Peter Collingbourne c79ad577fb cfi: Start testing CFI in both standalone and devirtualization modes.
Differential Revision: http://reviews.llvm.org/D21123

llvm-svn: 273758
2016-06-25 00:24:22 +00:00
Evgeniy Stepanov dd9e03ed87 [msan] Intercept eventfd_read, eventfd_write.
llvm-svn: 273748
2016-06-24 23:32:30 +00:00
Evgeniy Stepanov c8679985ed [sanitizer] Add syscall handlers for sigaction and rt_sigaction.
llvm-svn: 273746
2016-06-24 23:09:44 +00:00
Ryan Govostes 6f92bd38d8 [asan] Improve global-registration.c test
Removes use of GNU language extensions from the test, and hopefully fixes the
link order on Linux.

llvm-svn: 273741
2016-06-24 22:39:23 +00:00
Peter Collingbourne cf55f217ba cfi: Apply pass rename to tests.
Differential Revision: http://reviews.llvm.org/D21055

llvm-svn: 273731
2016-06-24 21:22:02 +00:00
Evgeniy Stepanov c7509de7cc [msan] Fix syscall handlers for pipe, pipe2, socketpair.
These syscalls write two file descriptors into the output buffer, not one.

llvm-svn: 273728
2016-06-24 21:15:53 +00:00
Xinliang David Li 3e9bbddcbb fix a test bug when executed remotedly
llvm-svn: 273693
2016-06-24 17:42:51 +00:00
Ryan Govostes 00f607eef0 Change shared library load path to appease Android bot
llvm-svn: 273654
2016-06-24 06:49:01 +00:00
Ryan Govostes 0ec8ab680f [asan] Add failure logging to global-registration.c test case
llvm-svn: 273629
2016-06-23 23:26:25 +00:00
Ryan Govostes 3c0f63c98b [asan] Fix global-registration.c on Linux
llvm-svn: 273476
2016-06-22 20:52:34 +00:00
Anna Zaks 0a494bd4d4 [asan] Relax a flaky invalid-pointer-pairs test
This test is flaky. Specifically, on some Mac configurations we see the
__sanitizer_ptr_cmp as the 0th frame. Let's relax it to not require that
f is in frame #0.

61396==ERROR: AddressSanitizer: invalid-pointer-pair: 0x01e00510 0x01e004d0
0 0x18f5a3 in __sanitizer_ptr_cmp ... libclang_rt.asan_osx_dynamic.dylib+0xaf5a3)
1 0xdd924 in f(char, char*, char*) ... invalid-pointer-pairs.cc:14:14

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

llvm-svn: 273475
2016-06-22 20:52:21 +00:00
Ryan Govostes f66146914b [asan] Add a test case for global registration
This test case checks that globals from all object files are being registered
after they've been linked together. It also checks that globals from libraries
loaded at runtime are registered.

llvm-svn: 273464
2016-06-22 19:59:10 +00:00
Dmitry Vyukov 47b7c5c912 [asan] add primitives that allow coroutine implementations
This patch adds the __sanitizer_start_switch_fiber and
__sanitizer_finish_switch_fiber methods inspired from what can be found here
2ea64dd249 .

These methods are needed when the compiled software needs to implement
coroutines, fibers or the like. Without a way to annotate them, when the program
jumps to a stack that is not the thread stack, __asan_handle_no_return shows a
warning about that, and the fake stack mechanism may free fake frames that are
still in use.

Author: blastrock (Philippe Daouadi)
Reviewed in http://reviews.llvm.org/D20913

llvm-svn: 273260
2016-06-21 12:29:18 +00:00
Evgeniy Stepanov ecfcc07a48 [msan] Don't check dstaddr in sendto() interceptor.
Dstaddr may contain uninitialized padding at the end (common
implementations accept larger addrlen and ignore the extra bytes).
Also, depending on the socket state, dstaddr argument may be ignored.

llvm-svn: 273205
2016-06-20 22:05:33 +00:00
Evgeniy Stepanov 843b651398 [msan] Allow uninitialized padding in struct msghdr.
llvm-svn: 273204
2016-06-20 21:44:14 +00:00
Evgeniy Stepanov 352289b679 Hide send/sendto/sendmsg interptors under a flag.
A runtime flag to enable checking in send* interceptors.
Checking is enabled by default.

llvm-svn: 273174
2016-06-20 17:57:51 +00:00
Qin Zhao e24bc365e8 [esan|cfrag] Add the struct field size array in StructInfo
Summary:
Adds the struct field size array in the struct StructInfo.

Prints struct field size info in the report.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, bruening, llvm-commits, kubabrecka

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

llvm-svn: 272988
2016-06-17 04:50:11 +00:00
Evgeniy Stepanov 3c17c73924 [msan] Intercept send/sendto/sendmsg.
send/sendmsg moved from tsan to sanitizer_common; sendto is new.

llvm-svn: 272980
2016-06-17 00:43:11 +00:00
Kostya Serebryany bf6a04fde8 [sanitizers] introduce yet another API function: __sanitizer_install_malloc_and_free_hooks
llvm-svn: 272943
2016-06-16 20:06:06 +00:00
Evgeniy Stepanov 062c26f1f0 Merge two coverage tests undef UBSan into one.
Also replace mkdir -p with rm -rf && mkdir.

llvm-svn: 272839
2016-06-15 21:18:17 +00:00
Evgeniy Stepanov 9ea0833b6e Fix ubsan/coverage test to put coverage file in a subdirectory.
By default coverage is dumped to the current directory, which may not
always be writable.

llvm-svn: 272732
2016-06-14 22:53:29 +00:00
Evgeniy Stepanov c565cfaac9 Compiler-rt test for sanitizer coverage w/o sanitizers.
llvm-svn: 272718
2016-06-14 21:33:59 +00:00
Derek Bruening f6f149da29 [sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors.  The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up.  This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.

Adds a test that emulates an instrumented allocator.

Reviewers: aizatsky

Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 272676
2016-06-14 15:15:38 +00:00
Nico Weber be7aa544f0 Revert r272591, http://lab.llvm.org:8011/builders/clang-x64-ninja-win7 has been broken since this landed.
llvm-svn: 272659
2016-06-14 12:39:22 +00:00
Derek Bruening c4c649e25a [sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors.  The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up.  This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.

Adds a test that emulates an instrumented allocator.

Reviewers: aizatsky

Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 272591
2016-06-13 21:50:00 +00:00
Derek Bruening db176c11dc Revert "[sanitizer][esan] Add internal_sigaction_syscall"
This reverts commit r272553.

The iOS build fails to link.

llvm-svn: 272557
2016-06-13 16:16:49 +00:00
Derek Bruening 19a4b8d8f8 [sanitizer][esan] Add internal_sigaction_syscall
Summary:
Adds a version of sigaction that uses a raw system call, to avoid circular
dependencies and support calling sigaction prior to setting up
interceptors.  The new sigaction relies on an assembly sigreturn routine
for its restorer, which is Linux x86_64-only for now.

Uses the new sigaction to initialize the working set tool's shadow fault
handler prior to libc interceptor being set up.  This is required to
support instrumentation invoked during interceptor setup, which happens
with an instrumented tcmalloc or other allocator compiled with esan.

Adds a test that emulates an instrumented allocator.

Reviewers: aizatsky

Subscribers: vitalybuka, tberghammer, zhaoqin, danalbert, kcc, srhines, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 272553
2016-06-13 15:42:39 +00:00
Sean Silva 537b146798 [libprofile] Define an expansion `%clang_profgen=`
llvm-svn: 272498
2016-06-12 04:17:57 +00:00
Xinliang David Li df5843a532 [profile] fix bot failure on darwin
Profile setting accross shared lib is broken on darwin (to be investigated).
Move the test to Linux only for now

llvm-svn: 272404
2016-06-10 16:23:32 +00:00
Xinliang David Li 1d58b8d95e [profile] add profile path tests for shared lib
Test that __llvm_profile_set_filename invoked in
main program is 'visible' to shared lib (overriding
shared libary's profile path set on command line)

llvm-svn: 272375
2016-06-10 06:14:17 +00:00
Xinliang David Li af053d8b97 [profile] add profile path tests
Testing profile path setter predendence.

llvm-svn: 272372
2016-06-10 05:19:38 +00:00
Qin Zhao a4a7220db1 [esan|cfrag] Add the struct field offset array in StructInfo
Summary:
Adds the struct field offset array in the struct StructInfo.

Prints struct size and field offset info in the report.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, bruening, llvm-commits, kubabrecka

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

llvm-svn: 272363
2016-06-10 02:10:34 +00:00
Xinliang David Li 5846d08a2c Fix win bot failure
llvm-svn: 272316
2016-06-09 21:52:24 +00:00
Vedant Kumar 2494d18f84 [profile] Fix test to bail on failed waitpid in instrprof-file_ex.c
This resolves PR28066.

Patch by David Binderman!

llvm-svn: 272268
2016-06-09 15:29:59 +00:00
Xinliang David Li e2ce2e0020 [profile] in-process merging support part-3
Differential Revision: http://reviews.llvm.org/D21056

llvm-svn: 272227
2016-06-08 23:43:56 +00:00
Derek Bruening c45e51c891 [esan|wset] Reduce flakiness in samples test
Generalizes the workingset-samples test to pass when a sample has a
size of 0, which can happen on a loaded machine.

llvm-svn: 272175
2016-06-08 17:35:52 +00:00
Kostya Serebryany 86020ba32b [scudo] trying to fix the bot: aligned_alloc is not known there; attempt 3
llvm-svn: 272074
2016-06-07 23:49:11 +00:00
Kostya Serebryany 8aa0d7332a [scudo] trying to fix the bot: aligned_alloc is not known there; attempt 2
llvm-svn: 272051
2016-06-07 20:09:49 +00:00
Kostya Serebryany 86f8d33442 [scudo] trying to fix the bot: aligned_alloc is not known there
llvm-svn: 272037
2016-06-07 18:29:10 +00:00
Kostya Serebryany 422ea24d45 [asan] make print_memory_profile_test more reliable by using large allocation sizes. Hoping to fix the llvm-clang-lld-x86_64-debian-fast bot
llvm-svn: 272020
2016-06-07 16:08:59 +00:00
Kostya Serebryany 712fc9803a [sanitizer] Initial implementation of a Hardened Allocator
Summary:
This is an initial implementation of a Hardened Allocator based on Sanitizer Common's CombinedAllocator.
It aims at mitigating heap based vulnerabilities by adding several features to the base allocator, while staying relatively fast.
The following were implemented:
- additional consistency checks on the allocation function parameters and on the heap chunks;
- use of checksum protected chunk header, to detect corruption;
- randomness to the allocator base;
- delayed freelist (quarantine), to mitigate use after free and overall determinism.
Additional mitigations are in the works.

Reviewers: eugenis, aizatsky, pcc, krasin, vitalybuka, glider, dvyukov, kcc

Subscribers: kubabrecka, filcab, llvm-commits

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

llvm-svn: 271968
2016-06-07 01:20:26 +00:00
David Blaikie 7d492c4ff8 add -f to rm so the test passes the first time it's run the file file is not present
(otherwise it just keeps failing at the rm step and never passes... )

llvm-svn: 271959
2016-06-06 23:31:58 +00:00
Sean Silva 7e4e69abe2 [libprofile] Also use `env` for this test.
(necessary on Windows)

llvm-svn: 271955
2016-06-06 23:19:23 +00:00
Sean Silva d7caf5889b [libprofile] Add %run to a couple tests.
llvm-svn: 271947
2016-06-06 22:19:49 +00:00
Xinliang David Li 0891b6d59b [profile] code cleanup /NFC
Address review feedback for better
readability.

llvm-svn: 271922
2016-06-06 18:31:29 +00:00
Kuba Brecka 2e26d9faac [asan] Reenable ASan tests in "check-all"
Somehow, in r271049, ASan lit tests and unit tests were removed from “check-all”. Doesn’t seem intentional, let’s fix it.

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

llvm-svn: 271905
2016-06-06 16:24:47 +00:00
Xinliang David Li 5cd1f94d4f [profile] in-process mergeing support (part-2)
(Part-1 merging API is in profile runtime)

This patch implements a portable file opening API
with exclusive access for the process. In-process
profile merge requires profile file update to be
atomic/fully sychronized.

llvm-svn: 271864
2016-06-06 03:17:58 +00:00
Chandler Carruth 7573cfe2b3 It really helps to not randomly delete one of the closing brackets. =/
llvm-svn: 271787
2016-06-04 09:06:59 +00:00
Chandler Carruth b330dcab19 Ok, now I know why I kept getting confused and not making progress
fixing tis test. There are different configurations running, and they
have subtly different backtraces. I didn't notice that the configs
changed and so I kept occilating between the two.

Now I've looked at two different configs at the same time, and so this
should be much more likely to work.

llvm-svn: 271786
2016-06-04 08:54:57 +00:00
Chandler Carruth 9ef4243824 Fix the test for printing the memory profile. This fuctionality is only
available along side the leak checking, so use the REQUIRES for that.

Also, use %run as other tests do when launching the built binary.

This fixes check-asan for me on Linux and looks like it should fix the
linux sanitizer bots as well.

llvm-svn: 271785
2016-06-04 08:45:32 +00:00
Chandler Carruth ece6d7bf2e Update this test yet again, this time based on a nice consecutive pair
of lines provided with the filecheck output from the previous run. I'll
probably give up after this and get someone with a Windows build to help
me out.

llvm-svn: 271784
2016-06-04 08:24:56 +00:00
Chandler Carruth 4f785dc1f6 I didn't actually get this right, but now I have frame #0 and frame #2.
This should fail on frame #1 and show what that should actually be.

llvm-svn: 271783
2016-06-04 08:09:24 +00:00
Chandler Carruth d26defd57e Amazingly, my guess was correct for the top two frames here. Hopefully
with this, the Windows sanitizer bot will go green!

llvm-svn: 271782
2016-06-04 07:29:10 +00:00
Chandler Carruth 79abce39bb Temporary hack to this test to try and get the sanitizer-windows bot to
show enough information for me to fix the patterns used here.

llvm-svn: 271779
2016-06-04 06:16:49 +00:00
Xinliang David Li c012d086fa reapply r271577 after OSX bug is fixed (hopefully)
llvm-svn: 271759
2016-06-04 01:51:25 +00:00
Qin Zhao bc929e4765 [esan|cfrag] Compute the struct field access difference ratio
Summary:
Computes the struct field access variation based on each field access
count.

Adds a flag to control the report thresholds.

Updates struct-simple.cpp with variance report output.

Reviewers: aizatsky

Subscribers: kubabrecka, zhaoqin, llvm-commits, eugenis, vitalybuka, kcc, bruening

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

llvm-svn: 271734
2016-06-03 20:48:17 +00:00
Derek Bruening 45afd7e8fc [esan] Eliminate flakiness in large-stack test
Turns off sampling for the large-stack test to remove nondeterminism in the
output and fix bot failures.

llvm-svn: 271691
2016-06-03 17:18:09 +00:00
Derek Bruening e78e4a6e94 [esan|wset] Add 8-level working set snapshot accumulation
Summary:
Adds a new option -snapshot_step controlling the frequency distribution for
an 8-level series of samples using each bit of each shadow byte.
Implements accumulation from each level to the next higher level at the
specified frequency.

Adds storage of the 8 series of samples using CircularBuffer instances.
Fixes an error in the circular buffer data structure where a static
object's destructor will be called too early.

Prints the results out at the end in a simple manner to give us something
to start with.

Updates the workingset-samples test to test the new feature.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 271683
2016-06-03 16:27:50 +00:00
Derek Bruening 07814769a8 [esan] Add sideline itimer support
Summary:
Adds support for creating a separate thread for performing "sideline"
actions on a periodic basis via an itimer.  A new class SidelineThread
implements this feature, exposing a sampling callback to the caller.

Adds initial usage of sideline sampling to the working set tool.  For now
it simply prints the usage at each snapshot at verbosity level 1.  Adds a
test of this behavior.  Adds a new option -record_snapshots to control
whether we sample and a new option -sample_freq to control the periodicity
of the sampling.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 271682
2016-06-03 16:14:07 +00:00
Dmitry Vyukov 0f7e949a42 tsan: rely on AnnotateRWLockCreateStatic to detect linker-initialized mutexes
The new annotation was added a while ago, but was not actually used.
Use the annotation to detect linker-initialized mutexes instead
of the broken IsGlobalVar which has both false positives and false
negatives. Remove IsGlobalVar mess.

llvm-svn: 271663
2016-06-03 11:48:27 +00:00
Mehdi Amini e1db5a0400 Revert "[profile] enable a subtest for vcall inline virtual func"
This reverts commit r271577.

The test does not pass on OSX.

llvm-svn: 271617
2016-06-03 00:45:26 +00:00
Derek Bruening 0b04950116 [esan] Add support for log_exe_name
Summary:
Adds the call needed to cache the binary name to support the sanitizer
option log_exe_name for usable log file results when running multiple
applications.  Adds a test.

Reviewers: aizatsky

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 271586
2016-06-02 20:50:30 +00:00
Xinliang David Li d4c23fc76f [profile] enable a subtest for vcall inline virtual func
llvm-svn: 271577
2016-06-02 20:12:06 +00:00
Dmitry Vyukov 1ae44e6a2b tsan: clean up dynamic TLS memory between reuse
Currently the added test produces false race reports with glibc 2.19,
because DLTS memory is reused by pthread under the hood.

Use the DTLS machinery to intercept new DTLS ranges.
__tls_get_addr known to cause issues for tsan in the past,
so write the interceptor more carefully.

Reviewed in http://reviews.llvm.org/D20927

llvm-svn: 271568
2016-06-02 19:18:22 +00:00
Qin Zhao 4175a6d580 [esan|cfrag] Add struct info registration
Summary:
Adds StructInfo to CacheFragInfo to match the LLVM's EfficiencySanitizer
structs.

Uses StructHashMap to keep track of the struct info used by the app.

Adds registerStructInfo/unregisterStructInfo to add/remove struct infos
to/from StructHashMap.

updates test struct-simple.cpp with more C structs.

Reviewers: aizatsky, filcab

Subscribers: filcab, zhaoqin, llvm-commits, eugenis, vitalybuka, kcc, bruening, kubabrecka

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

llvm-svn: 271564
2016-06-02 18:45:25 +00:00
Ivan Krasin 048155c399 UBSan: crash less often on corrupted Vtables.
Summary:
This CL adds a weak check for a Vtable prefix: for a well-formed
Vtable, we require the prefix to be within [-1<<20; 1<<20].

Practically, this solves most of the known cases when UBSan segfaults
without providing any useful diagnostics.

Reviewers: pcc

Subscribers: kubabrecka

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

llvm-svn: 271560
2016-06-02 18:36:12 +00:00
Xinliang David Li 66703ebfe5 [profile] Add end-end test of vp for inline virtual functions
Make sure inline virtual function's address is properly recorded and
dumped in raw profile so that value profiling does not loss tracking.
(Second part of the test will be enabled after the lowering bug is fixed
in LLVM)

llvm-svn: 271528
2016-06-02 16:24:21 +00:00
Kostya Serebryany 5a7159c416 [asan] add an interface function __sanitizer_print_memory_profile (a basic memory profiler; asan/Linux-only for now)
llvm-svn: 271463
2016-06-02 01:21:52 +00:00
Qin Zhao 9e39638375 [esan|cfrag] Add the skeleton to handle the cfrag argument
Summary:
Adds the struct declaration for the cache-fragmentation tool variable
passed to the runtime library.

Updates test struct-simple.cpp.

Reviewers: aizatsky, bruening

Subscribers: filcab, kubabrecka, bruening, kcc, vitalybuka, eugenis, llvm-commits, zhaoqin

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

llvm-svn: 271337
2016-05-31 21:27:39 +00:00
Mehdi Amini 42b0c352c1 Fix test for Darwin: ASAN is calling abort by default on Darwin, which not detects as a crash
llvm-svn: 271323
2016-05-31 20:09:56 +00:00
Derek Bruening b7e38d8821 [esan] Add circular buffer data structure
Summary:
Adds a new class, CircularBuffer, for holding a wrap-around fixed-size
sequence of a primitive data type.  This will be used initially by the
working set tool.

Adds a unit test for CircularBuffer, including infrastructure support to
include esan headers and to link with the esan library by pretending to
want the working set tool.

Reviewers: aizatsky, filcab

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 271286
2016-05-31 14:44:49 +00:00
Derek Bruening 8ef3f0fa5b [esan|wset] Iterate all memory to compute the total working set
Summary:
Adds iteration of all application memory in an efficient manner using
shadow faults.  Shadow memory starts out inaccessible and we mark it
writable one page at a time on each fault when the instrumentation touches
it.  This allows iteration over just the mapped shadow memory, saving
significant time.

Adds a process-end iteration and pretty-printing of the final result.

Adds a new test and updates the existing tests.

Reviewers: aizatsky, filcab

Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka

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

llvm-svn: 271277
2016-05-31 13:41:07 +00:00
Derek Bruening 8e74c1084b [esan] Intercept and chain signal handlers
Summary:
In preparation for fault-based shadow memory iteration, we add support for
our own signal handler by adding app signal handler interception as well as
chaining for SIGSEGV.  This is done in a simple manner: we do not honor the
app's alternate stack nor any sigaction flags for SIGSEGV.

Adds a new test of transparency in app signal handling.

Reviewers: aizatsky

Subscribers: filcab, kubabrecka, vitalybuka, zhaoqin, kcc, eugenis, llvm-commits

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

llvm-svn: 271272
2016-05-31 13:21:03 +00:00
Xinliang David Li 9ab45cf1eb Move test only for the relevant platform
llvm-svn: 271098
2016-05-28 04:26:06 +00:00
Kostya Serebryany e31e778160 [sanitizers] introduce a common run-time option dedup_token_length to help with report deduplication, off by default for now. See https://github.com/google/sanitizers/issues/684
llvm-svn: 271085
2016-05-28 01:25:44 +00:00
Derek Bruening 909d32955b [esan] Add handling of large stack size rlimits
Summary:
Adds detection of large stack size rlimits (over 1 TB or unlimited), which
results in an mmap location that our shadow mapping does not support.  We
re-exec the application in this situation.  Adds a test of this behavior.

Adds general detection of mmap regions outside of our app regions.  In the
future we want to try to adaptively handle these but for now we abort.

Moves the existing Linux-specific mmap code into a platform-specific file
where the new rlimit code lives.

Reviewers: eugenis

Subscribers: vitalybuka, zhaoqin, kcc, aizatsky, llvm-commits, kubabrecka

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

llvm-svn: 271079
2016-05-28 00:25:16 +00:00
Etienne Bergeron 00f3f6e296 This patch is activating the build of Asan on Windows 64-bits.
It's fixing compilation errors. The runtime is not yet working.

Missing features:

OverrideFunction for x64
an equiv function for inline asm (atomic_compare_exchange_strong)
shadow memory offset needs to be adjusted
RoundUpToInstrBoundary for x64
They will be implemented by subsequent patches.

Patch by Wei Wang.

Differential revision: http://reviews.llvm.org/D20455

llvm-svn: 271049
2016-05-27 21:29:31 +00:00
Kostya Serebryany 1508f591b3 [sanitizers] introduce __sanitizer_set_report_fd so that we can re-route the sanitizer logging to another fd from inside the process
llvm-svn: 271046
2016-05-27 21:23:05 +00:00
Xinliang David Li c3fdce3f1d [profile] Add a test to ensure runtime allocator is not invoked
llvm-svn: 271017
2016-05-27 16:49:29 +00:00
Derek Bruening 850d47ce64 [esan] Fix workingset-memset test failure
Fixes an esan workingset-memset test failure by switching to malloc to
avoid a shadow mapping issue with mmap in certain situations that will be
fully fixed separately.

llvm-svn: 270949
2016-05-27 01:47:27 +00:00
Xinliang David Li 753279e054 Add missing test case changes
llvm-svn: 270930
2016-05-26 22:20:39 +00:00
Vitaly Buka 132639120a Init tsan with .preinit_array section
Summary: Some libraries, like OpenSSL, runs code from .init section.

Reviewers: kcc, eugenis

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 270873
2016-05-26 17:05:36 +00:00
Hal Finkel 678635e010 Fix columns for member function calls
After r270775, Clang is smarter about the generating the locations for
member-function calls. Update some ubsan tests accordingly.

llvm-svn: 270801
2016-05-25 23:47:34 +00:00
Xinliang David Li 65971297a0 [profile] Add early checking to bypass node pointer update
llvm-svn: 270766
2016-05-25 21:27:02 +00:00
Qin Zhao 7e4933f430 [esan][cfrag] Add skeleton for cache fragmentation tool support
Summary:
Adds cache_frag.h and cache_frag.cpp for the cache fragmentation tool.

Updates test struct-simple.cpp.

Reviewers: aizatsky

Subscribers: filcab, zhaoqin, llvm-commits, eugenis, vitalybuka, kcc, bruening, kubabrecka

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

llvm-svn: 270737
2016-05-25 17:49:00 +00:00
Kuba Brecka f5f140db28 [tsan] Change some OS X tests to include system headers (xpc.h, mman.h) more explicitly.
llvm-svn: 270713
2016-05-25 16:04:24 +00:00
Derek Bruening 88639859db Add working set base runtime library
Summary:
Adds the base runtime library for the working set tool.
Adds slowpath code for updating the shadow memory.

To be added in the future:
+ Scan memory and report the total size.
+ Take samples for intermediate values.

Reviewers: aizatsky

Subscribers: kubabrecka, vitalybuka, zhaoqin, kcc, eugenis, llvm-commits

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

llvm-svn: 270650
2016-05-25 02:04:04 +00:00
Derek Bruening 515c15c207 [esan|cfrag] Add test struct-simple.cpp
Summary: Adds a new test struct-simple.cpp for testing the
cache-fragmentation tool with a multi-compilation-unit application.

Patch by Qin Zhao.

Reviewers: bruening

Subscribers: kubabrecka, kcc, vitalybuka, eugenis, aizatsky, llvm-commits, zhaoqin

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

llvm-svn: 270631
2016-05-24 23:03:52 +00:00
Xinliang David Li 7b41393497 [profile] initialize static pool properly
Remove dependency on runtime initializer to avoid
issues related to initialization order.

llvm-svn: 270371
2016-05-22 16:36:03 +00:00