Commit Graph

16111 Commits

Author SHA1 Message Date
Florian Mayer b96cbbd901 [sanitizer] Let internal symbolizer use toupper and tolower 2022-10-18 16:19:11 -07:00
Arthur Eubanks aa89ceab48 [win][compiler-rt] Make tests use lld-link instead of link
Git bash ships with a link.exe. We try to add git bash to the beginning
of PATH (see D84380). These tests end up executing the wrong link.exe.

As a workaround, use lld-link. Note that `REQUIRES: lld-available` tests currently aren't running, see D128567. I did manually verify that these tests pass with lld-link.

Reviewed By: rnk, hans

Differential Revision: https://reviews.llvm.org/D136108
2022-10-18 08:46:23 -07:00
Arthur Eubanks db98c06f11 [ubsan][test] Make some tests have shorter file names
We're hitting path size limits on Windows on these tests. As a
workaround, make the file names shorter.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D136113
2022-10-18 08:45:27 -07:00
YunQiang Su 9221aa6d64 [CMake] Fix MIPSr6 build for compiler-rt
The current version pass -mips64r2 or -mips32r2 options,
which make it failed to build on r6 platform.

In this patch: we detect whether we are MIPSr6 by
    _MIPS_ARCH_MIPS32R6/_MIPS_ARCH_MIPS64R6
The out and install path is set to the default triple instead of
hardcoded one, since the clang ask for it.

Differential Revision: https://reviews.llvm.org/D135735
2022-10-18 04:49:25 +00:00
Chia-hung Duan 5de73d27bd [scudo] Change region size from 1 MB to 2 MB in tests
In SizeClassAllocator64, the RegionBeg is determined by RegionBase +
random offset. The offset is n pages, where n is a random number less or
equal to 16. However, on certain platforms which have large page size,
it may end up immediately OOM without mapping any block pages. For
example,

PageSize = 64 KB, RegionSize = 1 MB

Suppose the random number n is 16, then the random offset will be
64 * 16 = 1024 KB which is equal to the RegionSize.

On most platforms we don't have such large page size and we have
different PRNG(pseudo random number generator) behaviors, thus we didn't
hit any failures before. Given that this now only affects the tests,
only increase the region size is enough.

Will revisit the logic of calculating the random offset.

Differential Revision: https://reviews.llvm.org/D136025
2022-10-17 20:22:33 +00:00
David Spickett d231efe1ee [compiler-rt] Relax pthread_getaffinity test to account for cgroups/docker
Fixes #58283

When running in a docker container you can have fewer cores assigned
to you than get_nrpoc would suggest.

Since the test just wants to know that interception worked, allow
any result > 0 and <= the global core count.

Reviewed By: MaskRay, vitalybuka

Differential Revision: https://reviews.llvm.org/D135677
2022-10-17 10:45:30 +00:00
Chia-hung Duan 3ead26e65b [scudo] Fix implicitly narrow casting (NFC)
u16 may be promoted to int by arithmetic type conversion. Do an explicit
cast to avoid certain compiler's warning. This fixes the problem
introduced by 0fb2aeef53

Differential Revision: https://reviews.llvm.org/D135985
2022-10-15 03:54:53 +00:00
Kamau Bridgeman c929bcb7d8 Revert "[scudo] Manage free blocks in BatchGroup."
This reverts commit cf9d7f55d3.
2022-10-14 15:11:57 -05:00
Kamau Bridgeman 1cf1b36112 Revert "[scudo] Support partial page releasing"
This reverts commit 9c26f51f5e.
2022-10-14 15:11:44 -05:00
Kamau Bridgeman 5fe6f3e0bc Revert "[scudo] Fix implicitly narrow casting (NFC)"
This reverts commit fd7c7ad4fe.
2022-10-14 15:11:34 -05:00
Chia-hung Duan fd7c7ad4fe [scudo] Fix implicitly narrow casting (NFC)
u16 may be promoted to int by arithmetic type conversion. Do an explicit
cast to avoid certain compiler's warning.

Differential Revision: https://reviews.llvm.org/D135945
2022-10-14 18:59:08 +00:00
Chia-hung Duan 9c26f51f5e [scudo] Support partial page releasing
Block grouping enables us doing partial page releasing so that we can
release the pages in a finer granularity. Which means we don't need to
visit all blocks to determine which pages are unused. Besides, this
means we can do incremental page releasing depends on the number fo free
blocks.

Reviewed By: cryptoad, cferris

Differential Revision: https://reviews.llvm.org/D134226
2022-10-13 23:35:07 +00:00
Chia-hung Duan cf9d7f55d3 [scudo] Manage free blocks in BatchGroup.
Scudo is supposed to allocate any blocks across the entired mapped
pages and each page is equally likely to be selected. Which means Scudo
is leaning to touch as many pages as possible. This brings better
security but it also sacrifices the chance of releasing dirty pages.

To alleviate the unmanagable footprint growing, this CL introduces the
BatchGroup concept. Each blocks will be classified into a BatchGroup
according to its address. While allocation, we are leaning to allocate
blocks in the same group first. Note that the blocks selected from a
group is still random over several pages. At the same time, we have
better prediction of dirty page growing speed. Besides, we are able to
do partial page releasing by examing part of BatchGroups.

Reviewed By: cryptoad, cferris

Differential Revision: https://reviews.llvm.org/D133897
2022-10-13 23:35:06 +00:00
Chia-hung Duan 56dafd024c [scudo] Add PageReleaseContext to convey page usage status.
PageReleaseContext contains all the information needed for determing if
a page can be released. Splitting out the context increases the flexibility
of heterogenous free lists in the future. Also rename PackedCounterArray to
PageMap.

Reviewed By: cryptoad, cferris

Differential Revision: https://reviews.llvm.org/D133895
2022-10-13 23:35:06 +00:00
Chia-hung Duan 0fb2aeef53 Use u16 to store Count/MaxCount
The Count/MaxCount used in TransferBatch and PerClass can be fit in u16 in
current configurations and it's also reasonable to have a u16 limit. The
spare 16 bits will be used for additional status like pages mapping
status in a TransferBatch.

Reviewed By: cryptoad, cferris, vitalybuka

Differential Revision: https://reviews.llvm.org/D133145
2022-10-13 23:35:06 +00:00
Wiktor Garbacz e851f7dbca Fix LSan build
This change fixes a build bug introduced in
39db491957

Differential Revision: https://reviews.llvm.org/D135860
2022-10-13 10:44:27 -07:00
Wiktor Garbacz 39db491957 [LeakSanitizer] Capture calling thread SP early to avoid false negatives.
As shown in https://github.com/llvm/llvm-project/issues/42932 dead
pointers might be overlapped by a new stack frame inside CheckForLeaks,
which does not use bytes with pointers. This leads to false negatives.

It's not a full solution for the problem as it does not solve
"overlapping" new/old frames for frames below the CheckForLeaks and in
other threads. It should improve leaks found in direct callers of
__lsan_do_leak_check.

Differential Revision: https://reviews.llvm.org/D130237
2022-10-12 16:46:32 -07:00
Michael Jones b9663ebbf8 [SCUDO] add cmake options for custom sysroot
These options will allow the SCUDO standalone to be built with custom
headers. Specifically, this patch will enable building with the
LLVM-libc headers.

Reviewed By: abrachet

Differential Revision: https://reviews.llvm.org/D135702
2022-10-12 15:03:04 -07:00
Louis Dionne 72e7fd7152 [compiler-rt] Bump deployment target in tests
On Darwin, libc++ is the default C++ stdlib now, and that requires
a deployment target of at least 10.7.
2022-10-12 17:28:48 -04:00
Vitaly Buka bfe5e81826 Revert "Fix locating of COMPILER_RT_LIBCXX_PATH"
clang-aarch64-sve-vla crashes in msan
clang-s390x-linux-lnt fails to compile libcxx

This reverts commit 14b2b67cd7.
2022-10-11 23:50:48 -07:00
Vitaly Buka 14b2b67cd7 Fix locating of COMPILER_RT_LIBCXX_PATH
COMPILER_RT_LIBCXX_PATH is required for msan unittests.
2022-10-11 21:40:02 -07:00
Kai Luo 50312ea133 [tsan][go] Fix string equal operator
Fixed error
```
compiler-rt/lib/tsan/go/buildgo.sh: 62: [: unexpected operator
```

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D135537
2022-10-10 09:39:23 +08:00
Petr Hosek 826693e2b0 [CMake] Use libcxx-abi-* targets for in-tree sanitizer C++ ABI
When in-tree libcxx is selected as the sanitizer C++ ABI, use
libcxx-abi-* targets rather than libcxxabi and libunwind directly.

Differential Revision: https://reviews.llvm.org/D134855
2022-10-09 03:35:59 +00:00
Enna1 9e80add2cf [memprof] dump memprof profile when receive deadly signals
Currently memprof profile is dumped when program exits (call `FinishAndWrite()` in ~Allocator) or `__memprof_profile_dump` is manually called.
For programs that never exit (e.g. server-side application), it will be useful to dump memprof profile when specific signal is received.
This patch installs a signal handler for deadly signals(SIGSEGV, SIGBUS, SIGABRT, SIGILL, SIGTRAP, SIGFPE) like we do in other sanitizers. In the signal handler `__memprof_profile_dump` is called to dump memprof profile.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D134795
2022-10-08 10:08:23 +08:00
Ellis Hoag ea607d033a [llvm-profdata] Rename show flag to --show-format
In https://reviews.llvm.org/D135127 we created the show flag
`--output-format` which was confusing because it behaved differently
than the same flag in the merge command. So, rename the flag to
`--show-format`. This also allows us to add the `text` option to mean
"normal text output" rather than "text-encoded profiles" like it does
for the merge command.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D135467
2022-10-07 11:35:07 -07:00
Ellis Hoag 70fb7bb561 [InstrProf][llvm-profdata] Dump profile correlation data as YAML
Change the behavior of the `llvm-profdata show --debug-info=` command to dump a YAML file when using debug info correlation since it provides more information in a parseable format.

Reviewed By: yozhu, phosek

Differential Revision: https://reviews.llvm.org/D134770
2022-10-07 09:47:25 -07:00
Julian Lettner 97aee595bf [Sanitizer] Fix compile errors in rtl-old/tsan_rtl.cpp
Differential Revision: https://reviews.llvm.org/D134389
2022-10-06 12:28:36 -07:00
Mariusz Borsa 7850df3de0 [Sanitizers][Darwin] Fix invalid gap found by FindAvailableMemoryRange
An application running with ASAN can fail during shadow memory allocation, with an error
indicating a failure to map shadow memory region due to negative size parameter passed to mmap.

It turns out that the mach_vm_region_recurse() call can return an address of a module
which is beyond the range of the VM address space available to the iOS process,
i.e. greater than the value returned by GetMaxVirtualAddress(). It leads the FindAvailableMemoryRange function
to the an incorrect conclusion that it has found a suitable gap where the shadow memory can fit in,
 while the shadow memory cannot be really allocated in this case.

The fix just takes the maximum VM address into account, causing the function to return 0,
meaning that the VM gap to fit the requested size could not be found.

rdar://66530705

Differential Revision: https://reviews.llvm.org/D134836
2022-10-06 12:06:30 -07:00
Gulfem Savrun Yeniceri da594649fe [InstrProf] Add version into llvm-profdata
This patch adds support of printing profile version
into llvm-profdata which was proposed in:
https://discourse.llvm.org/t/llvm-profdata-failure-guarantees-for-code-coverage/64924

Differential Revision: https://reviews.llvm.org/D135317
2022-10-06 17:02:16 +00:00
Alex Brachet a672b7a7d7 [InstrProf] Make __llvm_profile_counter_bias_default hidden
This symbol shouldn't have default visibility.

Differential Revision: https://reviews.llvm.org/D135346
2022-10-06 06:16:22 +00:00
Vitaly Buka 68f4ceaf9b Revert "[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests"
Breaks some bots, details in https://reviews.llvm.org/D91620

This reverts commit 93b1256e38.
2022-10-05 09:59:25 -07:00
Rainer Orth 93b1256e38 [compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests
When trying to debug some `compiler-rt` unittests, I initially had a hard
time because

- even in a `Debug` build one needs to set `COMPILER_RT_DEBUG` to get
  debugging info for some of the code and
- even so the unittests used a hardcoded `-O2` which often makes debugging
  impossible.

This patch addresses this by instead using `-O0` if `COMPILER_RT_DEBUG`.
Two tests in `sanitizer_type_traits_test.cpp` need to be disabled since
they have undefined references to `__sanitizer::integral_constant<bool,
true>::value`.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D91620
2022-10-05 09:53:26 +02:00
Hans Wennborg 20a269cf77 Revert "[CMake] Use libcxx-abi-* targets for in-tree sanitizer C++ ABI"
It casued some runtimes builds to fail with cmake error

  No target "libcxx-abi-static"

see code review.

> When in-tree libcxx is selected as the sanitizer C++ ABI, use
> libcxx-abi-* targets rather than libcxxabi and libunwind directly.
>
> Differential Revision: https://reviews.llvm.org/D134855

This reverts commit 414f9b7d2f.
2022-10-03 14:56:07 +02:00
Fangrui Song 6f46ff3765 [test] Make Linux/sem_init_glibc.cpp robust
and fix it for 32-bit ports defining sem_init@GLIBC_2.0 (i386, mips32, powerpc32) for glibc>=2.36.

Fix https://github.com/llvm/llvm-project/issues/58079

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D135023
2022-10-02 00:47:10 -07:00
Petr Hosek 414f9b7d2f [CMake] Use libcxx-abi-* targets for in-tree sanitizer C++ ABI
When in-tree libcxx is selected as the sanitizer C++ ABI, use
libcxx-abi-* targets rather than libcxxabi and libunwind directly.

Differential Revision: https://reviews.llvm.org/D134855
2022-09-30 20:32:10 +00:00
Vitaly Buka 8c5f66a3af [NFC][sanitizer] Simplify symbolizer build script
This checks are irrelevant with monorepo.
2022-09-30 12:25:59 -07:00
Vitaly Buka 5a86b53a91 [sanitizer] Fix build of 32bit symbolizer 2022-09-30 12:21:17 -07:00
Dmitry Vyukov 3056ccdbae tsan: fix deadlock/crash in signal handling
We set in_blocking_func around some blocking C functions so that we don't
delay signal infinitely (if in_blocking_func is set we deliver signals
synchronously).

However, pthread_join is blocking but also call munmap/free to free thread
resources. If we are inside the munmap/free interceptors called from
pthread_join and deliver a signal synchronously, it can lead to deadlocks
and crashes since we re-enter runtime and try to lock the same mutexes
or use the same per-thread data structures.

If we re-enter runtime via an interceptor when in_blocking_func is set,
temporary reset in_blocking_func around the interceptor and restore it back
when we return from the recursive interceptor.

Also move in_blocking_func from ThreadSignalContext to ThreadContext
so that we can CHECK that it's not set in SlotLocker ctor.

Fixes https://github.com/google/sanitizers/issues/1540

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D127845
2022-09-30 14:23:46 +02:00
Vitaly Buka 4d7c0f8ccf [sanitizer] Fix symbolizer build script 2022-09-29 23:32:54 -07:00
Petr Hosek 559ca30936 Revert "[CMake] Use libcxx targets for in-tree sanitizer C++ ABI"
This reverts commit 7dbdffefb7 since
it appears to have broken several ASan tests.
2022-09-30 05:52:49 +00:00
Petr Hosek bd0a35edfd [CMake] Use correct include flag for MSVC
When building using the MSVC driver, we need to use /imsvc rather than
-isystem for system headers.

Differential Revision: https://reviews.llvm.org/D134864
2022-09-30 01:29:04 +00:00
Petr Hosek 7dbdffefb7 [CMake] Use libcxx targets for in-tree sanitizer C++ ABI
When in-tree libcxx is selected as the sanitizer C++ ABI, use libcxx
targets rather than libcxxabi and libunwind, since those may not be
available on all platforms (Windows for example).

Differential Revision: https://reviews.llvm.org/D134855
2022-09-30 01:29:03 +00:00
Alex Brachet 2449f42427 [scudo][Fuchsia] Increase MaxNumCachedHint
This brings the value closer to other platforms and allows
for future improvements, see D133897.
2022-09-29 20:57:10 +00:00
Vitaly Buka 346de23ec9 Revert "[sanitizer] Use LLVM_ENABLE_LIBCXX to build symbolizer"
Trigger some "libatomic" error.

This reverts commit ccbb401472.
2022-09-28 23:55:21 -07:00
Petr Hosek 482fa79abb [NFC][CMake] Inline the append_libcxx_libs macro
This is only invoked from a single site and doesn't add any value.
2022-09-29 06:51:43 +00:00
Vitaly Buka ccbb401472 [sanitizer] Use LLVM_ENABLE_LIBCXX to build symbolizer 2022-09-28 19:27:25 -07:00
Vitaly Buka 5f2e2b7d80 [test][msan] -fno-sanitize-memory-param-retval in unittests 2022-09-28 18:53:09 -07:00
Arthur Eubanks f92481e79d [test][msan] Pin varg.cpp to -fno-sanitize-memory-param-retval
Should fix https://lab.llvm.org/buildbot#builders/19/builds/12736
2022-09-28 13:14:14 -07:00
Vitaly Buka aba150ca23 [test][msan] Fix more tests for D134669 2022-09-26 18:06:41 -07:00
Vitaly Buka 15805c030f [tests][msan] Use -fno-sanitize-memory-param-retval in tests
Supports either default of -f[no-]sanitize-memory-param-retval.

Reviewed By: aeubanks, MaskRay

Differential Revision: https://reviews.llvm.org/D134683
2022-09-26 17:24:22 -07:00