Commit Graph

541 Commits

Author SHA1 Message Date
Dan Liew b684c1a50f Add a `Symbolizer::GetEnvP()` method that allows symbolizer implementations to customise the environment of the symbolizer binary.
Summary:
This change introduces the `Symbolizer::GetEnvP()` method that returns a
pointer to environment array used for spawning the symbolizer process.
The motivation is to allow implementations to customise the environment
if required.  The default implementation just returns
`__sanitizer::GetEnviron()` which (provided it's implemented) should
preserve the existing behaviours of the various implementations.

This change has been plumbed through the `internal_spawn(...)` and
`StartSubprocess(...)` process spawning implementations.

For the `StartSubprocess()` implementation we need to call `execve()`
rather than `execv()` to pass the environment. However, it appears that
`internal_execve(...)` exists in sanitizer_common so this patch use that
which seems like a nice clean up.

Support in the Windows implementation of
`SymbolizerProcess:StartSymbolizerSubprocess()` has not been added
because the Windows sanitizer runtime doesn't implement `GetEnviron()`.

rdar://problem/58789439

Reviewers: kubamracek, yln, dvyukov, vitalybuka, eugenis, phosek, aizatsky, rnk

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D76666
2020-03-24 15:41:46 -07:00
Vitaly Buka f0714cbb6a [sanitizer] Fix warning on windows
Return value is not used anyway as PTHREAD_JOIN is not implemented.
2020-03-16 19:17:03 -07:00
Fangrui Song 33a1b3d8fc [sanitizer] Link Sanitizer-x86_64-Test-Nolibc with -static
Pass -static so that clang will not pass -Wl,--dynamic-linker,... to the
linker. The test is not expected to run under a ld.so. (Technically it
works under a ld.so but glibc expects to see a PT_DYNAMIC. lld
intentionally does not follow GNU ld's complex rules regarding
PT_DYNAMIC.)

This allows commit 1417558e4a to be
relanded.
2019-12-27 15:25:08 -08:00
Igor Kudrin a57adc7a0b [sanitizer] Construct InternalMmapVector without memory allocation.
Construction of InternalMmapVector is often followed by a call to
reserve(), which may result in immediate reallocation of the memory
for the internal storage. This patch delays that allocation until
it is really needed.

Differential Revision: https://reviews.llvm.org/D71342
2019-12-17 15:03:23 +07:00
Igor Kudrin 3a713ae5fa [SanitizerCommon] Reduce wasting memory in LowLevelAllocator.
MmapOrDie allocates memory multiple to page size. LowLevelAllocator
should use all that memory for the internal buffer because there are
chances that subsequent requests may be small enough to fit in that
space.

Differential Revision: https://reviews.llvm.org/D71275
2019-12-11 12:44:55 +07:00
Alexandre Ganea 9cc3ebf8b7 Fix warning: format specifies type 'unsigned long' but the argument has type 'unsigned long long' [-Wformat] 2019-11-04 14:42:07 -05:00
Vitaly Buka d2af368aee [compiler-rt] Remove some cpplint filters
llvm-svn: 371704
2019-09-12 02:20:36 +00:00
Vitaly Buka c0fa632236 Remove NOLINTs from compiler-rt
llvm-svn: 371687
2019-09-11 23:19:48 +00:00
Vitaly Buka 93a3cbc746 Revert r369472 and r369441
check-sanitizer does not work on Linux

llvm-svn: 369495
2019-08-21 05:06:21 +00:00
Sebastian Pop 63487bfec9 [AArch64] Speed-up leak and address sanitizers on AArch64 for 48-bit VMA
This patch fixes https://github.com/google/sanitizers/issues/703
On a Graviton-A1 aarch64 machine with 48-bit VMA,
the time spent in LSan and ASan reduced from 2.5s to 0.01s when running

clang -fsanitize=leak compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out
clang -fsanitize=address compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out

With this patch, LSan and ASan create both the 32 and 64 allocators and select
at run time between the two allocators following a global variable that is
initialized at init time to whether the allocator64 can be used in the virtual
address space.

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

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

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

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

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

The patch adjusts the test case to allow for this.

Tested on x86_64-pc-solaris2.11.

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

llvm-svn: 367705
2019-08-02 18:55:22 +00:00
Nico Weber 45ff4868c4 compiler-rt: Try to appease lint script.
A bot complains:

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

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

llvm-svn: 367493
2019-07-31 23:34:07 +00:00
Nico Weber d6d569fc06 compiler-rt: Rename .cc file in lib/sanitizer_common/tests to .cpp
See https://reviews.llvm.org/D58620 for discussion, and for the commands
I ran. In addition I also ran

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

and manually updated references to renamed files found by that.

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

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

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

llvm-svn: 367463
2019-07-31 18:51:27 +00:00
Hubert Tong 50721b27c4 [compiler-rt][tests] Propagate COMPILER_RT_UNITTEST_LINK_FLAGS
`COMPILER_RT_UNITTEST_LINK_FLAGS` is dropped in many places, unlike
`COMPILER_RT_UNITTEST_CFLAGS`. This patch attempts to remove that
inconsistency.

Previously reviewed as part of D58951.

Reviewers: sfertile, peter.smith, pzheng, phosek, Hahnfeld, nemanjai, jasonliu

Reviewed By: sfertile

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

Tags: #llvm, #sanitizers

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

llvm-svn: 359733
2019-05-01 22:25:16 +00:00
Vitaly Buka 9ef838761e [sanitizer][NFC] Remove unneeded SizeClassAllocatorLocalCache
llvm-svn: 359729
2019-05-01 21:23:07 +00:00
Vitaly Buka 20c5676416 [sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocator
They need to have same AddressSpaceView and MapUnmapCallback.

Reviewers: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 359719
2019-05-01 19:41:54 +00:00
Vitaly Buka 76931df40f [sanitizer][NFC] Get type of AllocatorCache from CombinedAllocator
Reviewers: eugenis, cryptoad, kcc

Reviewed By: kcc

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

Tags: #sanitizers, #llvm

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

llvm-svn: 359715
2019-05-01 19:30:49 +00:00
Mitch Phillips 40f98d4b78 Added test.
llvm-svn: 359632
2019-04-30 23:07:12 +00:00
Vitaly Buka 0f21545a3c [sanitizer] Calculate SizeClassAllocator32::ByteMap type from Params::kSpaceSize and Params::kRegionSizeLog
Reviewers: eugenis

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

Tags: #sanitizers, #llvm

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

llvm-svn: 359374
2019-04-27 06:30:52 +00:00
Vitaly Buka 077c502ddc Implement __sanitizer::conditional<B, T, F>
llvm-svn: 359334
2019-04-26 18:22:55 +00:00
Vitaly Buka efc94feef9 [NFC] Remove ::kForTest from AP64, it does not use it.
llvm-svn: 359323
2019-04-26 17:04:05 +00:00
Vitaly Buka 1a607ff043 [lsan] Use SANITIZER_WORDSIZE when selecting ByteMap
Originally this code was added for 64-bit platform and it was never update.
Add static_assert to validate type of ByteMap.

llvm-svn: 359286
2019-04-26 08:24:38 +00:00
Vitaly Buka d8e9c3a999 Revert "[lsan] Use SANITIZER_WORDSIZE when selecting ByteMap"
New static_assert fails on a bot.

This reverts commit r359269.

llvm-svn: 359276
2019-04-26 05:19:32 +00:00
Vitaly Buka 3db2a7a04f [lsan] Use SANITIZER_WORDSIZE when selecting ByteMap
Originally this code as added for 64-bit platform and was never changed.
Add static_assert to make sure that we have correct map on all platforms.

llvm-svn: 359269
2019-04-26 04:20:27 +00:00
Julian Lettner a30b116e6f [NFC][Sanitizer] Replace last uses of old Unwind API
Replace remaining uses of old Unwind API in unit tests.

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

Reviewed By: vitalybuka

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

llvm-svn: 355242
2019-03-01 23:50:47 +00:00
H.J. Lu fadb22f4e2 Revert "Revert "[sanitizers] Restore internal_readlink for x32""
This reverts revision 354601 and disables ReadBinaryNameCached check on
Windows since Windows has no working ReadBinaryName.

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

llvm-svn: 355129
2019-02-28 19:34:01 +00:00
Julian Lettner 1e4f073582 [NFC][Sanitizer] Rename BufferedStackTrace::FastUnwindStack
FastUnwindStack -> UnwindFast
SlowUnwindStack -> UnwindSlow
Stack is redundant, verb should come first.

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

Reviewers: vitalybuka

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

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

llvm-svn: 354601
2019-02-21 17:06:23 +00:00
H.J. Lu 6716f4af81 [sanitizers] Restore internal_readlink for x32
r316591 has

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

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

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

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

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

llvm-svn: 354451
2019-02-20 11:43:43 +00:00
Kostya Serebryany 64c7b060bc [sanitizers] add a regression test for the bug fixed in r354366
llvm-svn: 354373
2019-02-19 19:28:08 +00:00
Richard Smith 1dcff8d17c Fix invalid code that Clang trunk will soon diagnose.
There is an ambiguity between ::SizeClassMap (the typedef declared near
the start of this file) and __sanitizer::SizeClassMap (found by the
'using namespace __sanitizer;' near the start of this file).

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

llvm-svn: 354174
2019-02-15 21:48:57 +00:00
Dmitry Vyukov baf2f35ec4 sanitizers: Introduce ThreadType enum
Replace bool workerthread flag with ThreadType enum.
This change is preparation for fiber support.

[dvyukov: fixed build of sanitizer_thread_registry_test.cc]

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

llvm-svn: 353390
2019-02-07 11:01:22 +00:00
Igor Kudrin 0f13000958 [compiler-rt] Fix reporting unrecognized flags in unit tests.
Previously, the warning messages might be issued within a wrong test case.

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

llvm-svn: 352447
2019-01-29 02:31:57 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Dan Liew d2c6af7358 Introduce `AddressSpaceView` template parameter to `SizeClassAllocator64`.
Summary:
This is a follow up patch to r349138.

This patch makes a `AddressSpaceView` a type declaration in the
allocator parameters used by `SizeClassAllocator64`. For ASan, LSan, and
the unit tests the AP64 declarations have been made templated so that
`AddressSpaceView` can be changed at compile time. For the other
sanitizers we just hard-code `LocalAddressSpaceView` because we have no
plans to use these allocators in an out-of-process manner.

rdar://problem/45284065

Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 349954
2018-12-21 21:09:31 +00:00
Dan Liew 41fec1bfc5 Introduce `AddressSpaceView` template parameter to `SizeClassAllocator32`, `FlatByteMap`, and `TwoLevelByteMap`.
Summary:
This is a follow up patch to r346956 for the `SizeClassAllocator32`
allocator.

This patch makes `AddressSpaceView` a template parameter both to the
`ByteMap` implementations (but makes `LocalAddressSpaceView` the
default), some `AP32` implementations and is used in `SizeClassAllocator32`.
The actual changes to `ByteMap` implementations and
`SizeClassAllocator32` are very simple. However the patch is large
because it requires changing all the `AP32` definitions, and users of
those definitions.

For ASan and LSan we make `AP32` and `ByteMap` templateds type that take
a single `AddressSpaceView` argument. This has been done because we will
instantiate the allocator with a type that isn't `LocalAddressSpaceView`
in the future patches. For the allocators used in the other sanitizers
(i.e. HWAsan, MSan, Scudo, and TSan) use of `LocalAddressSpaceView` is
hard coded because we do not intend to instantiate the allocators with
any other type.

In the cases where untemplated types have become templated on a single
`AddressSpaceView` parameter (e.g. `PrimaryAllocator`) their name has
been changed to have a `ASVT` suffix (Address Space View Type) to
indicate they are templated.  The only exception to this are the `AP32`
types due to the desire to keep the type name as short as possible.

In order to check that template is instantiated in the correct a way a
`static_assert(...)` has been added that checks that the
`AddressSpaceView` type used by `Params::ByteMap::AddressSpaceView` matches
the `Params::AddressSpaceView`. This uses the new `sanitizer_type_traits.h`
header.

rdar://problem/45284065

Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov

Subscribers: mgorny, llvm-commits, #sanitizers

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

llvm-svn: 349138
2018-12-14 09:03:18 +00:00
Dan Liew c2e2dd43f0 Implement a small subset of the C++ `type_traits` header inside sanitizer_common so we can avoid depending on system C++ headers.
Summary:
In particular we implement the `is_same<T,U>` templated type. This is
useful for doing compile-time comparison of types in `static_assert`s.
The plan is to use this in another patch (
https://reviews.llvm.org/D54904 ).

Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov

Subscribers: mgorny, #sanitizers, llvm-commits

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

llvm-svn: 349077
2018-12-13 19:55:36 +00:00
Dan Liew f73b782105 [SanitizerCommon] Test `CombinedAllocator::ForEachChunk()` in unit tests.
Summary:

Previously we weren't testing this function in the unit tests.

Reviewers: kcc, cryptoad, dvyukov, eugenis, kubamracek

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 348260
2018-12-04 14:03:55 +00:00
Kuba Mracek 265cd31fbf Fix filtering of sanitizer_common unittest architectures on Darwin.
llvm-svn: 347622
2018-11-27 01:37:08 +00:00
Reid Kleckner 3e27306565 [asan] Remove stale -fno-exceptions flag in sanitizer_common as well
llvm-svn: 345685
2018-10-31 00:35:46 +00:00
Kostya Kortchinsky 67392feb49 [sanitizer] Disable failing Android test after D52371
Summary:
The default values used for Space/Size for the new SizeClassMap do not work
with Android. The Compact map appears to be in the same boat.
Disable the test on Android for now to turn the bots green, but there is no
reason Compact & Dense should not have an Android test.
Added a FIXME, I will revisit this soon.

Reviewers: eugenis

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

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

llvm-svn: 343252
2018-09-27 19:15:40 +00:00
Kostya Kortchinsky 7685301d79 [sanitizer] Introduce a new SizeClassMap with minimal amount of cached entries
Summary:
_Note_: I am not attached to the name `DenseSizeClassMap`, so if someone has a
better idea, feel free to suggest it.

The current pre-defined `SizeClassMap` hold a decent amount of cached entries,
either in cheer number of, or in amount of memory cached.

Empirical testing shows that more compact per-class arrays (whose sizes are
directly correlated to the number of cached entries) are beneficial to
performances, particularly in highly threaded environments.

The new proposed `SizeClassMap` has the following properties:
```
c00 => s: 0 diff: +0 00% l 0 cached: 0 0; id 0
c01 => s: 16 diff: +16 00% l 4 cached: 8 128; id 1
c02 => s: 32 diff: +16 100% l 5 cached: 8 256; id 2
c03 => s: 48 diff: +16 50% l 5 cached: 8 384; id 3
c04 => s: 64 diff: +16 33% l 6 cached: 8 512; id 4
c05 => s: 80 diff: +16 25% l 6 cached: 8 640; id 5
c06 => s: 96 diff: +16 20% l 6 cached: 8 768; id 6
c07 => s: 112 diff: +16 16% l 6 cached: 8 896; id 7

c08 => s: 128 diff: +16 14% l 7 cached: 8 1024; id 8
c09 => s: 144 diff: +16 12% l 7 cached: 7 1008; id 9
c10 => s: 160 diff: +16 11% l 7 cached: 6 960; id 10
c11 => s: 176 diff: +16 10% l 7 cached: 5 880; id 11
c12 => s: 192 diff: +16 09% l 7 cached: 5 960; id 12
c13 => s: 208 diff: +16 08% l 7 cached: 4 832; id 13
c14 => s: 224 diff: +16 07% l 7 cached: 4 896; id 14
c15 => s: 240 diff: +16 07% l 7 cached: 4 960; id 15

c16 => s: 256 diff: +16 06% l 8 cached: 4 1024; id 16
c17 => s: 320 diff: +64 25% l 8 cached: 3 960; id 49
c18 => s: 384 diff: +64 20% l 8 cached: 2 768; id 50
c19 => s: 448 diff: +64 16% l 8 cached: 2 896; id 51

c20 => s: 512 diff: +64 14% l 9 cached: 2 1024; id 48
c21 => s: 640 diff: +128 25% l 9 cached: 1 640; id 49
c22 => s: 768 diff: +128 20% l 9 cached: 1 768; id 50
c23 => s: 896 diff: +128 16% l 9 cached: 1 896; id 51

c24 => s: 1024 diff: +128 14% l 10 cached: 1 1024; id 48
c25 => s: 1280 diff: +256 25% l 10 cached: 1 1280; id 49
c26 => s: 1536 diff: +256 20% l 10 cached: 1 1536; id 50
c27 => s: 1792 diff: +256 16% l 10 cached: 1 1792; id 51

c28 => s: 2048 diff: +256 14% l 11 cached: 1 2048; id 48
c29 => s: 2560 diff: +512 25% l 11 cached: 1 2560; id 49
c30 => s: 3072 diff: +512 20% l 11 cached: 1 3072; id 50
c31 => s: 3584 diff: +512 16% l 11 cached: 1 3584; id 51

c32 => s: 4096 diff: +512 14% l 12 cached: 1 4096; id 48
c33 => s: 5120 diff: +1024 25% l 12 cached: 1 5120; id 49
c34 => s: 6144 diff: +1024 20% l 12 cached: 1 6144; id 50
c35 => s: 7168 diff: +1024 16% l 12 cached: 1 7168; id 51

c36 => s: 8192 diff: +1024 14% l 13 cached: 1 8192; id 48
c37 => s: 10240 diff: +2048 25% l 13 cached: 1 10240; id 49
c38 => s: 12288 diff: +2048 20% l 13 cached: 1 12288; id 50
c39 => s: 14336 diff: +2048 16% l 13 cached: 1 14336; id 51

c40 => s: 16384 diff: +2048 14% l 14 cached: 1 16384; id 48
c41 => s: 20480 diff: +4096 25% l 14 cached: 1 20480; id 49
c42 => s: 24576 diff: +4096 20% l 14 cached: 1 24576; id 50
c43 => s: 28672 diff: +4096 16% l 14 cached: 1 28672; id 51

c44 => s: 32768 diff: +4096 14% l 15 cached: 1 32768; id 48
c45 => s: 40960 diff: +8192 25% l 15 cached: 1 40960; id 49
c46 => s: 49152 diff: +8192 20% l 15 cached: 1 49152; id 50
c47 => s: 57344 diff: +8192 16% l 15 cached: 1 57344; id 51

c48 => s: 65536 diff: +8192 14% l 16 cached: 1 65536; id 48
c49 => s: 81920 diff: +16384 25% l 16 cached: 1 81920; id 49
c50 => s: 98304 diff: +16384 20% l 16 cached: 1 98304; id 50
c51 => s: 114688 diff: +16384 16% l 16 cached: 1 114688; id 51

c52 => s: 131072 diff: +16384 14% l 17 cached: 1 131072; id 48
c53 => s: 64 diff: +0 00% l 0 cached: 8 512; id 4
Total cached: 864928 (152/432)
```

It holds a bit less of 1MB of cached entries at most, and the cache fits in a 
page.

The plan is to use this map by default for Scudo once we make sure that there
is no unforeseen impact for any of current use case.

Benchmarks give the most increase in performance (with Scudo) when looking at
highly threaded/contentious environments. For example, rcp2-benchmark
experiences a 10K QPS increase (~3%), and a decrease of 50MB for the max RSS
(~10%). On platforms like Android where we only have a couple of caches,
performance remain similar.

Reviewers: eugenis, kcc

Reviewed By: eugenis

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

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

llvm-svn: 343246
2018-09-27 18:20:42 +00:00
Evgeniy Stepanov 090f0f9504 [hwasan] Record and display stack history in stack-based reports.
Summary:
Display a list of recent stack frames (not a stack trace!) when
tag-mismatch is detected on a stack address.

The implementation uses alignment tricks to get both the address of
the history buffer, and the base address of the shadow with a single
8-byte load. See the comment in hwasan_thread_list.h for more
details.

Developed in collaboration with Kostya Serebryany.

Reviewers: kcc

Subscribers: srhines, kubamracek, mgorny, hiraditya, jfb, llvm-commits

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

llvm-svn: 342923
2018-09-24 23:03:34 +00:00
Evgeniy Stepanov 20c4999e8b Revert "[hwasan] Record and display stack history in stack-based reports."
This reverts commit r342921: test failures on clang-cmake-arm* bots.

llvm-svn: 342922
2018-09-24 22:50:32 +00:00
Evgeniy Stepanov 9043e17edd [hwasan] Record and display stack history in stack-based reports.
Summary:
Display a list of recent stack frames (not a stack trace!) when
tag-mismatch is detected on a stack address.

The implementation uses alignment tricks to get both the address of
the history buffer, and the base address of the shadow with a single
8-byte load. See the comment in hwasan_thread_list.h for more
details.

Developed in collaboration with Kostya Serebryany.

Reviewers: kcc

Subscribers: srhines, kubamracek, mgorny, hiraditya, jfb, llvm-commits

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

llvm-svn: 342921
2018-09-24 21:38:42 +00:00
Kostya Serebryany d709a36084 [sanitizer] reapply r340884 'Add a RingBuffer class to sanitizer_common', with fixes for Windows
llvm-svn: 340969
2018-08-29 21:00:01 +00:00
Hans Wennborg 61cbae90a5 Revert r340884 "Add a RingBuffer class to sanitizer_common"
The test doesn't pass on Windows, where sizeof(long) == 4 also
on 64-bit, and so it isn't a multiple of sizeof(void*).

This also reverts the follow-up r340886.

> Summary: a constrained RingBuffer optimized for fast push
>
> Reviewers: eugenis
>
> Reviewed By: eugenis
>
> Subscribers: kubamracek, mgorny, delcypher, #sanitizers, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D51196

llvm-svn: 340924
2018-08-29 12:40:29 +00:00
Kostya Serebryany 67d0488934 [sanitizer] fix a test
llvm-svn: 340886
2018-08-28 23:50:59 +00:00
Kostya Serebryany 66eefee7ed Add a RingBuffer class to sanitizer_common
Summary: a constrained RingBuffer optimized for fast push

Reviewers: eugenis

Reviewed By: eugenis

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

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

llvm-svn: 340884
2018-08-28 23:32:56 +00:00