summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* [sanitizer] Add a function to gather random bytesKostya Kortchinsky2017-06-211-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: AFAICT compiler-rt doesn't have a function that would return 'good' random bytes to seed a PRNG. Currently, the `SizeClassAllocator64` uses addresses returned by `mmap` to seed its PRNG, which is not ideal, and `SizeClassAllocator32` doesn't benefit from the entropy offered by its 64-bit counterpart address space, so right now it has nothing. This function aims at solving this, allowing to implement good 32-bit chunk randomization. Scudo also has a function that does this for Cookie purposes, which would go away in a later CL once this lands. This function will try the `getrandom` syscall if available, and fallback to `/dev/urandom` if not. Unfortunately, I do not have a way to implement and test a Mac and Windows version, so those are unimplemented as of now. Note that `kRandomShuffleChunks` is only used on Linux for now. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: zturner, rnk, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34412 llvm-svn: 305922
* [Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocatorAlex Shlyapnikov2017-06-201-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Move cached allocator_may_return_null flag to sanitizer_allocator.cc and provide API to consolidate and unify the behavior of all specific allocators. Make all sanitizers using CombinedAllocator to follow AllocatorReturnNullOrDieOnOOM() rules to behave the same way when OOM happens. When OOM happens, turn allocator_out_of_memory flag on regardless of allocator_may_return_null flag value (it used to not to be set when allocator_may_return_null == true). release_to_os_interval_ms and rss_limit_exceeded will likely be moved to sanitizer_allocator.cc too (later). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34310 llvm-svn: 305858
* [sanitizer] Reverting D34152Kostya Kortchinsky2017-06-141-33/+2
| | | | | | | | | | | | | | | | | Summary: This broke thread_local_quarantine_pthread_join.cc on some architectures, due to the overhead of the stashed regions. Reverting while figuring out the best way to deal with it. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34213 llvm-svn: 305404
* [sanitizer] MmapAlignedOrDie changes to reduce fragmentationKostya Kortchinsky2017-06-141-2/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The reasoning behind this change is explained in D33454, which unfortunately broke the Windows version (due to the platform not supporting partial unmapping of a memory region). This new approach changes `MmapAlignedOrDie` to allow for the specification of a `padding_chunk`. If non-null, and the initial allocation is aligned, this padding chunk will hold the address of the extra memory (of `alignment` bytes). This allows `AllocateRegion` to get 2 regions if the memory is aligned properly, and thus help reduce fragmentation (and saves on unmapping operations). As with the initial D33454, we use a stash in the 32-bit Primary to hold those extra regions and return them on the fast-path. The Windows version of `MmapAlignedOrDie` will always return a 0 `padding_chunk` if one was requested. Reviewers: alekseyshl, dvyukov, kcc Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D34152 llvm-svn: 305391
* [sanitizer-coverage] nuke more stale codeKostya Serebryany2017-06-021-3/+3
| | | | llvm-svn: 304508
* [asan] Add strndup/__strndup interceptors.Pierre Gousseau2017-06-011-0/+6
| | | | | | | | Recommit of r302781 with Vitaly Buka's fix for non zero terminated strings. Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 304399
* [compiler-rt] Replace allow_user_segv_handler=0 with kHandleSignalExclusiveVitaly Buka2017-05-251-2/+4
| | | | | | | | | | | | | | Summary: allow_user_segv_handler had confusing name did not allow to control behavior for signals separately. Reviewers: eugenis, alekseyshl, kcc Subscribers: llvm-commits, dberris, kubamracek Differential Revision: https://reviews.llvm.org/D33371 llvm-svn: 303941
* [compiler-rt] Switch handle_<signal> flags from bool to enum.Vitaly Buka2017-05-191-0/+22
| | | | | | | | | | | | Summary: We are going to make it tri-state and remove allow_user_segv_handler. Reviewers: eugenis, alekseys, kcc Subscribers: kubamracek, dberris, llvm-commits Differential Revision: https://reviews.llvm.org/D33159 llvm-svn: 303464
* [compiler-rt] Add negative test for boolean flags.Vitaly Buka2017-05-191-0/+8
| | | | | | | | | | Reviewers: eugenis, alekseyshl Subscribers: kubamracek, dberris, llvm-commits Differential Revision: https://reviews.llvm.org/D33344 llvm-svn: 303462
* [compiler-rt][cmake] Build unit tests conditionally with ↵Simon Dardis2017-05-181-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | _FILE_OFFSET_BITS=64 and _LARGEFILE_SOURCE The sanitizer library unit tests for libc can get a different definition of 'struct stat' to what the sanitizer library is built with for certain targets. For MIPS the size element of 'struct stat' is after a macro guarded explicit padding element. This patch resolves any possible inconsistency by adding the same _FILE_OFFSET_BITS=64 and _LARGE_SOURCE with the same conditions as the sanitizer library to the build flags for the unit tests. This resolves a recurring build failure on the MIPS buildbots due to 'struct stat' defintion differences. Reviewers: slthakur Differential Revision: https://reviews.llvm.org/D33131 llvm-svn: 303350
* Revert r302781 and subsequent attempts to disable part of it.Daniel Jasper2017-05-181-7/+0
| | | | | | | The Msan unit tests are still broken and by this point, I think we should start over. llvm-svn: 303339
* temporary disable stndup interceptor, due to r302781 being buggyKostya Serebryany2017-05-181-1/+2
| | | | llvm-svn: 303324
* [sanitizer] Change SizeClassAllocator32 to accept just one templateKostya Kortchinsky2017-05-151-15/+23
| | | | | | | | | | | | | | | | | | | | | Summary: With rL279771, SizeClassAllocator64 was changed to accept only one template instead of 5, for the following reasons: "First, this will make the mangled names shorter. Second, this will make adding more parameters simpler". This patch mirrors that work for SizeClassAllocator32. This is in preparation for introducing the randomization of chunks in the 32-bit SizeClassAllocator in a later patch. Reviewers: kcc, alekseyshl, dvyukov Reviewed By: alekseyshl Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D33141 llvm-svn: 303071
* [asan] Recommit of r301904: Add strndup/__strndup interceptorsPierre Gousseau2017-05-111-0/+6
| | | | | | | | | Fix undeclared __interceptor_malloc in esan_interceptors.cc Fix undeclared strnlen on OSX Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 302781
* Revert r301904 causing tsan test failure in x86_64-linux-autoconfPierre Gousseau2017-05-021-6/+0
| | | | llvm-svn: 301909
* [asan] Add strndup/__strndup interceptors if targeting linux.Pierre Gousseau2017-05-021-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D31457 llvm-svn: 301904
* [asan] replace std::random_shuffle with std::shuffle in tests since ↵Kostya Serebryany2017-02-072-2/+6
| | | | | | std::random_shuffle is being deprecated in C++17; NFC llvm-svn: 294370
* Fixup of r293882: Forgot to update sanitizer_thread_registry.test.ccKuba Mracek2017-02-021-6/+6
| | | | llvm-svn: 293884
* Recommit: Stop intercepting some malloc-related functions on FreeBSD andDimitry Andric2017-01-301-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | macOS Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Also delete the non-functional `cfree` wrapper for Windows, to fix the test cases on that platform. Reviewers: emaste, kcc, rnk Subscribers: timurrrr, eugenis, hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 llvm-svn: 293536
* Revert "Stop intercepting some malloc-related functions on FreeBSD and macOS"Evgeniy Stepanov2017-01-271-10/+0
| | | | | | | | This reverts r293337, which breaks tests on Windows: malloc-no-intercept-499eb7.o : error LNK2019: unresolved external symbol _mallinfo referenced in function _main llvm-svn: 293346
* Stop intercepting some malloc-related functions on FreeBSD and macOSDimitry Andric2017-01-271-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Reviewers: emaste, kcc Subscribers: hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 llvm-svn: 293337
* Whenever reasonable, merge ASAN quarantine batches to save memory.Alex Shlyapnikov2017-01-193-0/+197
| | | | | | | | | | | | | | | | Summary: There are cases when thread local quarantine drains almost empty quarantine batches into the global quarantine. The current approach leaves them almost empty, which might create a huge memory overhead (each batch is 4K/8K, depends on bitness). Reviewers: eugenis Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D28068 llvm-svn: 292525
* Revert "[sancov] moving sancov rt to sancov/ directory"Mike Aizatsky2017-01-121-6/+3
| | | | | | | | This reverts commit https://reviews.llvm.org/rL291734 Reason: mac breakage http://lab.llvm.org:8080/green//job/clang-stage1-configure-RA_build/28798/consoleFull#1657087648e9a0fee5-ebcc-4238-a641-c5aa112c323e llvm-svn: 291736
* [sancov] moving sancov rt to sancov/ directoryMike Aizatsky2017-01-121-3/+6
| | | | | | | | Subscribers: kubabrecka, mgorny Differential Revision: https://reviews.llvm.org/D28541 llvm-svn: 291734
* Make cmake link flag naming consistentFrancis Ricci2017-01-101-3/+3
| | | | | | | | | | | | | | | | | | | Summary: The build system was inconsistent in its naming conventions for link flags. This patch changes all uses of LINKFLAGS to LINK_FLAGS, for consistency with cmake's LINK_FLAGS property. This patch should make it easier to search the source code for uses of link flags, as well as providing the benefit of improved style and consistency. Reviewers: compnerd, beanz Subscribers: kubabrecka, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D28506 llvm-svn: 291539
* Enable weak hooks on darwinFrancis Ricci2017-01-091-0/+3
| | | | | | | | | | | | | | | | Summary: By default, darwin requires a definition for weak interface functions at link time. Adding the '-U' link flag with each weak function allows these weak interface functions to be used without definitions, which mirrors behavior on linux and windows. Reviewers: compnerd, eugenis Subscribers: kubabrecka, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D28203 llvm-svn: 291417
* [sanitizer] Use architecture/slice information when symbolizing fat Mach-O ↵Kuba Mracek2017-01-061-2/+7
| | | | | | | | | | files on Darwin This patch starts passing architecture information about a module to llvm-symbolizer and into text reports. This fixes the longstanding x86_64/x86_64h mismatch issue on Darwin. Differential Revision: https://reviews.llvm.org/D27390 llvm-svn: 291287
* [asan] Fix handling of %m in printf interceptor.Evgeniy Stepanov2016-12-271-0/+4
| | | | llvm-svn: 290632
* [sanitizer] Track architecture and UUID of modules in LoadedModuleKuba Mracek2016-12-021-0/+21
| | | | | | | | | | When we enumerate loaded modules, we only track the module name and base address, which then has several problems on macOS. Dylibs and executables often have several architecture slices and not storing which architecture/UUID is actually loaded creates problems with symbolication: A file path + offset isn't enough to correctly symbolicate, since the offset can be valid in multiple slices. This is especially common for Haswell+ X86_64 machines, where x86_64h slices are preferred, but if one is not available, a regular x86_64 is loaded instead. But the same issue exists for i386 vs. x86_64 as well. This patch adds tracking of arch and UUID for each LoadedModule. At this point, this information isn't used in reports, but this is the first step. The goal is to correctly identify which slice is loaded in symbolication, and also to output this information in reports so that we can tell which exact slices were loaded in post-mortem analysis. Differential Revision: https://reviews.llvm.org/D26632 llvm-svn: 288537
* Return memory to OS right after free (not in the async thread).Evgeniy Stepanov2016-11-291-12/+12
| | | | | | | | | | | | | | | | | | Summary: In order to avoid starting a separate thread to return unused memory to the system (the thread interferes with process startup on Android, Zygota waits for all threads to exit before fork, but this thread never exits), try to return it right after free. Reviewers: eugenis Subscribers: cryptoad, filcab, danalbert, kubabrecka, llvm-commits Patch by Aleksey Shlyapnikov. Differential Revision: https://reviews.llvm.org/D27003 llvm-svn: 288091
* rename InternalBinarySearch to InternalLowerBoundMike Aizatsky2016-11-181-17/+17
| | | | | | | | | | | | Summary: The new name better corresponds to its logic. Reviewers: kcc Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D26821 llvm-svn: 287377
* fixing binary search for cases when element is not in arrayMike Aizatsky2016-11-161-5/+46
| | | | | | | | Subscribers: kubabrecka Differential Revision: https://reviews.llvm.org/D26707 llvm-svn: 287078
* [sanitizers] Set Darwin specific linker and compiler flags for all testsAnna Zaks2016-10-261-0/+5
| | | | | | | | | | | | | | | | Looks like we are missing these flags only in tsan and sanitizer-common. This results in linker warnings in some settings as it can cause the Unit tests to be built with a different SDK version than that was used to build the runtime. For example, we are not setting the minimal deployment target on the tests but are setting the minimal deployment target for the sanitizer library, which leads to the following warning on some bots: ld: warning: object file (sanitizer_posix_test.cc.i386.o) was built for newer OSX version (10.12) than being linked (10.11). Differential Revision: https://reviews.llvm.org/D25860 https://reviews.llvm.org/D25352 llvm-svn: 285255
* [asan] Reenable 64-bit allocator on android/aarch64.Evgeniy Stepanov2016-09-151-15/+36
| | | | | | This is a re-commit of r281371, with updated tests. llvm-svn: 281674
* [compiler-rt] Do not introduce __sanitizer namespace globallyAnna Zaks2016-09-154-2/+6
| | | | | | | | | | | | The definitions in sanitizer_common may conflict with definitions from system headers because: The runtime includes the system headers after the project headers (as per LLVM coding guidelines). lib/sanitizer_common/sanitizer_internal_defs.h pollutes the namespace of everything defined after it, which is all/most of the sanitizer .h and .cc files and the included system headers with: using namespace __sanitizer; // NOLINT This patch solves the problem by introducing the namespace only within the sanitizer namespaces as proposed by Dmitry. Differential Revision: https://reviews.llvm.org/D21947 llvm-svn: 281657
* [sanitizer] Test the allocator with the ASan win64 memory constantsReid Kleckner2016-09-151-2/+2
| | | | | | | | These got out of sync and the tests were failing for me locally. We assume a 47 bit address space in ASan, so we should do the same in the tests. llvm-svn: 281622
* [sanitizer] fix an allocator bug where the allocated memory may overlap with ↵Kostya Serebryany2016-09-091-1/+18
| | | | | | the free array (kudos to Kostya Korcthinsky). Also make sure that the allocator does not mmap more than requested. Test both. llvm-svn: 281103
* [sanitizer] extend SizeClassMap to take more template parameters, add ↵Kostya Serebryany2016-08-311-10/+41
| | | | | | VeryCompactSizeClassMap for testing purposes llvm-svn: 280266
* [sanitizer] enable random shuffling the memory chunks inside the allocator, ↵Kostya Serebryany2016-08-262-0/+7
| | | | | | under a flag. Set this flag for the scudo allocator, add a test. llvm-svn: 279793
* [sanitizer] change SizeClassAllocator64 to accept just one template ↵Kostya Serebryany2016-08-252-16/+57
| | | | | | parameter instead of 5. First, this will make the mangled names shorter. Second, this will make adding more parameters simpler. llvm-svn: 279771
* [sanitizer] re-apply r279572 and r279595 reverted in r279643: change the ↵Kostya Serebryany2016-08-241-5/+12
| | | | | | 64-bit allocator to use a single array for free-d chunks instead of a lock-free linked list of tranfer batches. This change simplifies the code, makes the allocator more 'hardened', and will allow simpler code to release RAM to OS. This may also slowdown malloc stress tests due to lock contension, but I did not observe noticeable slowdown on various real multi-threaded benchmarks. llvm-svn: 279664
* Revert r279572 "[sanitizer] change the 64-bit..." because of failures on ubsanVitaly Buka2016-08-241-12/+5
| | | | | | This reverts commit r279572 and r279595. llvm-svn: 279643
* [sanitizer] change the 64-bit allocator to use a single array for free-d ↵Kostya Serebryany2016-08-231-5/+12
| | | | | | chunks instead of a lock-free linked list of tranfer batches. This change simplifies the code, makes the allocator more 'hardened', and will allow simpler code to release RAM to OS. This may also slowdown malloc stress tests due to lock contension, but I did not observe noticeable slowdown on various real multi-threaded benchmarks. llvm-svn: 279572
* [sanitizer] adding a threaded performance stress test for malloc (useful for ↵Kostya Serebryany2016-08-231-0/+37
| | | | | | manual analysis of malloc performance) llvm-svn: 279570
* [sanitizer] use 32-bit offset instead of 64-bit pointers in the 64-bit ↵Kostya Serebryany2016-08-091-1/+1
| | | | | | allocator's transfer batches. This saves 2x memory for the transfer batches (up to ~1.5% overall in some cases) llvm-svn: 278179
* [sanitizer] allocator: move TransferBatch into ↵Kostya Serebryany2016-08-061-1/+1
| | | | | | SizeClassAllocator64/SizeClassAllocator32 because we actually need different iplementations for the 64- and 32-bit case. NFC; the following patches will make the TransferBatch implementations differ llvm-svn: 277899
* Disable a few more flaky asan64 tests.Nico Weber2016-08-051-0/+12
| | | | llvm-svn: 277886
* Disable a few win asan64 tests that don't reliably pass, ↵Nico Weber2016-08-051-0/+12
| | | | | | https://reviews.llvm.org/D23230 llvm-svn: 277882
* [compiler-rt] Fix memory allocator for dynamic address spaceEtienne Bergeron2016-08-041-1/+31
| | | | | | | | | | | | | | | | | | | | | | | Summary: The sanitizer allocators can works with a dynamic address space (i.e. specified with ~0ULL). Unfortunately, the code was broken on GetMetadata and GetChunkIdx. The current patch is moving the Win64 memory test to a dynamic address space. There is a migration to move every concept to a dynamic address space on windows. To have a better coverage, the unittest are now testing dynamic address space on other platforms too. Reviewers: rnk, kcc Subscribers: kubabrecka, dberris, llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D23170 llvm-svn: 277745
* XFAIL one sanitizer symbolizer test for FreeBSDDimitry Andric2016-07-311-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Due to a QoI issuse in FreeBSD's libcxxrt-based demangler, one sanitizer symbolizer test consistently appears to fail: Value of: DemangleSwiftAndCXX("foo") Actual: "float" Expected: "foo" This is because libcxxrt's __cxa_demangle() incorrectly demangles the "foo" identifier to "float". It should return an error instead. For now, XFAIL this particular test for FreeBSD, until we can fix libcxxrt properly (which might take some time to coordinate with upstream). Reviewers: rnk, zaks.anna, emaste Subscribers: emaste, llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D23001 llvm-svn: 277297
OpenPOWER on IntegriCloud