Commit Graph

7404 Commits

Author SHA1 Message Date
Adhemerval Zanella 4f9de1e7bf tsan: Enable 48-bit VMA support on aarch64
This patch adds 48-bits VMA support for tsan on aarch64.  As current
mappings for aarch64, 48-bit VMA also supports PIE executable.  This
limits the mapping mechanism because the PIE address bits
(usually 0aaaaXXXXXXXX) makes it harder to create a mask/xor value
to include all memory regions.  I think it is possible to create a
large application VAM range by either dropping PIE support or tune
current range.

It also changes slight the way addresses are packed in SyncVar structure:
previously it assumes x86_64 as the maximum VMA range.  Since ID is 14 bits
wide, shifting 48 bits should be ok.

Tested on x86_64, ppc64le and aarch64 (39 and 48 bits VMA).

llvm-svn: 277137
2016-07-29 12:45:35 +00:00
Dean Michael Berris 17a586e6de [compiler-rt][XRay] Address follow-up comments to initial interface and initialisation code
This addresses some comments from D21612, which contains the following changes:

- Update __xray_patch() and __xray_unpatch() API documentation to not imply asynchrony.
- Introduce a scope cleanup mechanism to make sure we can roll-back changes to the XRayPatching global atomic.
- Introduce a few more comments for potential extension points for other platforms (for the implementation details of patching and un-patching).

Reviewers: eugenis, rnk, kcc, echristo, majnemer

Subscribers: llvm-commits, mehdi_amini

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

llvm-svn: 277124
2016-07-29 07:11:58 +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 74999eb50f Fix broken build bot
The address resolution is ussing RTLD_NEXT and not RTLD_DEFAULT.
Which means &func may not be equivalent to dlsym("func").

llvm-svn: 276951
2016-07-28 01:35:32 +00:00
Etienne Bergeron 8c6eb1566c [compiler-rt] Fix warnings in interception code
Summary:
This patch is re-introducing the code to fix the
dynamic hooking on windows and to fix a compiler
warning on Apple.

Related patches:

* https://reviews.llvm.org/D22641
* https://reviews.llvm.org/D22610
* https://reviews.llvm.org/rL276311
* https://reviews.llvm.org/rL276490

Both architecture are using different techniques to
hook on library functions (memchr, strcpy,...). 

On Apple, the function is not dynamically hooked and
the symbol always points to a valid function 
(i.e. can't be null). The REAL macro returns the
symbol.

On windows, the function is dynamically patch and the
REAL(...) function may or may not be null. It depend
on whether or not the function was hooked correctly.
Also, on windows memcpy and memmove are the same.

```
#if !defined(__APPLE__)
[...]
# define REAL(x) __interception::PTR_TO_REAL(x)
# define ASSIGN_REAL(dst, src) REAL(dst) = REAL(src)
[...]
#else  // __APPLE__
[...]
# define REAL(x) x
# define ASSIGN_REAL(x, y)
[...]
#endif  // __APPLE__

Reviewers: rnk

Subscribers: kcc, hans, kubabrecka, llvm-commits, bruno, chrisha

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

llvm-svn: 276885
2016-07-27 16:16:54 +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
Dean Michael Berris 7094aa4f8d Revert "Default COMPILER_RT_BUILD_XRAY=ON"
This reverts commit 23240d8de38c79220a888f645a1f4b686bfb87c6.

Broke the build because the build bots haven't gotten the latest config
from zorg yet.

llvm-svn: 276847
2016-07-27 08:10:04 +00:00
Dean Michael Berris d3aaa77ff9 Default COMPILER_RT_BUILD_XRAY=ON
llvm-svn: 276845
2016-07-27 07:27:35 +00:00
Dean Michael Berris 9a0c446d9e Use RAII for ensuring that mprotect calls are undone
Summary: This fixes an mprotect leak identified in D21612.

Reviewers: echristo, rSerge

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 276833
2016-07-27 04:30:25 +00:00
Evgeniy Stepanov d140aec490 [asan] Remove zero FSR check on ARM.
The kernel on Nexus 5X returns error_code in ucontext which has
correct FSR_WRITE flag, but empty (zero) abort type field. Removing
the checks means that we will report all SEGVs as READ on very old
kernels, but will properly distinguish READ vs WRITE on moderately
old ones.

llvm-svn: 276803
2016-07-26 21:02:45 +00:00
Evgeniy Stepanov 08ef0e0175 [asan] Hardcode page size 4096 on Android.
EXEC_PAGESIZE lies.
sysconf() is broken in .preinit_array.

llvm-svn: 276802
2016-07-26 21:02:44 +00:00
Reid Kleckner cb42ea0b4f [sanitizer] Try to fix LargeMmapAllocator test on Windows
This test attempts to allocate 100 512MB aligned pages of memory. This
is implemented in the usual way by allocating size + alignment bytes and
aligning the result. As a result, this test allocates 51.2GB of memory.
Windows allocates swap for all memory allocated, and our bots do not
have this much swap available.

Avoid the failure by using a more reasonable alignment, like 16MB, as we
do on 32-bit.

llvm-svn: 276779
2016-07-26 17:59:09 +00:00
Xinliang David Li c5307c6993 Define compatibility flag if not defined with -std=c++
llvm-svn: 276708
2016-07-25 23:12:53 +00:00
Chris Bieneman 56e3827e92 Revert "Enable cross-compilation across architectures on android"
This reverts commit r276333.

As I commented in the review (https://reviews.llvm.org/D22415), this change isn't needed because CMAKE_C_FLAGS is implicitly added by CMake to the command line for all C source files.

With this patch enabled CMAKE_C_FLAGS is duplicated on all C sources, and applied to ASM sources, which is not ideal.

I sent an email about this to llvm-commits on the commit thread. I suspect the problem the patch author was actually seeing is that CMAKE_C_FLAGS isn't applied to ASM files, and the builtins library has quite a few of those. The correct solution there is to specify CMAKE_ASM_FLAGS with whatever flags need to be passed to the compiler when compiling ASM files.

If there are other problems with flag propagation, please let me know.

llvm-svn: 276683
2016-07-25 20:25:38 +00:00
Bruno Cardoso Lopes 1f849e3b84 Revert r276539 "Silence -Wpointer-bool-conversion warning after r276324"
Some bots are not happy with the change.
This reverts commit d307ca28083065851ad969444f3c063562f2d4bd.

llvm-svn: 276541
2016-07-24 01:27:07 +00:00
Bruno Cardoso Lopes bd36338449 Silence -Wpointer-bool-conversion warning after r276324
sanitizer_common_interceptors.inc:667:12: warning: address of function 'memchr' will always evaluate to 'true' [-Wpointer-bool-conversion]
  if (REAL(memchr)) {
  ~~       ^~~~~~

llvm-svn: 276539
2016-07-24 01:09:03 +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
Bruno Cardoso Lopes fb4358d15b Revert "fix https://reviews.llvm.org/D22610" and "[compiler-rt] Fix memmove/memcpy overlap detection on windows"
This currently fails ~500 tests on Darwin:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/20456/

This reverts commit 4cfee0dff1facb8fa2827d25c5943bfef96d1a8f and
dbd91205d578cb61ab77be06087e9f65ba8a7ec8.

llvm-svn: 276490
2016-07-22 23:02:34 +00:00
Kostya Serebryany d251e94a01 [sanitizer] revert r276383 while investigating failures on bot
llvm-svn: 276456
2016-07-22 19:02:59 +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
Daniel Sanders aea8b553e3 [compiler-rt][cmake] Don't reset CAN_TARGET_${arch} on every cmake invocation.
Allowing this variable to be cached makes it possible to repair the MIPS
buildbots in lieu of either fixing the mips64 sanitizer issues or fixing the
detection of mips64 support (which I think was changed by r268977 but didn't
take effect on this buildbot until the last couple days) so that it returns to
not being built on these buildbots.

llvm-svn: 276402
2016-07-22 10:15:09 +00:00
Xinliang David Li f0e0a74f87 [Profile] cleanup: do not reference name directly of vars shared between rt and llvm
llvm-svn: 276385
2016-07-22 04:08:16 +00:00
Kostya Serebryany 5bc01c108d [sanitizer] refactor TransferBatch to hide the implementation. NFC
llvm-svn: 276383
2016-07-22 02:21:12 +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
Kostya Serebryany bfd69e0580 [sanitizer] allocator: introduce kUseSeparateSizeClassForBatch (false by default). When true, it will cause all TransferBatches to be allocated on a separate dedicated size class, which improves security and may potentially simplify memory reclamation. However in the current state this may cause up to 3% extra memory usage. Subsequent changes should bring this overhead down
llvm-svn: 276377
2016-07-22 01:13:13 +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
Kostya Serebryany 88e95bf38c [sanitizer] trying to fix Mac bots
llvm-svn: 276346
2016-07-21 22:18:36 +00:00
Kostya Serebryany 395386f910 [sanitizer] better allocator stats (with rss)
llvm-svn: 276343
2016-07-21 21:38:40 +00:00
Etienne Bergeron 901b0dc96a [compiler-rt] Add support for relative offset adjustment in interception
Summary:
Some instructions can only be copied if the relative offset is adjusted.

This patch adds support for two common instruction.
It's quite common to have a indirect load in the prologue 
(loading the security cookie).

Reviewers: rnk

Subscribers: llvm-commits, wang0109, chrisha

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

llvm-svn: 276336
2016-07-21 21:08:54 +00:00
Francis Ricci 283d8df277 Enable cross-compilation across architectures on android
Summary:
This patch fixes cross-architecture compilation,
by allowing flags like -target and --sysroot to be set for
architecture testing and compilation.

Reviewers: tberghammer, srhines, danalbert, beanz, compnerd

Subscribers: tberghammer, llvm-commits, danalbert

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

llvm-svn: 276333
2016-07-21 21:05:14 +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
Reid Kleckner f6d5475e20 Disable thread safe statics in clang-cl, they call the CRT
Also remove the needless static that was using them.

llvm-svn: 276327
2016-07-21 20:03:37 +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
Kostya Serebryany 35eeea707e [sanitizer] allocator: remove kPopulateSize and only use SizeClassMap::MaxCached; ensure that TransferBatch size is a power of two, refactor TransferBatch creation/destruction into separate functions.
llvm-svn: 276318
2016-07-21 18:47:53 +00:00
Reid Kleckner db81b3e0b2 Fix clang-cl warning and crash in sanitizers
Make kStderrFd a macro to avoid dynamic initialization of the
report_file global. This actually causes a crash at runtime, because
ASan initializes before static initializers run.

Remove an unused variable in asan_win.cc.

llvm-svn: 276314
2016-07-21 18:31:01 +00:00
Etienne Bergeron 2c781262b8 fix https://reviews.llvm.org/D22610
AppleClang can't compile the assignment expression.

llvm-svn: 276311
2016-07-21 17:58:04 +00:00
Etienne Bergeron aa76a0cf91 [compiler-rt] Fix memmove/memcpy overlap detection on windows
Summary:
The memcpy and memmove functions are the same on windows.
The overlap detection logic is incorrect.

printf-1 test:
```
stdin>:2:114: note: possible intended match here
==877412==ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x0000002bf2a8,0x0000002bf2ad) and [0x0000002bf2a9, 0x0000002bf2ae) overlap
```                                                                                                                 ^

Reviewers: rnk

Subscribers: llvm-commits, wang0109, kubabrecka, chrisha

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

llvm-svn: 276299
2016-07-21 16:06:54 +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
Daniel Sanders 8390d50e9c Revert r276256 - Attempt to fix clang-cmake-mips after r268977.
It didn't fix the problem on the buildbot. CAN_TARGET_mips64 is still true.

llvm-svn: 276258
2016-07-21 09:52:33 +00:00