summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
Commit message (Collapse)AuthorAgeFilesLines
* [RISCV-V] Provide muldi3 builtin assembly implementationkamlesh kumar2020-06-253-19/+46
| | | | | | | | | | Provides an assembly implementation of muldi3 for RISC-V, to solve bug 43388. Since the implementation is the same as for mulsi3, that code was moved to `riscv/int_mul_impl.inc` and is now reused by both `mulsi3.S` and `muldi3.S`. Differential Revision: https://reviews.llvm.org/D80465 (cherry picked from commit e31ccee1b01acf703889312ee86023ff87bd39fe)
* [profile] Don't crash when forking in several threadsCalixte Denizet2020-05-071-2/+52
| | | | | | | | | | | | | | | | | | | Summary: When forking in several threads, the counters were written out in using the same global static variables (see GCDAProfiling.c): that leads to crashes. So when there is a fork, the counters are resetted in the child process and they will be dumped at exit using the interprocess file locking. When there is an exec, the counters are written out and in case of failures they're resetted. Reviewers: jfb, vsk, marco-c, serge-sans-paille Reviewed By: marco-c, serge-sans-paille Subscribers: llvm-commits, serge-sans-paille, dmajor, cfe-commits, hiraditya, dexonsmith, #sanitizers, marco-c, sylvestre.ledru Tags: #sanitizers, #clang, #llvm Differential Revision: https://reviews.llvm.org/D78477 (cherry picked from commit bec223a9bc4eb9747993ee9a4c1aa135c32123e6)
* Revert "[compiler-rt] Add a critical section when flushing gcov counters"Hans Wennborg2020-02-261-24/+1
| | | | | | See the discussion on PR44792. This reverts commit 02ce9d8ef5a84bc884de4105eae5f8736ef67634.
* [TSan] Ensure we can compile the runtime with older SDKsJulian Lettner2020-02-051-1/+8
| | | | | | | | | | | | | | | | | | | | | One of my changes [1] included in this release silently bumped the minimal macOS SDK required for building the TSan runtime to SDK 10.12. Let's ensure release 10 does not unexpectedly break builders with old SDKs and add proper minimal SDK checking in CMake for subsequent releases. This fix `#ifdef`s out interceptors for newer APIs. Note that the resulting TSan runtime is less complete: when these newer APIs are used TSan will report false positives. Fixes llvm 10 release blocker: #44682 https://bugs.llvm.org/show_bug.cgi?id=44682 [1] 894abb46f891cba2e0ef581650f27f512a7824b4 Reviewed By: dmajor Differential Revision: https://reviews.llvm.org/D74059
* [scudo][standalone] Fork supportKostya Kortchinsky2020-01-1418-42/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: fork() wasn't well (or at all) supported in Scudo. This materialized in deadlocks in children. In order to properly support fork, we will lock the allocator pre-fork and unlock it post-fork in parent and child. This is done via a `pthread_atfork` call installing the necessary handlers. A couple of things suck here: this function allocates - so this has to be done post initialization as our init path is not reentrance, and it doesn't allow for an extra pointer - so we can't pass the allocator we are currently working with. In order to work around this, I added a post-init template parameter that gets executed once the allocator is initialized for the current thread. Its job for the C wrappers is to install the atfork handlers. I reorganized a bit the impacted area and added some tests, courtesy of cferris@ that were deadlocking prior to this fix. Subscribers: jfb, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D72470
* [profile] Support merge pool size >= 10Fangrui Song2020-01-121-19/+27
| | | | | | | | | | | The executable acquires an advisory record lock (`fcntl(fd, F_SETLKW, *)`) on a profile file. Merge pool size >= 10 may be beneficial when the concurrency is large. Also fix a small problem about snprintf. It can cause the filename to be truncated after %m. Reviewed By: davidxl Differential Revision: https://reviews.llvm.org/D71970
* Summary: update macro for OFF_T so that sanitizer works on AARCH64.Lirong Yuan2020-01-105-12/+5
| | | | | | | | | | | | Reviewers: vitalybuka, eugenis, MaskRay Reviewed By: eugenis, MaskRay Subscribers: MaskRay, kristof.beyls, #sanitizers, llvm-commits, jkz, scw Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D72367
* [msan] Fix underflow in qsort interceptor.Evgenii Stepanov2020-01-061-10/+14
|
* [msan] Check qsort input.Evgenii Stepanov2020-01-061-0/+14
| | | | | | | | | | | | | | | | | | Summary: Qsort interceptor suppresses all checks by unpoisoning the data in the wrapper of a comparator function, and then unpoisoning the output array as well. This change adds an explicit run of the comparator on all elements of the input array to catch any sanitizer bugs. Reviewers: vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71780
* [compiler-rt] [netbsd] Switch to syscall for ThreadSelfTlsTcb()Kamil Rytarowski2020-01-031-11/+2
| | | | | This change avoids using internal, namespaced per-CPU calls that are not a stable interface to read the TSL base value.
* Check for aarch64 when not using .init_arraysSterling Augustine2020-01-021-2/+2
| | | | | | | | | | Reviewers: vvereschaka Subscribers: kristof.beyls, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D72005
* [sanitizer] Link Sanitizer-x86_64-Test-Nolibc with -staticFangrui Song2019-12-271-1/+1
| | | | | | | | | | | 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 1417558e4a61794347c6bfbafaff7cd96985b2c3 to be relanded.
* Support powerpc and sparc when building without init_array.Sterling Augustine2019-12-271-7/+25
| | | | | | | | | | | | Summary: Support powerpc and sparc when building without init_array. Reviewers: rdhindsa, gribozavr Subscribers: jyknight, nemanjai, fedor.sergeev, jsji, shchenz, steven.zhang, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71944
* Reland "[msan] Intercept qsort, qsort_r."Reid Kleckner2019-12-272-0/+92
| | | | | | | This reverts commit 8fcce5ac73d49981656d9126e6c88391c1f6bf01. I spoke too soon, the revert does not actually cause the startup crash to go away.
* Revert "[msan] Intercept qsort, qsort_r."Reid Kleckner2019-12-272-92/+0
| | | | | | | | | | | | | | | | | | | This reverts commit 7a9ebe95125ea87a494d0c18f44f10bd70e12188, and dependent commit 54c522420347e58aa7bae1892cf5c5672b57c875, which disables qsort interception for some iOS platforms. After this change, the -Nolibc sanitizer common test binary crashes on startup on my regular Linux workstation, as well as on our bots: https://ci.chromium.org/p/chromium/builders/try/linux_upload_clang/740 ******************** Failing Tests (1): SanitizerCommon-Unit :: ./Sanitizer-x86_64-Test/SanitizerCommon.NolibcMain Loading it up in gdb shows that it crashes during relocation processing, which suggests that some glibc loader versions do not support the THREADLOCAL data added in this interceptor.
* [compiler-rt] [netbsd] Add support for versioned statvfs interceptorsKamil Rytarowski2019-12-274-1/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add support for NetBSD 9.0 and newer versions of interceptors operating on struct statvfs: fstatvfs, fstatvfs1, getmntinfo, getvfsstat, statvfs, statvfs1. The default promoted interceptors are for NetBSD 9.99.26. Older ones (currently 9.0) are kept in a new NetBSD specific file: /sanitizer_common_interceptors_netbsd_compat.inc. This file defines compat interceptors and mangles `INIT_*` macros, concatenating the current interceptors and the compat ones. This redefinition is not elegant, but it avoids preprocessor madness. Define struct_statvfs90_sz for the compat purposes. Reviewers: mgorny, kcc, vitalybuka, joerg Reviewed By: mgorny Subscribers: dberris, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71700
* Temporarily Revert "[compiler-rt] [netbsd] Add support for versioned statvfs ↵Eric Christopher2019-12-264-176/+1
| | | | | | | | | | | interceptors" as it's failing the netbsd specific linter parts of the sanitizer linter: llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_netbsd_compat.inc:23: Lines should be <= 80 characters long [whitespace/line_length] llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_netbsd.cpp:2450: Do not use variable-length arrays. Use an appropriately named ('k' followed by CamelCase) compile-time constant for the size. This reverts commit 78f714f824fac8aa3fdd85908c41538bccefb959.
* [compiler-rt] [netbsd] Add support for versioned statvfs interceptorsKamil Rytarowski2019-12-274-1/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add support for NetBSD 9.0 and newer versions of interceptors operating on struct statvfs: fstatvfs, fstatvfs1, getmntinfo, getvfsstat, statvfs, statvfs1. The default promoted interceptors are for NetBSD 9.99.26. Older ones (currently 9.0) are kept in a new NetBSD specific file: /sanitizer_common_interceptors_netbsd_compat.inc. This file defines compat interceptors and mangles `INIT_*` macros, concatenating the current interceptors and the compat ones. This redefinition is not elegant, but it avoids preprocessor madness. Define struct_statvfs90_sz for the compat purposes. Reviewers: mgorny, kcc, vitalybuka, joerg Reviewed By: mgorny Subscribers: dberris, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71700
* Revert "[msan] Check qsort input."Evgenii Stepanov2019-12-261-18/+0
| | | | | | | | | | | | | This change breaks LLVM bootstrap with ASan and MSan. FAILED: lib/ToolDrivers/llvm-lib/Options.inc OptParser.td:137:1: error: Option is equivalent to def INPUT : Option<[], "<input>", KIND_INPUT>; ^ OptParser.td:137:1: error: Other defined here def INPUT : Option<[], "<input>", KIND_INPUT>; This reverts commit caa48a6b88aeed8ae80e6ddb1eae8c6a7cbe260b.
* [compiler-rt] Disable QSORT interception on watchOS and tvOS.Florian Hahn2019-12-261-1/+14
| | | | | | | | | | Building the sanitizers for watchOS currently fails with sanitizer_common_interceptors.inc:9656:8: error: thread-local storage is not supported for the current target static THREADLOCAL SIZE_T qsort_size; I've also speculatively disabled QSORT interception for tvOS to unblock failing builds. I'll ask someone with more sanitizer knowledge to check after the holidays.
* [compiler-rt] [netbsd] Correct the fallback definition of PT_LWPNEXTKamil Rytarowski2019-12-251-2/+2
| | | | Fixes build on NetBSD 9.0.
* [compiler-rt] [netbsd] Define _RTLD_SOURCE to fix buildKamil Rytarowski2019-12-251-0/+4
| | | | | The TLS base (LWP private pointer) functions are namespaced and hidden i.e. inside the _RTLD_SOURCE namespace.
* [compiler-rt] Adapt for ptrace(2) changes in NetBSD-9.99.30Kamil Rytarowski2019-12-243-1/+46
| | | | | Enable compat support for now legacy PT_LWPINFO. Support PT_LWPSTATUS and PT_LWPNEXT.
* [compiler-rt] Adapt stop-the-world for ptrace changes in NetBSD-9.99.30Kamil Rytarowski2019-12-241-2/+10
| | | | Handle PT_LWPNEXT for newer kernels and keep PT_LWPINFO for older ones.
* [msan] Check qsort input.Evgenii Stepanov2019-12-231-0/+18
| | | | | | | | | | | | | | | | | | Summary: Qsort interceptor suppresses all checks by unpoisoning the data in the wrapper of a comparator function, and then unpoisoning the output array as well. This change adds an explicit run of the comparator on all elements of the input array to catch any sanitizer bugs. Reviewers: vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71780
* [msan] Intercept qsort, qsort_r.Evgenii Stepanov2019-12-232-0/+79
| | | | | | | | | | | | | | | Summary: This fixes qsort-related false positives with glibc-2.27. I'm not entirely sure why they did not show up with the earlier versions; the code seems similar enough. Reviewers: vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71740
* Revert "[msan] Check qsort input." and "[msan] Intercept qsort, qsort_r."Jonas Devlieghere2019-12-202-91/+0
| | | | | | | | | | | | | | Temporarily revert the qsort changes because they fail to build on bots that build with modules: > error: thread-local storage is not supported for the current > target (iossim) http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/1820/console http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/4983/console This reverts commit ddf897fc80499ece298bc33201db6b697d2af50e. This reverts commit 07861e955d0095f25639d84c5726c73b528567cb.
* [scudo][standalone] Support __BIONIC__Kostya Kortchinsky2019-12-201-1/+5
| | | | | | | | | | | | | | Summary: Some Android builds that we are interested in define `__BIONIC__` but not `__ANDROID__`, so expand `SCUDO_ANDROID` to encompass those. Reviewers: cferris, hctim, pcc, eugenis, morehouse Subscribers: krytarowski, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71772
* [msan] Check qsort input.Evgenii Stepanov2019-12-201-0/+18
| | | | | | | | | | | | | | | | | | Summary: Qsort interceptor suppresses all checks by unpoisoning the data in the wrapper of a comparator function, and then unpoisoning the output array as well. This change adds an explicit run of the comparator on all elements of the input array to catch any sanitizer bugs. Reviewers: vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71780
* [msan] Intercept qsort, qsort_r.Evgenii Stepanov2019-12-202-0/+73
| | | | | | | | | | | | | | | Summary: This fixes qsort-related false positives with glibc-2.27. I'm not entirely sure why they did not show up with the earlier versions; the code seems similar enough. Reviewers: vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71740
* [scudo][standalone] Implement TSD registry disablingKostya Kortchinsky2019-12-205-8/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In order to implement `malloc_{enable|disable}` we were just disabling (or really locking) the Primary and the Secondary. That meant that allocations could still be serviced from the TSD as long as the cache wouldn't have to be filled from the Primary. This wasn't working out for Android tests, so this change implements registry disabling (eg: locking) so that `getTSDAndLock` doesn't return a TSD if the allocator is disabled. This also means that the Primary doesn't have to be disabled in this situation. For the Shared Registry, we loop through all the TSDs and lock them. For the Exclusive Registry, we add a `Disabled` boolean to the Registry that forces `getTSDAndLock` to use the Fallback TSD instead of the thread local one. Disabling the Registry is then done by locking the Fallback TSD and setting the boolean in question (I don't think this needed an atomic variable but I might be wrong). I clang-formatted the whole thing as usual hence the couple of extra whiteline changes in this CL. Reviewers: cferris, pcc, hctim, morehouse, eugenis Subscribers: jfb, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71719
* Revert "Support powerpc when builing without init_array."Dmitri Gribenko2019-12-191-17/+3
| | | | | This reverts commit 5789e83dedb97588ad75cca36d01ba6c5142d6d3. It broke the build on aarch64.
* [compiler-rt] Enable SANITIZER_CAN_USE_PREINIT_ARRAY on NetBSDKamil Rytarowski2019-12-191-1/+1
| | | | .preinit_array is supported since 9.0.
* [compiler-rt] [fuzzer] Include stdarg.h for va_listKamil Rytarowski2019-12-191-0/+1
| | | | Fixes build on NetBSD after 139e216e6610091b7ee3c30bc11114f5d73cbd3e.
* Support powerpc when builing without init_array.Sterling Augustine2019-12-181-3/+17
| | | | | | | | | | Summary: Also add an error case when targetting an unimplement architecture. Subscribers: nemanjai, jsji, shchenz, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71670
* Correct version check 9.9.26 -> 9.99.26Kamil Rytarowski2019-12-181-1/+1
|
* [NFC] Fix sanitizer lint problem that's breaking Android bot.Mitch Phillips2019-12-181-1/+1
| | | | | Fixes the lint issue introduced by e14ff22694c28b5e731502bfc30192b3208d4d8d
* [compiler-rt] Sync NetBSD ioctl definitions with 9.99.26Kamil Rytarowski2019-12-183-5/+18
| | | | Document the minimal version supported to 9.0.
* [sanitizer] Construct InternalMmapVector without memory allocation.Igor Kudrin2019-12-172-2/+2
| | | | | | | | | 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
* [TSan][Darwin] Avoid calling pthread_self() before libpthread is initializedJulian Lettner2019-12-161-1/+6
| | | | | | | | | | | | | | This skips calling `pthread_self` when `main_thread_identity` hasn't been initialized yet. `main_thread_identity` is only ever assigned in `__tsan::InitializePlatform`. This change should be relatively safe; we are not changing behavior other than skipping the call to `pthread_self` when `main_thread_identity == 0`. rdar://57822138 Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D71559
* [NFC] Guard scudo_standalone's optional dependency on GWP-ASan behind flags.Mitch Phillips2019-12-131-1/+3
|
* [GWP-ASan] [Scudo] ifdef entire GWP-ASan tests.Mitch Phillips2019-12-131-4/+2
| | | | | | | | | Turns out that gtest in LLVM is only 1.8.0 (the newest version 1.10.0) supports the GTEST_SKIP() macro, and apparently I didn't build w/o GWP-ASan. Should fix the GN bot, as well as any bots that may spuriously break on platforms where the code wasn't correctly ifdef'd out as well.
* [Scudo] [GWP-ASan] Add GWP-ASan to Scudo Standalone.Mitch Phillips2019-12-137-1/+122
| | | | | | | | | | | | | | | | Summary: Adds GWP-ASan to Scudo standalone. Default parameters are pulled across from the GWP-ASan build. No backtrace support as of yet. Reviewers: cryptoad, eugenis, pcc Reviewed By: cryptoad Subscribers: merge_guards_bot, mgorny, #sanitizers, llvm-commits, cferris, vlad.tsyrklevich, pcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71229
* [sanitizers] Redirect stdout and stderr to TASK_LOGEric Christopher2019-12-121-1/+1
| | | | | | | | | | | | At some point cpplint.py became very noisy during a build spewing a few hundred lines of "Done processing..." even with SILENT=1 in cmake. This attempts to redirect the stdout of "Done processing" to the task log along with any errors. Tested by this with and without SILENT=1 to check things. Differential Revision: https://reviews.llvm.org/D71402 Reviewed By: eugenis
* [compiler-rt] libFuzzer: update -merge_control_file= help message.Max Moroz2019-12-121-1/+2
| | | | | | | | | | | | | | | | Summary: The motivation for this change is to have a distinguisher in libFuzzer that would let the runner know whether multistep merge is supported or not by a particular fuzz target binary. Otherwise, multistep merge fails to execute with older version of libFuzzer, and there is no way to verify that easily. Reviewers: kcc Subscribers: dberris, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71423
* [fuzzer] Add basic support for emscripten.Jonathan Metzman2019-12-126-7/+29
| | | | | | | | | | | | | | | | | | | | | | | Summary: Add basic support for emscripten. This enables libFuzzer to build (using build.sh) for emscripten and fuzz a target compiled with -fsanitize-coverage=inline-8bit-counters. Basic fuzzing and bug finding work with this commit. RSS limit and timeouts will not work because they depend on system functions that are not implemented/widely supported in emscripten. Reviewers: kcc, vitalybuka, hctim Reviewed By: hctim Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71285
* Revert unintentional change to compiler-rt as part of the __bit_reference ↵Eric Christopher2019-12-121-1/+1
| | | | revert.
* [compiler-rt] Add a critical section when flushing gcov countersCalixte Denizet2019-12-121-1/+24
| | | | | | | | | | | | | | | | | Summary: Counters can be flushed in a multi-threaded context for example when the process is forked in different threads (https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp#L632-L663). In order to avoid pretty bad things, a critical section is needed around the flush. We had a lot of crashes in this code in Firefox CI when we switched to clang for linux ccov builds and those crashes disappeared with this patch. Reviewers: marco-c, froydnj, dmajor, davidxl, vsk Reviewed By: marco-c, dmajor Subscribers: ahatanak, froydnj, dmajor, dberris, jfb, #sanitizers, llvm-commits, sylvestre.ledru Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D70910
* Temporarily Revert "[libc++] Fix -Wdeprecated-copy warnings in __bit_reference"Eric Christopher2019-12-121-1/+1
| | | | | | as it's causing test failures due to mismatched visibility. This reverts commit 02bb20223bda5add729402962c70d0ebd0d98af2.
* [profile] Avoid allocating a page on the stack, NFCVedant Kumar2019-12-114-14/+33
| | | | | | | | | | | | | | | | | | | | | When writing out a profile, avoid allocating a page on the stack for the purpose of writing out zeroes, as some embedded environments do not have enough stack space to accomodate this. Instead, use a small, fixed-size zero buffer that can be written repeatedly. For a synthetic file with >100,000 functions, I did not measure a significant difference in profile write times. We are removing a page-length zero-fill `memset()` in favor of several smaller buffered `fwrite()` calls: in practice, I am not sure there is much of a difference. The performance impact is only expected to affect the continuous sync mode (%c) -- zero padding is less than 8 bytes in all other cases. rdar://57810014 Differential Revision: https://reviews.llvm.org/D71323
OpenPOWER on IntegriCloud