Commit Graph

19874 Commits

Author SHA1 Message Date
Christopher Ferris
420f62e05c [scudo] Only print stats when the test fails. (#168000)
When running the tests on other platforms, printing the stats on all of
the passing tests makes it hard to see failure output. Therefore, this
change only prints the stats if the test actually fails.
2025-11-24 15:03:08 -08:00
Martin Storsjö
1e1974a903 [compiler-rt] [test] Avoid error printouts if os.sysconf is missing (#168857)
This avoids dozens of instances of benign error messages being printed
when running the tests on e.g. Windows:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: module 'os' has no attribute 'sysconf'

Co-authored-by: Florian Mayer <fmayer@google.com>
2025-11-24 23:51:40 +02:00
Florian Mayer
ff80de72c4 Reapply "[UBSan] [compiler-rt] add preservecc variants of handlers" (#168973) (#169091)
This reverts commit 418204d9c1.
2025-11-24 12:44:32 -08:00
Daniel Thornburgh
acab67baa7 [M68k][compiler-rt] Allow compiler-rt builtins to be built for M68k (#169256)
I've tested this locally, and the builtins build proceeds without a
hitch for m68k-none-none. This is part of a larger effort to establish a
working m68k baremetal toolchain.
2025-11-23 19:15:45 -08:00
Aiden Grossman
126462035a [UBSan] Fix test-darwin-interface.c on X86 Darwin with Internal Shell (#169105)
This test was failing with the internal shell due to the use of
subshells. This was not caught in my initial round of testing due to me
only using a M4 Mac for running my tests.
2025-11-22 08:52:34 -08:00
Aiden Grossman
d7307f458c [ORC] Fix obj-imageinfo.S on X86 Darwin with Internal Shell (#169104)
d464c99f59 fixes this test on AArch64
Darwin, but I did not realize that there was another X86 version of the
test. This patch also updates the X86 version of the test in a similar
manner.
2025-11-21 15:20:16 -08:00
Ellis Hoag
28c048ec0f [profdata] Skip probes with missing counter and function pointers (#163254) 2025-11-21 09:24:14 -08:00
Christopher Ferris
b27749d8c7 [scudo] Small cleanup of memory tagging code part 2. (#168807)
Make the systemSupportsMemoryTagging() function return even on system
that don't support memory tagging. This avoids the need to always check
if memory tagging is supported before calling the function.

Modify iterateOverChunks() to call useMemoryTagging<>(Options) to
determine if mte is supported. This already uses the cached check of
systemSupportsMemoryTagging() rather than directly calling that
function.

Updated the code that calls systemSupportsMemoryTagging().
2025-11-21 09:08:31 -08:00
Andrew Haberlandt
bb2e4686c1 [TSan] [Darwin] Fix off by one in TSAN init due to MemoryRangeIsAvailable (#169008) 2025-11-21 07:47:11 -08:00
Vitaly Buka
af098e0096 Revert "[ubsan_minimal] Allow UBSan handler from Minimal runtime to accept arguments (#152192)" (#168812)
This partially reverts #152192, keeping updated tests and
some code reordering in clang/lib/CodeGen/CGExpr.cpp.

compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp is exact revert
(with followup #152419)

We don't have a good use case for that, so revert it before we are stuck
maintaining this API.

21.x does not have this patch.

This reverts commit a1209d8686.
2025-11-21 01:09:28 -08:00
Florian Mayer
418204d9c1 Revert "[UBSan] [compiler-rt] add preservecc variants of handlers" (#168973)
Reverts llvm/llvm-project#168643
2025-11-20 16:00:44 -08:00
Florian Mayer
49e46a57cc [UBSan] [compiler-rt] add preservecc variants of handlers (#168643) 2025-11-20 15:40:37 -08:00
Martin Storsjö
04acac2c90 [compiler-rt] [test] Generalize an UNSUPPORTED marking (#168858)
Don't specifically target windows-msvc - the same goes for any windows
target; mingw doesn't have dlfcn.h either.
2025-11-20 23:33:35 +02:00
Andrew Haberlandt
b3d1e921aa [ASAN] Disable broken __SANITIZER_DISABLE_CONTAINER_OVERFLOW__ tests on iOS/Android (#168821)
The tests added by #163468 appear to be broken due to lack of libcxx support (?).

Marking unsupported everywhere for now since it passes on some platforms and fails on others, and
I don't know the full list.

Android fail: https://lab.llvm.org/buildbot/#/builders/186/builds/14106
2025-11-20 18:51:53 +00:00
Aiden Grossman
c90fb56b41 Revert "[compiler-rt] Default to Lit's Internal Shell (#168232)"
This reverts commit b725bdba1f.

This is still causing Darwin failures. There are six tests that are
still failing:
AddressSanitizer-x86_64-darwin.TestCases/Posix.deep_call_stack.cpp
AddressSanitizer-x86_64-darwin.TestCases.scariness_score_test.cpp
AddressSanitizer-x86_64h-darwin.TestCases/Posix.deep_call_stack.cpp
ORC-x86_64-darwin.TestCases/Darwin/x86-64.objc-imageinfo.S
UBSan-Minimal-x86_64-darwin.TestCases.test-darwin-interface.c
UBSan-Minimal-x86_64h-darwin.TestCases.test-darwin-interface.c

There are a couple failure modes:
1. deep_call_stack.cpp and scariness_score_test.cpp are failing due to
   ulimit issues that we have observed previously.
2. objc-imageinfo.S is failing in the x86 variant because I only updated
   the AArch64 variant.
3. test-darwin-interface.c is using subshells, so obviously fails with
   the internal shell. Also looks like this one did not run on my system
   due to it requiring x86_64 Darwin.
2025-11-20 18:41:15 +00:00
Andrew Haberlandt
b5c0fcdade [sanitizer_common] posix_spawn test should forward DYLD_LIBRARY_PATH (#168795)
This test explicitly sets the environment for a spawned process. Without
DYLD_LIBRARY_PATH, the spawned process may use a ASAN runtime other than
the one that was used by the parent process That other runtime library
may not work at all, or may not be in the default search path. Either
case can cause the spawned process to die before it makes it to main,
thus failing the test. The compiler-rt lit config sets the library path
variable
[here](https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/lit.common.cfg.py#L84)
(i.e. to ensure that just-built runtimes are used for tests, in the case
of a standalone compiler-rt build), and that is currently used by the
parent process but not the spawned ones.

My change only forwards the variable for Darwin (DYLD_LIBRARY_PATH), but
we **_ought_** to also forward the variable for other platforms.
However, it's not clear that there's any good way to plumb this into the
test, since some platforms actually have multiple library path variables
which would need to be forwarded (see: SunOS
[here](https://github.com/llvm/llvm-project/blob/main/compiler-rt/test/lit.common.cfg.py#L102)).
I considered adding a substitution variable for the library path
variable, but that doesn't really work if there's multiple such
variables.
2025-11-20 10:40:13 -08:00
Aiden Grossman
b725bdba1f Reapply "[compiler-rt] Default to Lit's Internal Shell (#168232)" (#168760)
This reverts commit eb20b53925.

This relands the compiler-rt internal shell after XRay and Darwin tests
that were failing under the internal shell have been fixed.
2025-11-20 07:51:33 -08:00
Paddy McDonald
beac880da5 Better fix for the stack_container_dynamic_lib test (#168798)
Add the missing %libdl to the link command
2025-11-19 18:06:11 -08:00
Paddy McDonald
ff39d59000 Disable test under GCC (#168792)
New test stack_container_dynamic_lib.cpp has errors under gcc.

Require clang while better fix is investigated
2025-11-19 16:08:34 -08:00
Paddy McDonald
36f9d5a41f [ASan] Document define to disable container overflow checks at compile time. (#163468)
Document a define to allow library developers to support disabling 
AddressSanitizer's container overflow detection in template code at 
compile time.

The primary motivation is to reduce false positives in environments
where
libraries and frameworks that cannot be recompiled with sanitizers
enabled
are called from application code. This supports disabling checks when
the
runtime environment cannot be reliably controlled to use ASAN_OPTIONS.

Key changes:
- Use the define `__SANITIZER_DISABLE_CONTAINER_OVERFLOW__` to disable
  instrumentation at compile time
- Implemented redefining the container overflow APIs in
common_interface_defs.h
  to use define to provide null implementation when define is present
- Update documentation in AddressSanitizer.rst to suggest and illustrate
  use of the define
- Add details of the define in PrintContainerOverflowHint()
- Add test disable_container_overflow_checks to verify new hints on the
error and fill the testing gap that
ASAN_OPTIONS=detect_container_overflow=0
  works
- Add tests demonstrating the issue around closed source libraries and 
  instrumented apps that both modify containers

This requires no compiler changes and should be supportable cross
compiler toolchains.

An RFC has been opened to discuss: 

https://discourse.llvm.org/t/rfc-add-fsanitize-address-disable-container-overflow-flag-to-addresssanitizer/88349
2025-11-19 11:20:10 -08:00
Nico Weber
87a1fd17e9 [gn] "port" 5efce7392f (arm 32-bit asm compiler-rt) 2025-11-19 12:41:08 -05:00
Aiden Grossman
ed0c36ca28 [Fuzzer] make big-file-copy.test work with the internal shell (#168658)
This patch uses several shell features not supported by the internal
shell, such as $? to get the exit code of a command, and exit. This
patch adjusts the test to work with the internal shell by using bash to
run the actual command with a zero exit code to ensure the file is
deleted, and python to propagate the exit code up to lit.
2025-11-19 09:27:38 -08:00
Aiden Grossman
e9b11ae837 [ASan] Make duplicate_os_log_reports.cpp work with the internal shell
This test used a for loop to implement retries and also did some trickery with PIDs.
For this test, just invoke bash for actually running the test given we need the PID,
and move the for loop into a separate shell script file that we can then invoke from
within the test. Normally it would make sense to rewrite such a script in Python, but
given this test does not have portability concerns only running on Darwin, it is fine
to use a shell script here given there is no other convenient alternative.

Reviewers: ndrewh, DanBlackwell, fmayer

Reviewed By: ndrewh

Pull Request: https://github.com/llvm/llvm-project/pull/168656
2025-11-19 09:26:30 -08:00
Aiden Grossman
c41f642399 [ASan] Make dyld_insert_libraries_reexec work with internal shell
This test was doing some feature checks within the test itself. This patch
rewrites the feature checks to be done in a fashion more idiomatic to lit,
as the internal shell does not support the features needed for the previous
feature checks.

Reviewers: ndrewh, DanBlackwell, fmayer

Reviewed By: ndrewh

Pull Request: https://github.com/llvm/llvm-project/pull/168655
2025-11-19 09:09:03 -08:00
Andrew Haberlandt
c6775e2eb6 [compiler-rt] [libFuzzer] Fix merge-posix test (again) (#168639) 2025-11-19 08:32:21 -08:00
Aiden Grossman
7a3923676f [ASan] Fix interface_symbols_darwin.cpp on internal shell
This test turned out to not actually be that interested. There was just a
subshell usage that needed replacing with readfile, and then the test just
works.

Reviewers: fmayer, DanBlackwell, ndrewh

Reviewed By: ndrewh

Pull Request: https://github.com/llvm/llvm-project/pull/168654
2025-11-19 07:16:13 -08:00
Jake Egan
c62fc065b4 [asan] Implement address sanitizer on AIX: platform support (#139587)
Adds some general changes for supporting asan on AIX.

Issue: #138916
2025-11-19 09:44:22 -05:00
Michael Kruse
c32c1d0d21 [Runtimes] Default build must use its own output dirs (#168266)
Post-commit fix of #164794 reported at
https://github.com/llvm/llvm-project/pull/164794#issuecomment-3536253493

`LLVM_LIBRARY_OUTPUT_INTDIR` and `LLVM_RUNTIME_OUTPUT_INTDIR` is used by
`AddLLVM.cmake` as output directories. Unless we are in a
bootstrapping-build, It must not point to directories found by
`find_package(LLVM)` which may be read-only directories. MLIR for
instance sets thesese variables to its own build output
directory, so should the runtimes.
2025-11-19 13:51:14 +01:00
Aiden Grossman
7aeb2646bf [ASan] Make most tests run under internal shell on Darwin
This patch fixes most of the ASan tests that were failing on Darwin when
running under the internal shell. There are still a couple left that
are more interesting cases that I'll do in a follow up patch. The
tests that still need to be done:
```
TestCases/Darwin/duplicate_os_log_reports.cpp
TestCases/Darwin/dyld_insert_libraries_reexec.cpp
TestCases/Darwin/interface_symbols_darwin.cpp
```

Reviewers: thetruestblue, fhahn, vitalybuka, DanBlackwell, ndrewh

Reviewed By: DanBlackwell

Pull Request: https://github.com/llvm/llvm-project/pull/168545
2025-11-18 08:22:25 -08:00
Aiden Grossman
2ede6afff0 [TSan] Make tests work with internal shell
This patch makes all tsan tests work with the internal shell on Darwin. Tests
were using various features not supported by the internal shell, mainly subshells
and not using env to set environment variables. This patch also fixes one of the
dynamiclib substitutions to not use a subshell.

Reviewers: ndrewh, DanBlackwell, fmayer, vitalybuka

Reviewed By: DanBlackwell

Pull Request: https://github.com/llvm/llvm-project/pull/168544
2025-11-18 07:25:48 -08:00
Aiden Grossman
c771159ab5 [RTSan] Fix tests under Internal Shell (#168470)
This patch fixes the only RTSan test that was broken by enabling lit's
internal shell on Darwin. This patch rewrites the test to prefix env
variables with `env` and to avoid the use of subshells.
2025-11-18 05:58:22 -08:00
Simon Tatham
5efce7392f [compiler-rt][ARM] Optimized mulsf3 and divsf3 (#168394)
(Reland of #161546, fixing three build and test issues)

This commit adds optimized assembly versions of single-precision float
multiplication and division. Both functions are implemented in a style
that can be assembled as either of Arm and Thumb2; for multiplication, a
separate implementation is provided for Thumb1. Also, extensive new
tests are added for multiplication and division.

These implementations can be removed from the build by defining the
cmake variable COMPILER_RT_ARM_OPTIMIZED_FP=OFF.

Outlying parts of the functionality which are not on the fast path, such
as NaN handling and underflow, are handled in helper functions written
in C. These can be shared between the Arm/Thumb2 and Thumb1
implementations, and also reused by other optimized assembly functions
we hope to add in future.
2025-11-18 11:21:23 +00:00
Aiden Grossman
d464c99f59 [ORC] Make tests work with Internal Shell (#168471)
This patch makes objc-imageinfo.S work with the internal shell. The test
uses a subshell to temporarily change the directory. The internal shell
does not support subshells, so this construct was replaced with a
pushd/popd sequence.
2025-11-17 18:54:14 -08:00
Aiden Grossman
eb20b53925 Revert "Reapply "[compiler-rt] Default to Lit's Internal Shell" (#168232)"
This reverts commit bde9062418.

This caused failures on Darwin that were not caught by upstream
buildbots. Reverting for now to give myself some time to fix.
2025-11-18 00:21:06 +00:00
Christopher Ferris
7a14ef0293 [scudo] Skip test if mlock fails. (#168448)
Some linux versions might not support the mlock call, so skip that part
of the test if the mlock fails.
2025-11-17 15:25:33 -08:00
Christopher Ferris
7672a5cee1 [scudo] Fix wrong return type. (#168157) 2025-11-17 10:59:04 -08:00
Andrew Haberlandt
c4be17a887 [compiler-rt] [libFuzzer] Fix merge-posix.test file size test (#168137)
This test uses `ulimit -f 1` to test what libFuzzer does when trying to
create a file > **_1KB_**. However, the none of the input files used by
this test are actually >= 1KB, so there's no reason to expect this test
to pass.

This test appears to be passing on accident since the "control file"
happens to be > 1KB, but this is not always the case depending upon the
length of the path where the test is run from.

This modifies the test to ensure that one of the input file is actually
>1KB.
2025-11-17 10:28:26 -08:00
Aiden Grossman
72059bebb3 [compiler-rt][Profile] Mark Darwin test work with internal shell
This test was using subshells and then passing the results to diff. Write out
the results to files before passing to diff as the internal shell does not
support subshells.
2025-11-17 09:54:08 -08:00
Aiden Grossman
c7a9be81be [XRay] Rewrite tests to not use subshells
So that they will actually function with the internal shell.
2025-11-17 15:08:03 +00:00
Aiden Grossman
53e3f8e3c5 [XRay] Prefix setting XRAY_OPTIONS with env
So setting the environment variable works with the new internal shell.
This does not fix all the XRay tests because some of them are using
subshells and need to be rewritten to not use subshells.
2025-11-17 14:53:02 +00:00
Aiden Grossman
bde9062418 Reapply "[compiler-rt] Default to Lit's Internal Shell" (#168232)
This reverts commit 8cc49fb99a.

This was causing failures on two specific buildbots that have since been
fixed.
2025-11-16 00:49:29 -08:00
Aiden Grossman
8240552e88 [compiler-rt] Update test to export variables instead of using env
To work around a bug in lit's internal test runner around ulimit.
Commands that use env to set environment variables for that command do
not have limits applied to them. This needs to be fixed, but for now we
can work around without degrading the readability of the test too much.
2025-11-16 08:13:48 +00:00
Mikołaj Piróg
8f6c7aa2b1 [X86] Remove vector length (256 vs 512) distinction of AVX10 (#167736)
As in title. AVX10.x doesn't distinguish between available vector
lengths.

-mattr=avx10.x-512 and defining of macros with _512 is kept for compatibility. 

Bit-positions of avx10.1/2 features in compiler-rt and X86TargetParser
are synced to match those in the gcc.
2025-11-15 15:51:06 +01:00
Andrew Haberlandt
4d3ed10241 [compiler-rt] [Darwin] Strip MTE tags from ASAN and TSAN (#166453)
ASAN and TSAN need to strip tags in order to compute the correct shadow
addresses.

rdar://163518624
2025-11-14 09:48:09 -08:00
anoopkg6
630dfc928c [dfsan] Fix Endianess issue (#162881)
Fix Endianess issue with getting shadow 4 bytes corresponding to the
first origin pointer.

---------

Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-11-13 16:38:24 -08:00
Andrew Haberlandt
4fe79a761e [sanitizer-common] [Darwin] Fix overlapping dyld segment addresses (attempt 2) (#167800)
This re-lands #166005, which was reverted due to the issue described in
#167797.

There are 4 small changes:
- Fix LoadedModule leak by calling Clear() on the modules list
- Fix internal_strncpy calls that are not null-terminated
- Improve test to accept the dylib being loaded from a different path
than compiled `{{.*}}[[DYLIB]]`
- strcmp => internal_strncmp

This should not be merged until after #167797.


rdar://163149325
2025-11-13 16:11:14 -08:00
Andrew Haberlandt
6a89439423 [sanitizer_common] Add darwin-specific MemoryRangeIsAvailable (#167797)
The fixes a TOCTOU bug in the code that initializes shadow memory in
ASAN:


4b05581bae/compiler-rt/lib/asan/asan_shadow_setup.cpp (L66-L91)

1. During initialization, we call `FindDynamicShadowStart` to search the
memory mapping for enough space to dynamically allocate shadow memory.
2. We call `MemoryRangeIsAvailable(shadow_start, kHighShadowEnd);`,
which goes into `MemoryMappingLayout`.
3. We actually map the shadow with `ReserveShadowMemoryRange`.

In step 2, `MemoryMappingLayout` makes various allocations using the
internal allocator. This can cause the allocator to map more memory! In
some cases, this can actually allocate memory that overlaps with the
shadow region returned by` FindDynamicShadowStart` in step 1. This is
not actually fatal, but it memory corruption; MAP_FIXED is allowed to
overlap other regions, and the effect is any overlapping memory is
zeroed.

------

To address this, this PR implements `MemoryRangeIsAvailable` on Darwin
without any heap allocations:

- Move `IntervalsAreSeparate` into sanitizer_common.h
- Guard existing sanitizer_posix implementation of
`MemoryRangeIsAvailable` behind !SANITIZER_APPLE
- `IsAddressInMappedRegion` in sanitizer_mac becomes
`MemoryRangeIsAvailable`, which also checks for overlap with the DYLD
shared cache.

After this fix, it should be possible to re-land #166005, which
triggered this issue on the x86 iOS simulators.

rdar://164208439
2025-11-13 21:42:45 +00:00
Christopher Ferris
3e28992b30 [scudo] Always zero on linux even if the memory cannot be released. (#167788)
If a caller has locked memory, then the madvise call will fail. In that
case, zero the memory so that we don't return non-zeroed memory for
calloc calls since we thought the memory had been released.
2025-11-13 13:01:28 -08:00
Simon Tatham
1c196452dd Revert "[compiler-rt][ARM] Optimized mulsf3 and divsf3" (#167906)
Reverts llvm/llvm-project#161546

One of the buildbots reported a cmake error I don't understand, and
which I didn't get in my own test builds:
```
CMake Error at /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/compiler-rt/cmake/Modules/CheckAssemblerFlag.cmake:23 (try_compile):
  COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE
```

My best guess is that the thing I did in `CheckAssemblerFlag.cmake` only
works on some versions of cmake. But I don't understand the problem well
enough to fix it quickly, so I'm reverting the whole patch and will
reland it later.
2025-11-13 16:58:21 +00:00
Simon Tatham
f7e6521277 [compiler-rt][ARM] Optimized mulsf3 and divsf3 (#161546)
This commit adds optimized assembly versions of single-precision float
multiplication and division. Both functions are implemented in a style
that can be assembled as either of Arm and Thumb2; for multiplication, a
separate implementation is provided for Thumb1. Also, extensive new
tests are added for multiplication and division.

These implementations can be removed from the build by defining the
cmake variable COMPILER_RT_ARM_OPTIMIZED_FP=OFF.

Outlying parts of the functionality which are not on the fast path, such
as NaN handling and underflow, are handled in helper functions written
in C. These can be shared between the Arm/Thumb2 and Thumb1
implementations, and also reused by other optimized assembly functions
we hope to add in future.
2025-11-13 16:26:01 +00:00