Commit Graph

19931 Commits

Author SHA1 Message Date
Alexey Samsonov
8f93365b19 [tsan] Export __cxa_guard_ interceptors from TSan runtime. (#171921)
These functions from C++ ABI are defined in
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp and are supposed to
replace implementations from libstdc++/libc++abi.

We need to export them similar to why we need to export other
interceptors and TSan runtime functions - e.g. if a dlopen-ed shared
library depends on `__cxa_guard_acquire`, it needs to pick up the
exported definition from the TSan runtime that was linked into the main
executable calling the dlopen()

However, because the `__cxa_guard_` functions don't use traditional
interceptor machinery, they are omitted from the auto-generated
`libclang_rt.tsan.a.syms` files. Fix this by adding them to
tsan.syms.extra file explicitly.

Co-authored-by: Vitaly Buka <vitalybuka@google.com>
2025-12-14 08:53:22 -08:00
Alex Bradbury
8a53c01b67 [XRay][test] Mark fdr-mode.cpp test as unsupported for RISC-V
Commit c6f501d479 fixed an issue where some tests were incorrectly
marked as unsupported for a bootstrapping build. This exposed in our
'slow' full-bootstrap qemu-system CI that the fdr-mode.cpp fails on
RISC-V. We mark it as unsupported. I believe _xray_ArgLoggerEntry needs
to be implemented in xray_trampoline_risc*.S for this to work.
2025-12-14 14:26:48 +00:00
Michael Pratt
cdfdb06c91 [TSan] Zero-initialize Trace.local_head
Trace.local_head is currently uninitialized when Trace is created. It is
first initialized when the first event is added to the trace, via the
first call to TraceSwitchPartImpl.

However, ThreadContext::OnFinished uses local_head, assuming that it is
initialized. If it has not been initialized, we have undefined behavior,
likely crashing if the contents are garbage. The allocator (Alloc)
reuses previously allocations, so the contents of the uninitialized
memory are arbitrary.

In a C/C++ TSAN binary it is likely very difficult for a thread to start
and exit without a single event inbetween. For Go programs, code running
in the Go runtime itself is not TSan-instrumented, so goroutines that
exclusively run runtime code (such as GC workers) can quite reasonably
have no TSan events.

The addition of such a goroutine to the Go test.c is sufficient to
trigger this case, though for reliable failure (segfault) I've found it
necessary to poison the ThreadContext allocation like so:

```
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp index feee566f44..352db9aa7c 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -392,7 +392,9 @@
       report_mtx(MutexTypeReport),
       nreported(),
       thread_registry([](Tid tid) -> ThreadContextBase* {
-        return new (Alloc(sizeof(ThreadContext))) ThreadContext(tid);
+        void* ptr = Alloc(sizeof(ThreadContext));
+        internal_memset(ptr, 0xde, sizeof(ThreadContext));
+        return new (ptr) ThreadContext(tid);
       }),
       racy_mtx(MutexTypeRacy),
       racy_stacks(),
```

The fix is trivial: local_head should be zero-initialized.
2025-12-12 05:31:44 +00:00
Andrew Haberlandt
e281800924 Revert: check-builtins target for LLVM_ENABLE_RUNTIMES (#171940)
Revert #171741 and #166837.

@petrhosek reported issues with some builders using this feature
2025-12-11 16:22:27 -08:00
Florian Mayer
ee22217d1f [Sanitizer] show configure.log for libz build (#171932)
This is for debugging the failures on the aarch64 buildbot
2025-12-11 16:20:15 -08:00
Sadaf Ebrahimi
f36792b2a3 [scudo] Fix typo in multiple files (#171925) 2025-12-11 15:31:34 -08:00
Christopher Ferris
efd472c88d [scudo] Show the resident pages from the secondary cache. (#170568)
Move the test utility to get the resident pages into linux.cpp.

Add some specific tests for this function.

Add displaying of resident pages from in the secondary cache when
calling getStats.
2025-12-11 15:29:08 -08:00
Dan Blackwell
de29f24bde [sanitizer_common][test-only] Mark popen xfail on iossim (#171814)
rdar://166246774
2025-12-11 12:18:01 +00:00
Dan Blackwell
f548902922 [sanitizer_common][test-only] Remove xfail for darwin ubsan on dedup_token_length_test (#171812)
This test is currently XPASSing on the iossim CI.

rdar://166219043
2025-12-11 12:12:20 +00:00
anoopkg6
d0767e96f9 [JITLink] Add TLS support for SystemZ (#171559)
This patch adds TLS support for SystemZ on top of orc-runtime support. A
separate orc-runtime support #171062 has been created from earlier TLS
support #[170706](https://github.com/llvm/llvm-project/pull/170706).

See conversations in
[#170706](https://github.com/llvm/llvm-project/pull/170706)

---------

Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-12-11 12:11:50 +01:00
Wael Yehia
76ae530407 [PPC] XFAIL ppc/fixtfti_test.c and ppc/fixunstfti_test.c and track them under issue 171751 2025-12-11 02:06:10 +00:00
Dan Blackwell
16ee5c7787 Revert "[sanitizer_common][test-only] Specify full path for sort executable in popen.cpp" (#171706)
Reverts llvm/llvm-project#171622

Co-authored-by: Andrew Haberlandt <ndrewh@users.noreply.github.com>
2025-12-10 21:30:25 +00:00
Eli Friedman
bc0d0bbc6b [compiler-rt] Add baremetal version of profile library. (#167998)
Adds a flag COMPILER_RT_PROFILE_BAREMETAL, which disables the parts of
the profile runtime which require a filesystem or malloc. This minimal
library only requires string.h from the C library.

This is useful for profiling or code coverage of baremetal images, which
don't have filesystem APIs, and might not have malloc configured (or
have limited heap space).

Expected usage:

- Add code to your project to call
`__llvm_profile_get_size_for_buffer()` and
`__llvm_profile_write_buffer()` to write the profile data to a buffer in
memory, and then copy that data off the device using target-specific
tools.
- If you're using a linker script, set up your linker script to map the
profiling and coverage input sections to corresponding output sections
with the same name, and mark them KEEP. `__llvm_covfun` and
`__llvm_covmap` are non-allocatable, `__llvm_prf_names` is read-only
allocatable, and `__llvm_prf_cnts` and `__llvm_prf_data` are read-write
allocatable.
- The resulting data is in same format as the non-baremetal profiles.

There's some room for improvement here in the future for doing profiling
and code coverage for baremetal. If we revised the profiling format, and
introduced some additional host tooling, we could move some of the
metadata into non-allocated sections, and construct the profraw file on
the host. But this patch is sufficient for some use-cases.
2025-12-10 12:58:25 -08:00
Dan Blackwell
c5995e25ba [sanitizer_common][test-only] Specify full path for sort executable in popen.cpp (#171622)
This test has begun failing on iossim with 'sh: sort: command not found'
in the stderr. I believe this may be due to the change to the lit
internal shell not having 'sort' in it's path.

This patch adds the full path /usr/bin/sort to work around this.
2025-12-10 17:59:59 +00:00
Dan Blackwell
365ae7afe2 [compiler-rt][sanitizer_common] Make sanitizer_common tests work for other Apple Platforms (#150994)
This commit addresses a longstanding TODO comment, by doing the
following:
* Modifies the CMakeLists to add the new test configs
* Modifies the relevant lit file to add the required envs
* Fixes the FileCheck match in
`Darwin/symbolizer-function-offset-atos.cpp`
* XFAILs any appropriate tests

rdar://107758331
2025-12-10 09:54:12 +00:00
Brad Smith
62dbe573cf [compiler-rt][sanitizer] fix i386 build for Haiku (#171075)
r13 does not provide the trap err.

Co-authored-by: Jerome Duval <jerome.duval@gmail.com>
2025-12-10 03:09:54 -05:00
Sadaf Ebrahimi
570bceaa19 [scudo] Add last release time info to getStats (#170902)
Knowing when the last page release happened can help us figure out if
the page release is skipped or not.
2025-12-09 21:08:44 -08:00
Arthur Eubanks
e7015c9afb [compiler-rt] Fix usage of stdin/stdout (#171560)
From #170809.

Causes compile errors when `stdin`/`stdout` are #defined in stdio.h.
2025-12-10 04:11:34 +00:00
Christopher Ferris
64ee4bf734 [scudo] Refactor initialization of TSDs. (#169738)
Instead of getting a lock and then checking/modifying the Initialization
variable, make it an atomic. Doing this, we can remove one of the
mutexes in shared TSDs and avoid any potential lock contention in both
shared TSDs and exclusive TSDs if multiple threads do allocation
operations at the same time.

Add two new tests that make sure no crashes occur if multiple threads
try and do allocations at the same time.
2025-12-09 13:30:46 -08:00
Andrew Haberlandt
926cbddc18 [sanitizer_common] child_stdin_fd_ should only be set on posix_spawn path (#171508)
#170809 added the child_stdin_fd_ field on SymbolizerProcess to allow
the parent process to hold on to the read in of the child's stdin pipe.
This was to avoid SIGPIPE.

However, the `StartSubprocess` path still closes the stdin fd in the
parent here:

7f5ed91684/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp (L525-L535)

This could cause a double-close of this fd (problematic in the case of
fd reuse).

This moves the `child_stdin_fd_` field to only be initialized on the
posix_spawn path. This should ensure #170809 only truly affects Darwin.
2025-12-09 21:22:54 +00:00
Andrew Haberlandt
dc92bd03c9 [sanitizer_common] [Darwin] Replace pty with pipe on posix_spawn path for spawning symbolizer (#170809)
Due to a legacy incompatibility with `atos`, we were allocating a pty
whenever we spawned the symbolizer. This is no longer necessary and we
can use a regular ol' pipe.

This PR is split into two commits:
- The first removes the pty allocation and replaces it with a pipe. This
relocates the `CreateTwoHighNumberedPipes` call to be common to the
`posix_spawn` and `StartSubprocess` path.
- The second commit adds the `child_stdin_fd_` field to
`SymbolizerProcess`, storing the read end of the stdin pipe. By holding
on to this fd for the lifetime of the symbolizer, we are able to avoid
getting SIGPIPE (which would occur when we write to a pipe whose
read-end had been closed due to the death of the symbolizer). This will
be very close to solving #120915, but this PR is intentionally not
touching the non-posix_spawn path.

rdar://165894284
2025-12-09 12:05:43 -08:00
Aiden Grossman
a033183606 [compiler-rt] Try bumping soft_rss_limit again (#171469)
This is still failing on some of the bots. Try bumping the limit again
to see if this fixes things.
2025-12-09 16:37:48 +00:00
anoopkg6
e60a3325a3 [JITLink] Add orc-runtime support for SystemZ (#171062)
Add orc-runtime support and tests for SystemZ.

Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-12-09 12:07:40 +01:00
Mészáros Gergely
6061b90945 [compiler-rt] [test] refine target_page_size() in lit.common.cfg.py (NFC) (#170475)
Use mmap.PAGESIZE and fallback to os.sysconf if it is not available.
This allows to query the page size on Windows too, which has mmap but
not sysconf.

This is a pedantic change because Windows has a fixed page size of 4KiB.
I found this solution independently of #168857, and thought it might be
worth committing, since this is technically more correct.

[mmap.PAGESIZE implementation in
CPython](88cd5d9850/Modules/mmapmodule.c (L47))
2025-12-09 09:43:38 +01:00
Eli Friedman
c3acafcda2 [hwasan] Add config for AArch64 Linux with 39-bit VA. (#170927)
This is leveraging work which has already been done for Android, which
ships 39-bit VA kernels, and extending it to other embedded Linux
targets.

(SANITIZER_AARCH64_39BIT_VA was added in 58c8f57681.)
2025-12-08 13:58:07 -08:00
Eli Friedman
b71eb53cd4 [asan] Add config for AArch64 Linux with 39-bit VA. (#170929)
This is leveraging work which has already been done for Android, which
ships 39-bit VA kernels, and extending it to other embedded Linux
targets.

(SANITIZER_AARCH64_39BIT_VA was added in 58c8f57681.)
2025-12-08 13:57:33 -08:00
Aiden Grossman
d17f3b53e9 [XRay] Disable two more tests on armhf
Similar to d6f92050c0. Needed now that
these tests are actually running more broadly.
2025-12-08 20:32:31 +00:00
Andrew Haberlandt
c5d17bdf0c [compiler-rt] Add check-builtins target for LLVM_ENABLE_RUNTIMES builds (#166837)
When doing a LLVM_ENABLE_RUNTIMES-based build of clang+compiler_rt, the
`check-builtins` target is missing and builtins tests are not run
(#112105, #144090).

This provides one possible path forward for enabling these tests.

The approach taken here is to test the builtins with the `compiler-rt`
runtime build (i.e. only if you pass
`LLVM_ENABLE_RUNTIMES='compiler-rt'`). The builtins tests currently rely
on shared test infrastructure in `compiler-rt/`, so this is probably the
easiest solution without relocating the builtins and their tests outside
of `compiler-rt/`.

The main challenge is that the built-ins test configuration expects to
be able to inspect the builtin target and see the sources used to build
it:
```
    get_target_property(BUILTIN_LIB_SOURCES "${BUILTIN_LIB_TARGET_NAME}" SOURCES)
```

Since the builtins build and runtimes build are separate under
LLVM_ENABLE_RUNTIMES, this target inspection is not possible. To get
around this, we write a temporary file alongside each builtins library
containing the list of sources (e.g.
`"${CMAKE_BINARY_DIR}/clang_rt.builtins-${arch}.sources.txt"`). Then, we
introduce an undocumented compiler-rt option
`COMPILER_RT_FORCE_TEST_BUILTINS_DIR` (which is only intended to be used
by the LLVM_ENABLE_RUNTIMES build, and could be removed after builtins
re relocated) that passes the path to the directory containing this
file, and configures builtins tests (even though the runtimes build has
`COMPILER_RT_BUILD_BUILTINS=OFF`)

rdar://163518748
2025-12-08 11:10:20 -08:00
Aiden Grossman
f29f01db8f [Sanitizer] Bump soft_rss_limit_mb in test (#170911)
This test is failing on some buildbots now that the internal shell has
been turned on and was failing previously on some ppc bots when turning
it on a while back (before it got reverted).

At least one X86 bot is barely hitting the limit
(https://lab.llvm.org/buildbot/#/builders/174/builds/28487 224MB-235MB).

This likely needs to be bumped due to changes in the process tree (now
that we invoke things through python rather than a bash shell) with the
enablement of the internal shell.
2025-12-08 06:04:41 -08:00
Dan Blackwell
bd1bd178f8 [fuzzer][test-only] Bump runs for reduce_inputs.test unseeded run (#169641)
I have seen a failure whereby the fuzzer failed to reach the expected
input and thus failed the test.

This patch bumps the max executions to 10,000,000 in order to give the
fuzzer a better chance of reaching the expected input. Most runs
complete successfully, so I do not see this adding test time in the
general case; I believe it's a fair tradeoff for the unlucky seed to run
for longer if it reduces the noise from false positives. Note, this
updates a different `RUN:` to
https://github.com/llvm/llvm-project/pull/165402.

rdar://162122184
2025-12-08 09:05:49 +00:00
Brad Smith
b0e98426f3 Revert "[FMV][AArch64] Add initial AT_HWCAP3 / AT_HWCAP4 support (#161595)" (#171071)
Crashing with older glibc.

This reverts commit edb4319251,
57b5ba00cb and
9715ccae1f.
2025-12-07 22:32:37 -05:00
Aiden Grossman
75aa7bdf45 [ASan] Disable another test on Darwin due to ulimit stack issues
Similar to #170786.
2025-12-06 05:27:24 +00:00
Louis Dionne
a55221da60 [clang] Revert changes to prefer the toolchain-provided libc++.dylib
This patch reverts the change that made clang prefer the toolchain
libc++.dylib when there is one (#170303), and the subsequent test
workaround we landed to fix bots (#170912).

We are seeing some failure on macOS LLDB bots that need to be
investigated, and that will require more time than I can spare
before the end of today.

This reverts commits bad1a88963 and 190b8d0b.
2025-12-05 16:45:41 -05:00
Aiden Grossman
7982688b69 [Profile] Fix debuginfod test with internal shell
The recent relanding of the internal shell broke one of the debuginfod
tests as it is not tested by any upstream buildbot due to the use of
curl. Rewriting the test to not use subshells is pretty simple.
2025-12-05 21:38:29 +00:00
Eli Friedman
58c8f57681 [compiler-rt] Add CMake flag for AArch64 Linux with 39-bit VA. (#167028)
Sanitizers currently assume AArch64 Linux has 48-bit VA. Followup
patches will add checks for this flag to asan and hwasan.
2025-12-05 13:36:05 -08:00
Aiden Grossman
94984d5cdb Reapply "[compiler-rt] Default to Lit's Internal Shell (#168232)"
This reverts commit c90fb56b41.

The failures identified in the revert commit have noe been fixed:
1. 4bc783be2d
2. 126462035a
3. d7307f458c
2025-12-05 18:49:04 +00:00
Aiden Grossman
35203a6a86 [ASan] Do not return from void functions in asan_abi_shim.cpp (#170897)
This was causing compilation failures on MacOS.
2025-12-05 10:48:37 -08:00
Louis Dionne
190b8d0b4f [clang][Darwin] Prefer the toolchain-provided libc++.dylib if there is one (#170303)
When libc++ is bootstrapped with clang, the resulting clang uses the just-built libc++
headers from <install>/bin/../include/c++/v1. However, before this patch, clang would
still use the system-provided libc++.dylib (usually in the Apple SDK) because it would
fail to add the corresponding linker flag to find the just-built libc++. After this
patch, Clang will instead link against the toolchain provided `libc++.dylib` in
`<install>/lib` if it exists, which will result in programs being linked against
corresponding libc++ headers and dylib.

Fixes #77653
rdar://107060541
2025-12-05 13:06:18 -05:00
happyCoder92
fb6513130d Add API to temporalily suppress usage of ASAN's fake stack (#160135)
Intended use-case is for threads that use (or switch to) stack with
special properties e.g. backed by MADV_DONTDUMP memory.

---------

Co-authored-by: Vitaly Buka <vitalybuka@google.com>
2025-12-05 09:53:21 -08:00
Aiden Grossman
4bc783be2d [ASan] Disable test that sets call stack on Darwin (#170786)
This test fails with the internal shell as we implement ulimit with a
python wrapper. This python wrapper fails on recent versions of MacOS to
set the stack size limit lower, or even to the current values. More
discussion is in https://github.com/python/cpython/issues/78783 towards
the bottom (it seems like a new issue should be opened).

It does not seem like we lose significant test coverage by disabling
this on MacOS as the test running on Linux should catch any major
regressions. We can also simply reenable once the issue is fixed
(although writing a simple c program with calls setrlimit directly also
fails in the smae manner).
2025-12-05 09:36:52 -08:00
Jake Egan
2833d9f15a [NFC][asan] Fix formatting of asan_interceptors.h (#170361)
Format the whole `asan_interceptors.h` file to prepare for some changes
in PR https://github.com/llvm/llvm-project/pull/131870.
2025-12-05 10:25:18 -05:00
Florian Mayer
b32e067e97 [compiler-rt] [UBSan] Fix missing preserve handlers (#170788) 2025-12-04 18:25:36 -08:00
Aiden Grossman
d6f92050c0 [XRay] Mark test unsupported on armhf
Tbis addresses a buildbot failure now that these tests actually run more
broadly.

error: ALWAYSINSTR: expected string not found in input
// ALWAYSINSTR: {{.*function-name:.*main.*}}
                ^
<stdin>:1:1: note: scanning from here
2025-12-02 14:38:01 +00:00
Aiden Grossman
f3501d70d8 [XRay] Mark default-options.cpp unsupported on ppc
This test fails now that it actually runs:

ld.lld: error: undefined symbol: std::__throw_system_error(int)
2025-12-02 04:55:39 +00:00
Aiden Grossman
c6f501d479 [XRay] Run tests inside bootstrapping build (#168378)
COMPILER_RT_STANDALONE_BUILD is set when doing a bootstrapping build
through LLVM_ENABLE_RUNTIMES with the CMake source directory being in
llvm/. This patch changes the XRay tests to also detect that we have
LLVM sources and the llvm-xray tool if we are in a bootstrapping build
through the use of the LLVM_TREE_AVAILABLE variable which is set in
runtimes/CMakeLists.txt.
2025-12-01 16:23:43 -08:00
Nico Weber
b73385dda5 [TySan] Attempt to unbreak build after #169036
If tysan was not in COMPILER_RT_SANITIZERS_TO_BUILD, we used to
get an error after #169036, see comments there for details.
2025-12-01 13:42:59 -05:00
anoopkg6
40aa91f12a [TySan] TySan support for SystemZ - Re-submission of original pr#162396 (#169850)
This is a re-submission of original reverted patch [(#162396)
](https://github.com/llvm/llvm-project/pull/162396url)for adding TySan
support for systemzZ along with build failure patch
[#169746](https://github.com/llvm/llvm-project/pull/169746).

See conversations in #169746.

Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-12-01 17:52:24 +01:00
Koakuma
3e16aef2a6 [SPARC] Properly handle CC for long double on sparc32 (#162226)
Pass and return `long double`s indirectly, as specified in the psABI.
This continues the patch at https://reviews.llvm.org/D89130.

This should fix the issue at https://github.com/llvm/llvm-project/issues/41838.
2025-11-29 21:30:39 +07:00
Mikołaj Piróg
442f853e28 [compiler-rt] Add missing cpuid check for clflushopt (#169900)
As in title.
2025-11-28 18:31:54 +01:00
Matthew Nagy
8c31b1214d [TySan](test-only) Mark ubsan-tysan test as unsupported for now (#169934) 2025-11-28 16:29:04 +00:00