summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [GWP-ASan] 32-bit test pointers, allow multi-init for test.Mitch Phillips2019-12-091-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: GWP-ASan test currently fail on 32-bit platforms, as some of the pointers are larger than `uintptr_t` on 32-bit platforms. Fix up all those instances. Also add an uncompress varint test where the result is an underflow. Furthermore, allow multi-init for testing. Each gtest when running `check-gwp_asan` apparently runs in its own instance, but when integrating these tests into Android, this behaviour isn't the same. We remove the global multi-init check here, to allow for testing to work elsewhere, and we're not really worried about multi-init anyway as it's part of our contract with the allocator. Reviewers: eugenis, vlad.tsyrklevich Reviewed By: eugenis Subscribers: #sanitizers, llvm-commits, pcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71121
* [GWP-ASan] Add GWP_ASAN_ prefix to macros.Mitch Phillips2019-11-251-1/+1
| | | | | | | | | | | | | | | | | Summary: When platforms use their own `LIKELY()` definitions, it can be quite troublesome to ensure they don't conflict with the GWP-ASan internal definitions. Just force the GWP_ASAN_ prefix to help this issue. Reviewers: eugenis Reviewed By: eugenis Subscribers: #sanitizers, llvm-commits, cferris, pcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D70683
* [GWP-ASan] Fix typos.Mitch Phillips2019-08-201-3/+3
| | | | | | | | | | | | | | | | | | Summary: Fix two spelling typos and de-indent a guarded #define so that it's consistent with clang-format. Reviewers: vitalybuka Reviewed By: vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66311 llvm-svn: 369433
* [GWP-ASan] Implement stack frame compression.Mitch Phillips2019-08-151-12/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch introduces stack frame compression to GWP-ASan. Each stack frame is variable-length integer encoded as the difference between frame[i] and frame[i - 1]. Furthermore, we use zig-zag encoding on the difference to ensure that negative differences are also encoded into a relatively small number of bytes. Examples of what the compression looks like can be seen in `gwp_asan/tests/compression.cpp`. This compression can reduce the memory consumption cost of stack traces by ~50%. Reviewers: vlad.tsyrklevich Reviewed By: vlad.tsyrklevich Subscribers: mgorny, #sanitizers, llvm-commits, eugenis, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66189 llvm-svn: 369048
* [GWP-ASan] Update backtrace function signature.Mitch Phillips2019-08-121-15/+18
| | | | | | | | | | | | | | | | | | | | Summary: Updates the function signature and comments for backtracing (and printing backtraces). This update brings GWP-ASan in line with future requirements for stack frame compression, wherein the length of the trace is provided explicitly, rather than relying on nullptr-termination. Reviewers: vlad.tsyrklevich Reviewed By: vlad.tsyrklevich Subscribers: #sanitizers, llvm-commits, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D66099 llvm-svn: 368619
* Explicitly define __STDC_FORMAT_MACROS for PRIu64Mitch Phillips2019-07-111-0/+6
| | | | | | | | | | | | | | | | | | | | Summary: Builds are failing on RHEL machines because of PRIu64. lvm/projects/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp:420:50: error: expected ')' `snprintf(ThreadBuffer, kThreadBufferLen, "%" PRIu64, ThreadID);` inttypes.h in RHEL uses PRIu64 macros only when __STDC_FORMAT_MACROS is defined. Author: DTharun Reviewers: hctim Reviewed By: hctim Differential Revision: https://reviews.llvm.org/D64388 llvm-svn: 365801
* [GWP-ASan] Add generic unwinders and structure backtrace output.Mitch Phillips2019-07-021-82/+128
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds two flavours of generic unwinder and all the supporting cruft. If the supporting allocator is okay with bringing in sanitizer_common, they can use the fast frame-pointer based unwinder from sanitizer_common. Otherwise, we also provide the backtrace() libc-based unwinder as well. Of course, the allocator can always specify its own unwinder and unwinder-symbolizer. The slightly changed output format is exemplified in the first comment on this patch. It now better incorporates backtrace information, and displays allocation details on the second line. Reviewers: eugenis, vlad.tsyrklevich Reviewed By: eugenis, vlad.tsyrklevich Subscribers: srhines, kubamracek, mgorny, cryptoad, #sanitizers, llvm-commits, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D63841 llvm-svn: 364941
* [GWP-ASan] Guard against recursive allocs. Pack TLS for perf.Mitch Phillips2019-06-251-4/+29
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Add a recursivity guard for GPA::allocate(). This means that any recursive allocations will fall back to the supporting allocator. In future patches, we will introduce stack trace collection support. The unwinder will be provided by the supporting allocator, and we can't guarantee they don't call malloc() (e.g. backtrace() on posix may call dlopen(), which may call malloc(). Furthermore, this patch packs the new TLS recursivity guard into a thread local struct, so that TLS variables should be hopefully not fall across cache lines. Reviewers: vlad.tsyrklevich, morehouse, eugenis Reviewed By: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits, eugenis Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D63736 llvm-svn: 364356
* Fixup files added in r362636 to build with gcc 5.4. NFCIDouglas Yung2019-06-061-11/+11
| | | | llvm-svn: 362682
* [GWP-ASan] Core Guarded Pool Allocator [4].Mitch Phillips2019-06-051-0/+433
Summary: See D60593 for further information. This patch introduces the core of GWP-ASan, being the guarded pool allocator. This class contains the logic for creating and maintaining allocations in the guarded pool. Its public interface is to be utilised by supporting allocators in order to provide sampled guarded allocation behaviour. This patch also contains basic functionality tests of the allocator as unittests. The error-catching behaviour will be tested in upcoming patches that use Scudo as an implementing allocator. Reviewers: vlad.tsyrklevich, eugenis, jfb Reviewed By: vlad.tsyrklevich Subscribers: dexonsmith, kubamracek, mgorny, cryptoad, jfb, #sanitizers, llvm-commits, morehouse Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D62872 llvm-svn: 362636
OpenPOWER on IntegriCloud