19044 Commits

Author SHA1 Message Date
Josh Stone
bc1e0c53a2
[profile] Make the binary-id-offset.c test more robust (#117647)
Using a `--section-start` address in the test was causing link errors on
some targets. Now it uses a linker script to move the note after `.bss`,
which should still have the kind of memory offset we're looking for.

This is a follow-up to #114907 to fix buildbot errors.
2024-11-27 00:06:30 -05:00
B I Mohammed Abbas
06d24da131
Fix extendhfxf2 test (#117665)
Fix changes in #113897

Co-authored-by: Alex Richardson <alexrichardson@google.com>
2024-11-26 15:27:53 -08:00
Chris Apple
3a8b28f698
[rtsan] Add ioctl interceptor (#117569) 2024-11-26 15:17:04 -08:00
Vitaly Buka
8ffe63fb55 [nfc][asan] Fix typo in comment 2024-11-26 14:30:26 -08:00
Joel E. Denny
81349b84eb
[sanitizer] Use /tmp/ not /tmp/dir/ in tests (#117759)
Tests fail if the user doesn't own /tmp/dir/. On hosts with multiple
users running the test suite, who owns /tmp/dir/ can become a race.
2024-11-26 14:22:14 -08:00
bernhardu
36b1811da4
[win/asan] Add a test skeleton for function GetInstructionSize. (#116948)
Was first part of PR #113085.
2024-11-26 11:02:48 +01:00
B I Mohammed Abbas
a5dd646360
Add extendhfxf2 into compiler rt (#113897)
Retry of pr #109090 and #111099.

Co-authored-by: Alexander Richardson <alexrichardson@google.com>
2024-11-25 10:19:27 -08:00
Alexander Richardson
3cb28522ba
Reapply "[runtimes] Allow building against an installed LLVM tree"
This relands #86209 which was reverted because ./bin/llvm no longer
accepted test paths in the source tree instead of the build tree. This was
happening because `add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit`
was called before all tsst suites were registered, and therefore it was
missing the source->build dir mappings.

Original commit message:

I am currently trying to test the LLVM runtimes (including compiler-rt)
against an installed LLVM tree rather than a build tree (since that is
no longer available). Currently, the runtimes build of compiler-rt assumes
that LLVM_BINARY_DIR is writable since it uses configure_file() to write
there during the CMake configure stage. Instead, generate this file inside
CMAKE_CURRENT_BINARY_DIR, which will match LLVM_BINARY_DIR when invoked
from llvm/runtimes/CMakeLists.txt.

I also needed to make a minor change to the hwasan tests: hwasan_symbolize
was previously found in the LLVM_BINARY_DIR, but since it is generated as
part of the compiler-rt build it is now inside the CMake build directory
instead. I fixed this by passing the output directory to lit as
config.compiler_rt_bindir and using llvm_config.add_tool_substitutions().

For testing that we no longer write to the LLVM install directory as
part of testing or configuration, I created a read-only bind mount and
configured the runtimes builds as follows:
```
$ sudo mount --bind --read-only ~/llvm-install /tmp/upstream-llvm-readonly
$ cmake -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_COMPILER=/tmp/upstream-llvm-readonly/bin/clang \
  -DCMAKE_CXX_COMPILER=/tmp/upstream-llvm-readonly/bin/clang++ \
  -DLLVM_INCLUDE_TESTS=TRUE -DLLVM_ENABLE_ASSERTIONS=TRUE \
  -DCOMPILER_RT_INCLUDE_TESTS=TRUE -DCOMPILER_RT_DEBUG=OFF \
  -DLLVM_ENABLE_RUNTIMES=compiler-rt \
  -DCMAKE_DISABLE_FIND_PACKAGE_LLVM=TRUE \
  -DCMAKE_DISABLE_FIND_PACKAGE_Clang=TRUE \
  -G Ninja -S ~/upstream-llvm-project/runtimes \
  -B ~/upstream-llvm-project/runtimes/cmake-build-debug-llvm-git
```

Pull Request: https://github.com/llvm/llvm-project/pull/114307
2024-11-25 10:13:00 -08:00
Hans
55f5d68c2d
[win/asan] Recognize mov QWORD PTR [rip + X], reg (#117335)
This comes up when intercepting clang-built `__sanitizer_cov` functions.
2024-11-25 09:50:08 +01:00
gbMattN
4d4a353b8e
[TSan] Increase the number of simultaneously locked mutexes that a thread can hold (#116409)
I've run into an issue where TSan can't be used on some code without
turning off deadlock detection because a thread tries to hold too many
mutexes. It would be preferable to be able to use deadlock detection as
that is a major benefit of TSan.

Its mentioned in https://github.com/google/sanitizers/issues/950 that
the 64 mutex limit was an arbitrary number. I've increased it to 128 and
all the tests still pass. Considering the increasing number of cores on
CPUs and how programs can now use more threads to take advantage of it,
I think raising the limit to 128 would be some good future proofing

---------

Co-authored-by: Vitaly Buka <vitalybuka@google.com>
2024-11-24 00:58:39 -08:00
Vitaly Buka
5fa0345d90
[tsan] Unwind for CHECK according to fast_unwind_on_fatal (#117470)
It's needed for #116409, which hangs with slow
unwind.
2024-11-24 00:25:06 -08:00
bernhardu
6c52a18a1d
[win/asan] GetInstructionSize: Fix 8A 05 ... to return 6 again. (#116889)
This was already the case before 3bd8f4e,
which probably accidentally inserted
a few new instructions and a return 4 in between.
2024-11-21 23:17:11 +02:00
Thurston Dang
9ba6672b9f
[sanitizer_common] Intercept timespec_get except for hwasan (#117080)
Intercept timespec_get for all sanitizers except for hwasan
2024-11-21 12:29:18 -08:00
bernhardu
b89e774672
[win/asan] Avoid warnings in compiling interception_win_test.cpp. (#116887)
Example:
  warning: unused variable 'kPatchableCode12' [-Wunused-const-variable]
2024-11-21 22:11:49 +02:00
Josh Stone
667e1fadcf
[profile] Use base+vaddr for __llvm_write_binary_ids note pointers (#114907)
This function is always examining its own ELF headers in memory, but it
was trying to use conditions between examining files or memory, and it
wasn't accounting for LOAD offsets at runtime. This is especially bad if
a loaded segment has additional padding that's not in the file offsets.

Now we do a first scan of the program headers to figure out the runtime
base address based on `PT_PHDR` and/or `PT_DYNAMIC` (else assume zero),
similar to libc's `do_start`. Then each `PT_NOTE` pointer is simply the
base plus the segments's `pt_vaddr`, which includes LOAD offsets.

Fixes #114605
2024-11-21 10:14:29 -08:00
Chris Apple
595e484c08
[rtsan] Add option to allow printing of duplicate stacks (suppress_equal_stacks) (#117069)
Following the example of tsan, where we took the name

This would allow users to determine if they want to see ALL output from
rtsan.

Additionally, remove the UNLIKELY hint, as it is now up to the flag whether or
not it is likely that we go through this conditional.
2024-11-21 06:32:05 -08:00
Chris Apple
963b8e36bb
[rtsan] Add sched_yield interceptor (#117084)
This calls the system calls switch_pri and sys_ulock_wait. It also is
one of the more straightforwardly rt-unsafe, in that it gives up this
thread's timeslice.
2024-11-21 06:30:45 -08:00
Lang Hames
7c0786363e [ORC-RT] Test basic C++ static initialization support in the ORC runtime.
This tests that a simple C++ static initializer works as expected.

Compared to the architecture specific, assembly level regression tests for the
ORC runtime; this test is expected to catch cases where the compiler adopts
some new MachO feature that the ORC runtime does not yet support (e.g. a new
initializer section).
2024-11-21 18:20:43 +11:00
Chris Apple
934140a335
[rtsan] Remove mkfifoat interceptor (#116997)
This partially reverts #116915
[fce917d](fce917d39d)

mkfifoat was improperly guarded against in MacOS systems
2024-11-20 08:27:58 -08:00
Chris Apple
fce917d39d
[rtsan] Add pipe, mkfifo interceptors (#116915)
## Why we think this are unsafe

Again, these correspond directly to system calls on linux and OSX. They
are two ways to do interprocess communication so it would make sense
that they take some synchronization by the OS.
2024-11-20 07:47:14 -08:00
Daniel Kiss
77bf34c315
[AArch64][compiler-rt] Add LSE support for Windows. (#116706) 2024-11-20 11:05:31 +01:00
Fangrui Song
ac38ab594f
[lsan] Use VReport if not REGISTERS_AVAILABLE (#116555)
Certain tests (many are from lld/test) run `... '2>&1 | count 0` to
ensure that there is no stderr message.

GetRegistersAndSP may rarely fail, leading to
a spurious failure like (with a local hack to make `count` dump the
input):

```
+ /home/ray/llvm/out/asan/bin/ld.lld func1-gcs.o func2-gcs.o func3-gcs.o -o /dev/null -z gcs-report=warning -z gcs=never
+ /home/ray/llvm/out/asan/bin/count 0
Expected 0 lines, got 1.
==2403039==Unable to get registers from thread 2403018.
```

The failure can reliably be reproduced by running `ninja check-lld` a
few times under asan+lsan (see the bot
sanitizer-x86_64-linux-bootstrap-asan).
2024-11-20 01:07:28 -08:00
Chris Apple
3c8818cf2d
[rtsan] Add more file descriptor interceptors - dup*, lseek (#116853)
# Why we think these are real-time unsafe

They correspond directly to system calls in linux and OSX, they are
manipulating a shared resource, which likely takes some operating-system
synchronization.
2024-11-19 14:54:14 -08:00
Chris Apple
7c41b5ccdc
[rtsan] Add support for ReportErrorSummary (#116424)
Adding support for the extra SUMMARY line that is output by most
compilers. This also adds the ability for end-users to specify their own
handlers for reporting these errors (see the test).
2024-11-19 14:53:47 -08:00
Florian Mayer
0488d1774b
Reland "[Sanitizers] Intercept timer_create" (#113710) (#116717)
Original commit 2ec5c69b6872b8b474f3d37b9125d3d57d144d1b only
intercepted timer_create.

Because of how versioned libc symbols work, this could cause problems
where a newer `timer_create`
was used, and the result would be used by an older version. This would
cause crashes. This is why we
need to intercept all of the related functions.

Addresses https://github.com/llvm/llvm-project/issues/111847
2024-11-18 23:18:54 -08:00
Wael Yehia
a17f11baa1 [test][PGO] Add a multi-threaded test for continuous PGO. 2024-11-19 04:57:33 +00:00
Chris Apple
9c3665c8d2
[rtsan] Add I/O multiplexing interceptors (#115227)
Intercepts in the family of `poll`, `select` and modern equivalents
`epoll` (linux only) and `kqueue` bsd family only.

These calls mirror the names of the system calls they call, which have
been verified on mac at least (e.g. kevent calls the system call
kevent).
2024-11-18 15:29:49 -08:00
Wael Yehia
7b525495e8 [test][PGO] Use -fprofile-update=atomic instead of mllvm option in ContinuousSyncMode/online-merging.c 2024-11-18 20:04:20 +00:00
Freddy Ye
97836bed63
Reland "[X86] Support -march=diamondrapids (#113881)" (#116564)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
2024-11-18 10:40:32 +08:00
Freddy Ye
90e92239bd
Revert "[X86] Support -march=diamondrapids (#113881)" (#116563)
This reverts commit 826b845c9e97448395431be3e4e5da585bd98c5e.
2024-11-18 08:45:28 +08:00
Freddy Ye
826b845c9e
[X86] Support -march=diamondrapids (#113881)
Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
2024-11-18 08:31:17 +08:00
Wael Yehia
4f2651c363
[PGO][test] Enable continuous mode PGO tests on AIX (#115987)
Co-authored-by: Wael Yehia <wyehia@ca.ibm.com>
2024-11-14 22:18:01 -05:00
Chris Apple
d761b7485d
[rtsan] NFC: Add comment about O_NONBLOCK behavior (#116189) 2024-11-14 15:49:00 -08:00
Enna1
9f96f1cb6f
[sanitizer] print both class id and corresponding size when region is exhausted (#116186) 2024-11-14 12:18:11 -08:00
Thurston Dang
531acf9e2f
Reapply "[sanitizer_common] AND signals in BlockSignals instead of deleting (#113443)" for non-Android Linux only (#115790)
The original patch (25fd366d6a7d40266ff27c134ed8beb0a90cc33b) was
reverted in 083a5cdbeab09517d8345868970d4f41170d7ed2 because it broke
some buildbots.

This revised patch makes two changes:
- Reverts to *pre-#98200* behavior for Android. This avoids a build
breakage on Android.
- Only define KeepUnblocked if SANITIZER_LINUX: this avoids a build
breakage on solaris, which does not support internal_sigdelset.
N.B. Other buildbot failures were non-sanitizer tests and are therefore
unrelated.

Original commit message:
    My earlier patch https://github.com/llvm/llvm-project/pull/98200
    caused a regression because it unconditionally unblocked synchronous
    signals, even if the user program had deliberately blocked them.
    This patch fixes the issue by checking the current signal mask, as
    suggested by Vitaly. It also adds tests.
    Fixes #113385
2024-11-14 10:35:35 -08:00
Wu Yingcong
6c9256dc5c
[ASAN] fix a nullptr dereference error. (#116011)
`parent_context` is used without checking for nullptr and we can see in
LINE 50 that it could totally be nullptr. This patch addresses this
issue.
2024-11-13 15:46:57 -08:00
Daniel Kiss
2a1586dfb5
[compiler-rt] Add cpu model init for Windows. (#111961) 2024-11-13 11:05:40 +01:00
NAKAMURA Takumi
1c9467f148 compiler-rt/lib: Fix newline at eof 2024-11-12 23:41:25 +09:00
Feng Zou
28e4aad45a
[X86][BF16] Add libcall for FP128 -> BF16 (#115825)
This is to fix #115710.
2024-11-12 15:54:09 +08:00
Florian Mayer
f9125ddc1f
Revert "[libfuzzer] use timer_create() instead of setitimer() for linux" (#115811)
Reverts llvm/llvm-project#110274

Buildbots broke
2024-11-11 19:50:30 -08:00
Min
3b29a8a008
[libfuzzer] use timer_create() instead of setitimer() for linux (#110274)
SetTimer() now uses setitimer() to sending SIGALRM every `
UnitTimeoutSec/2 + 1` s
Set UnitTimeoutSec with the `-timeout=` option

"POSIX.1-2008 marks getitimer() and setitimer() obsolete" and also has
some issues regarding accuracy of the timers under load . See
https://linux.die.net/man/2/setitimer.
I propose using timer_create() and sigaction() ,See
http://man7.org/linux/man-pages/man2/timer_create.2.html

# test result on my x86_64 linux
`make check-fuzzer`

![image](https://github.com/user-attachments/assets/19b4e073-16a5-4daa-95ed-2cf4830c042f)
2024-11-11 19:12:30 -08:00
Vitaly Buka
9254b81990
[tsan] Fix typo in type (#115769)
Introduced with #114931
Fixes https://github.com/golang/go/issues/70283
2024-11-11 13:16:27 -08:00
Alexander Richardson
5082acce4f
[compiler-rt] Add custom libc++ workaround for CMake < 3.26
The INSTALL_BYPRODUCTS ExternalProject_Add() argument was only added in
CMake 3.26 and the current minimum is 3.20. Work around this by using an
explicit ExternalProject_Add_Step() call for the install step with a
BYPRODUCTS argument. We can't keep using the `install` name here since that
is reserved by the CMake implementation and results in errors when used.

This commit should be reverted once LLVM depends on CMake 3.26.

Pull Request: https://github.com/llvm/llvm-project/pull/115677
2024-11-10 20:30:23 -08:00
c8ef
59770a4382
[NFC] Correct imprecise file location in the comment. (#115630) 2024-11-10 15:23:58 +08:00
Alexander Richardson
a29e623e12
[compiler-rt] Make add_custom_libcxx() resilient to DESTDIR being set
If DESTDIR is set in the environment during the build/test stage, the
local libc++ installation will be installed under DESTDIR instead of being
in the build directory.

See https://github.com/llvm/llvm-project/pull/115077#issuecomment-2464640457
and https://gitlab.kitware.com/cmake/cmake/-/issues/18165.

Pull Request: https://github.com/llvm/llvm-project/pull/115525
2024-11-08 11:45:38 -08:00
Alexandros Lamprineas
799e520c51
[FMV] Remove feature dgh. (#115363)
It belongs to the HINT space so it can be executed as NOP if the
hardware doesn't support it.

Reviewed in ACLE -> https://github.com/ARM-software/acle/pull/357
2024-11-08 10:18:41 +00:00
Sebastian Kreutzer
1adca7af21
Reapply "[XRay][AArch64] Support -fxray-shared (#114431)" (#115300)
This patch implements support for `-fxray-shared` on AArch64 and fixes a
remaining issue in the previous PR #114431.

A bug in the XRay `CMakeLists.txt` caused the XRay assembly sources to
be built for every architecture in `XRAY_DSO_SUPPORTED_ARCH` on Apple.
This led to the compiler trying to compile AArch64 assembly for X86
targets and vice versa.
This is addressed here by ensuring that assembly sources are only built
for the matching architecture (see fixup commit).

**Original PR description:**
This patch adds support for `-fxray-shared` on AArch64. This feature,
introduced in #113548 for x86_64, enables the instrumentation of shared
libraries with XRay.

Changes:
- Adds AArch64 to the list of targets supporting `-fxray-shared`
- Introduces PIC versions of the AArch64 XRay trampolines 
- Adjusts relevant XRay tests
2024-11-07 23:21:04 -08:00
Alexandros Lamprineas
e8b7d8bfb5
[FMV][AArch64] Remove features which expose non exploitable runtime behavior. (#114387)
Features ebf16, memtag3, and rpres allow existing instructions to behave
differently depending on the value of certain control registers. FMV
does not read the content of control registers making these features
unsuitable for runtime dispatch. See the ACLE patch for more info:
https://github.com/ARM-software/acle/pull/355
2024-11-07 17:15:23 +00:00
Keith Packard
5a8956ea8b
[compiler-rt][libunwind] Support aarch64 without FPU (#111235)
These two libraries don't build for `-march=armv8-a+nofp
-mabi=aapcs-soft` as a couple of uses of floating point instructions and
registers have crept in.

In libunwind, skip save/restore of FPU registers on targets without them.
In compiler-rt, fall back to the old C implementation of __arm_sc_memset when
the target doesn't have an FPU.

---------

Signed-off-by: Keith Packard <keithp@keithp.com>
2024-11-07 08:32:45 -08:00
Kito Cheng
522880cb99
[compiler-rt][RISCV] Avoid using __init_riscv_feature_bits as a direc… (#115316)
…t constructor

`__init_riscv_feature_bits` takes an argument that can be
platform-specific, potentially pointing to the VDSO address of the
hwprobe system call for Linux. However, marking it as a constructor does
not guarantee that 0/NULL will always be passed to this argument, which
may result in treating an uninitialized or garbage value as a pointer to
hwprobe, leading to a crash.

The simplest solution is to introduce a small constructor function to
ensure that the platform-specific argument is set to 0/NULL.
2024-11-08 00:06:48 +08:00