19044 Commits

Author SHA1 Message Date
Rainer Orth
11903e8c96
[sanitizer][test] Unify LD_LIBRARY_PATH handling (#111498)
When testing on Linux/sparc64 with a `runtimes` build, the
`UBSan-Standalone-sparc :: TestCases/Misc/Linux/sigaction.cpp` test
`FAIL`s:
```
runtimes/runtimes-bins/compiler-rt/test/ubsan/Standalone-sparc/TestCases/Misc/Linux/Output/sigaction.cpp.tmp: error while loading shared libraries: libclang_rt.ubsan_standalone.so: wrong ELF class: ELFCLASS64
```
It turns out SPARC needs the same `LD_LIBRARY_PATH` handling as x86.

This is what this patch does, at the same time noticing that the current
duplication between `lit.common.cfg.py` and
`asan/Unit/lit.site.cfg.py.in` isn't necessary.

Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.
2024-10-15 10:06:11 +02:00
Rainer Orth
e290152181
[ubsan][test] Enable Misc/Linux tests on all Posix systems (#111497)
When investigating PR #101634, it turned out that
`UBSan-Standalone-sparc :: TestCases/Misc/Linux/diag-stacktrace.cpp`
isn't Linux-specific at all. In fact, none of the
`ubsan/TestCases/Misc/Linux` tests are.

Therefore this patch moves them to `Misc/Posix` instead.

Tested on `sparc64-unknown-linux-gnu`, `sparcv9-sun-solaris2.11`,
`x86_64-pc-linux-gnu`, and `amd64-pc-solaris2.11`.
2024-10-15 09:49:57 +02:00
ChiaHungDuan
cb3e7b39a5
Reapply "[scudo] Apply the min release threshold to the group" (#112252) (#112266)
This reverts commit 037938d637b830332e50232d7b90b5faad039c11.

Fixed the iterator to avoid infinite loop
2024-10-14 21:30:44 -07:00
David CARLIER
706c9dae50
[compiler-rt] Fix GH-112254 DumpAllRegs for win arm64. (#112305) 2024-10-15 05:12:52 +01:00
Florian Mayer
b373278767
[Sanitizers] Intercept timer_create (#112285) 2024-10-14 20:46:45 -07:00
David CARLIER
b8ee0aac2a
[compiler-rt] DumpAllRegisters implementation for windows arm64. (#112254) 2024-10-14 23:13:37 +01:00
Paul Kirth
c4131cb56c
[Fuchsia][cmake] Avoid referencing cxx_shared in compiler-rt (#112257)
After https://github.com/llvm/llvm-project/pull/80007 Fuchsia builds are
now always building cxx_shared for arm64 and x64 Linux. Ultimately, this
is because the LIBCXX_ENABLE_SHARED is not used in compiler-rt to select
the correct libc++ target, and because cxx_shared is now always defined,
it is selected as a dependency when building runtimes tests.

---------

Co-authored-by: Petr Hosek <phosek@google.com>
2024-10-14 14:41:19 -07:00
ChiaHungDuan
037938d637
Revert "[scudo] Apply the min release threshold to the group" (#112252)
Reverts llvm/llvm-project#112014

The change didn't update the iterator
2024-10-14 12:53:07 -07:00
Thomas Petazzoni
a1217020da
Undef _TIME_BITS along with _FILE_OFFSET_BITS
This change is identical to
26800a2c7e7996dc773b4e990dd5cca41c45e1a9 ("[sanitizer] Undef
_TIME_BITS along with _FILE_OFFSET_BITS on Linux"), but for
sanitizer_procmaps_solaris.cpp.

Indeed, even though sanitizer_procmaps_solaris.cpp is Solaris
specific, it also gets built on Linux platforms. It also includes
sanitizer_platform.h, which also ends up including features-time64.h,
causing a build failure on 32-bit Linux platforms on which 64-bit
time_t is enabled by setting _TIME_BITS=64.

To fix this, we do the same change: undefine _TIME_BITS, which anyway
will cause no harm as the rest of this file is inside a
SANITIZER_SOLARIS compile-time conditional.

Fixes:

In file included from /home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features.h:394,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform.h:25,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_procmaps_solaris.cpp:14:
/home/thomas/buildroot/buildroot/output/host/i686-buildroot-linux-gnu/sysroot/usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is al
lowed only with _FILE_OFFSET_BITS=64"
   26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
      |     ^~~~~

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Closes: https://github.com/llvm/llvm-project/pull/99699
2024-10-14 20:02:26 +01:00
ChiaHungDuan
53c9553562
[scudo] Apply the min release threshold to the group (#112014)
For the block smaller than a page size, one block is unlikely to
introduce more unused pages (at most 2 if it acrosses the page boundary
and both touched pages are unused). So it's better to apply the
threshold to reduce the time of scanning groups that can't release any
new pages.
2024-10-14 10:46:12 -07:00
Yuta Saito
d4efc3e097
[Coverage][WebAssembly] Add initial support for WebAssembly/WASI (#111332)
Currently, WebAssembly/WASI target does not provide direct support for
code coverage.
This patch set fixes several issues to unlock the feature. The main
changes are:

1. Port `compiler-rt/lib/profile` to WebAssembly/WASI.
2. Adjust profile metadata sections for Wasm object file format.
- [CodeGen] Emit `__llvm_covmap` and `__llvm_covfun` as custom sections
instead of data segments.
    - [lld] Align the interval space of custom sections at link time.
- [llvm-cov] Copy misaligned custom section data if the start address is
not aligned.
    - [llvm-cov] Read `__llvm_prf_names` from data segments
3. [clang] Link with profile runtime libraries if requested

See each commit message for more details and rationale.
This is part of the effort to add code coverage support in Wasm target
of Swift toolchain.
2024-10-15 02:41:43 +09:00
Raul Tambre
9cc6d6e9a9
[compiler-rt] Explicitly enable C extensions for profile (#110555)
The profiling code requires GNU extensions as it uses functions such as getpagesize(), fdopen(), etc.

The problem manifests when the compiler is built to not default to the extensions mode, e.g. custom config with -std=c2x. CMake didn't support this scenario very well, but it's been fixed by CMP0128. Set the policy to NEW as we now conform to it.
2024-10-14 15:07:11 +03:00
NAKAMURA Takumi
851817b494 fuzzer/strncmp.test: Increase iteration to 20M.
I saw cases that this finised before finding `BINGO`, possibly
insufficient number of iteration. In my case, 11,067,133 satisfied.

So, increase the number for now. This change may increase the duration
of this in failing (`BINGO` not found) case.
2024-10-14 18:34:36 +09:00
Yangyu Chen
7fc3491c04
[compiler-rt][RISCV] Use u64 data type for marchid and mimpid (#112163)
Base on https://github.com/riscv-non-isa/riscv-c-api-doc/pull/91 , the
marchid and mimpid are MXLEN bits wide, and kernel returned them as u64
data type. So we should use u64 data type for marchid and mimpid in
__riscv_cpu_model struct here.

Signed-off-by: Yangyu Chen <cyy@cyyself.name>
2024-10-14 16:23:01 +08:00
David CARLIER
e866e6b8bb
[compiler-rt] Implements DumpAllRegisters for windows intel archs. (#108688) 2024-10-12 21:10:47 +01:00
Chris Apple
4468d58080
[rtsan] Support basic call stack suppressions (#111608)
This adds basic support for suppressions, which is a first class feature
of the other sanitizers.
2024-10-12 11:13:36 -07:00
Vitaly Buka
fa81868fe6
[lsan] Log thread history (#111949)
Only with high verbosity and leak reports, or thread logging requested.
2024-10-11 18:09:37 -07:00
Vitaly Buka
aa44f59abf
[NFC][sanitizer] Add Debug utility to print thread history (#111948)
For #111949
2024-10-11 16:58:42 -07:00
Vitaly Buka
e1cff8bf81
[lsan] Add debug option to "deflake" leaks (#112037)
There are hard to debug leaks which look like
false.

In general, repeating leak checking should not
affect set of leaks significantly, especial
`at_exit` leak checking.

But if we see significant discrepancy, it may give
us a clue for investigation.
2024-10-11 16:57:19 -07:00
Vitaly Buka
abe148a09f
[NFC][sanitizer][asan] Promote stack_id into ThreadContextBase (#111917)
`parent_id` and `stack_id` represent location
where the thread was created, so it's reasonable
to keep them togeter.

For now, only Asan and MemProf use `stack_id`,
but it will be halpfull to print thread origin from
other sanitizers as well.

For #111948
2024-10-11 14:47:01 -07:00
Sunho Kim
188ede28e0 [ORC] Implement basic reoptimization. 2024-10-12 01:21:05 +09:00
Mikhail Goncharov
90627a5a19 Revert "[XRay] Add support for instrumentation of DSOs on x86_64 (#90959)"
This reverts commit a4402039bffd788b9af82435fd5a2fb311fdc6e8 and 4451f9f812d458f6b53785b27869674caf01e67b
2024-10-11 14:01:58 +02:00
Sebastian Kreutzer
4451f9f812
[XRay] Fix LLVM include in xray_interface.cpp (#111978)
Removes a dependency on LLVM in `xray_interface.cpp` by replacing
`llvm_unreachable` with compiler-rt's `UNREACHABLE`.
Applies clang-format to some unformatted changes. 

Original PR: #90959
2024-10-11 13:11:03 +02:00
Sebastian Kreutzer
a4402039bf
[XRay] Add support for instrumentation of DSOs on x86_64 (#90959)
This PR introduces shared library (DSO) support for XRay based on a
revised version of the implementation outlined in [this
RFC](https://discourse.llvm.org/t/rfc-upstreaming-dso-instrumentation-support-for-xray/73000).
The feature enables the patching and handling of events from DSOs,
supporting both libraries linked at startup or explicitly loaded, e.g.
via `dlopen`.
This patch adds the following:
- The `-fxray-shared` flag to enable the feature (turned off by default)
- A small runtime library that is linked into every instrumented DSO,
providing position-independent trampolines and code to register with the
main XRay runtime
- Changes to the XRay runtime to support management and patching of
multiple objects

These changes are fully backward compatible, i.e. running without
instrumented DSOs will produce identical traces (in terms of recorded
function IDs) to the previous implementation.

Due to my limited ability to test on other architectures, this feature
is only implemented and tested with x86_64. Extending support to other
architectures is fairly straightforward, requiring only a
position-independent implementation of the architecture-specific
trampoline implementation (see
`compiler-rt/lib/xray/xray_trampoline_x86_64.S` for reference).

This patch does not include any functionality to resolve function IDs
from DSOs for the provided logging/tracing modes. These modes still work
and will record calls from DSOs, but symbol resolution for these
functions in not available. Getting this to work properly requires
recording information about the loaded DSOs and should IMO be discussed
in a separate RFC, as there are mulitple feasible approaches.

@petrhosek @jplehr
2024-10-11 11:23:34 +02:00
Vitaly Buka
3cb4d20d5b [NFC][sanitizer] Simplify GetThreadLocked
Now we can pass `invalid tid`.
2024-10-10 21:20:11 -07:00
Vitaly Buka
df4c913425
[asan] Print unique_id instead of tid (#111925)
Before the first reuse, after 2^32 threads
they are equal.
2024-10-10 21:04:25 -07:00
Vitaly Buka
e556f0787c
[NFC][asan] Cleanup AsanThreadIdAndName ctor/init (#111923)
Co-authored-by: YunQiang Su <yunqiang@isrc.iscas.ac.cn>
2024-10-10 21:03:29 -07:00
Vitaly Buka
36639af8ad
[NFC][sanitizer] VReport incomplete list (#111944) 2024-10-10 21:01:07 -07:00
Vitaly Buka
374886a360
[NFC][sanitizer] Check suspended threads outside ThreadSuspender::SuspendThread (#111943)
Allows to distinguish failure from stopped threads.
2024-10-10 20:59:48 -07:00
Vitaly Buka
59b2945c70
[sanitizer] Fix ThreadLister::IsAlive (#111942)
'status_path_' must include `tid`.
Regression from #111909.
2024-10-10 20:57:34 -07:00
Vitaly Buka
e01ae3920d
[NFC][sanitizer] Use tid_t instead of int in ThreadLister (#111941) 2024-10-10 20:56:25 -07:00
Vitaly Buka
9c81a24765
[asan] Prevent printing invalid parent thread (#111916)
By default reuse can happend only after
`UINT32_MAX` threads, so it's almost NFC.
2024-10-10 17:44:57 -07:00
Vitaly Buka
af7fa2710c
[sanitizer] VReport thread status for failed PTRACE_ATTACH (#111901)
Such threads can cause false leak reports,
but often it's hard to diagnose the reason of
failed PTRACE_ATTACH. Maybe we can find
a clue from `/proc/*/task/*/status`
2024-10-10 14:53:16 -07:00
Vitaly Buka
5deadc6eae
[NFC][sanitizer] Extract LoadStatus (#111909)
For #111901
2024-10-10 14:52:50 -07:00
Wael Yehia
16ef893e9f [test] env -u is not supported on AIX, use unset instead 2024-10-10 21:35:10 +00:00
Vitaly Buka
195486950f [NFC][sanitizer] Fix at_scope_exit name. 2024-10-10 13:28:45 -07:00
Vitaly Buka
36bd9aebc4
[sanitizer] VReport BeforeFork/AfterFork (#111900)
Forks are common suspects for unusual sanitizer behavior.
It can be handy to see them without rebuild.
2024-10-10 13:12:36 -07:00
Vitaly Buka
942fefe741 [NFC][sanitizer] Reopen '/proc/%d/task' instead of seek
NFC because I am not aware of any particular
issue from seek, but reopen looks less error prone.

Pull Request: https://github.com/llvm/llvm-project/pull/111899
2024-10-10 13:09:01 -07:00
Vitaly Buka
07892aaf04 [NFC][sanitizer] Clang format sanitizer_thread_registry.cpp 2024-10-10 12:36:26 -07:00
Vitaly Buka
453d373e80 [lsan] Add a few "\n" missing from VReport 2024-10-10 11:24:36 -07:00
Wael Yehia
dc09f96441 [test] remove profile file at the start of profile/instrprof-write-file-atexit-explicitly.c 2024-10-09 17:54:24 +00:00
Martin Storsjö
fb2960aad9
[compiler-rt] [profile] Add missing (void) to prototypes, for C sources (#110642)
If built as part of the main llvm build, via
ENABLE_LLVM_PROJECTS=compiler-rt, the code gets built with more warning
options than if built standalone. Some of these trigger warnings like:

warning: a function declaration without a prototype is deprecated in all
versions of C [-Wstrict-prototypes]
2024-10-09 09:30:32 +03:00
Vitaly Buka
b26aac5a44 [sanitizer] Report -> VReport for ThreadLister failure 2024-10-08 23:11:58 -07:00
David CARLIER
d0b9c2c564
[compiler-rt] Remove SHA2 interceptions for NetBSD/FreeBSD. (#110246)
To Fix #110215

Interceptors introduced with 18a7ebda99044473fdbce6376993714ff54e6690
2024-10-09 05:47:00 +01:00
David CARLIER
a8eb12cdc9
[compiler-rt] Reapply freadlink interception for macOs. (#110917)
Fixed test, needed explicit O_SYMLINK on symbolic link opening.
2024-10-08 23:50:39 +01:00
Chris Apple
3423a5e3b7
[rtsan][NFC] Refactor where we unwind the stack (#111443)
This change alters where we unwind the stack. We now do it in ExpectNotRealtime, and pass in the DiagnosticInfo and Stack to OnViolation.
2024-10-08 14:26:17 -07:00
lizhijin1024
b44371194b
[rtsan] Ensure pthread is initialized in test (#111401)
Handle running stuck of `pthread_cond_destroy` on X86 in test
`PthreadCondSignalDiesWhenRealtime` and
`PthreadCondBroadcastDiesWhenRealtime`.
2024-10-08 09:19:32 +08:00
gbMattN
75103aae4a
Added include of common interfaces (#111374)
Pull request for issue #110823 
Including the file which defines the macros we use here. This would let
user code only include this interface, rather than having to include two
files.
2024-10-07 14:28:19 -07:00
Chris Apple
9e06e772a1
[rtsan] Add stats summary even when halt_on_error=true (#110165) 2024-10-07 14:26:09 -07:00
Chris Apple
10d43061aa
[rtsan][NFC] Refactor to scoped bypasser for __rtsan::Context (#111438) 2024-10-07 14:24:54 -07:00