Commit Graph

15378 Commits

Author SHA1 Message Date
Vitaly Buka 7cd7b4d2f8 [sanitizer] Add common "demangle" flag
Reviewed By: browneee

Differential Revision: https://reviews.llvm.org/D116202
2021-12-23 14:36:39 -08:00
Vitaly Buka f103ee2e9e [sanitizer] Move internal_symbolizer "inline" option
This option is per process anyway. I'd like to add more options, but
having them as parameters of __sanitizer_symbolize_code looks
inconvenient.

Reviewed By: browneee

Differential Revision: https://reviews.llvm.org/D116201
2021-12-23 11:28:03 -08:00
Vitaly Buka a7ebf2010e [NFC][sanitizer] Increase kArgVMax to 16
D116202 uses all availible slots.
2021-12-23 11:11:47 -08:00
Vitaly Buka 9fe0d67c9a [sanitizer] Check kArgVMax in SymbolizerProcess::GetArgV 2021-12-23 11:05:37 -08:00
Kirill Stoimenov 4bf31659fa Revert "[ASan] Moved optimized callbacks into a separate library."
This reverts commit ab3640aa0e.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D116223
2021-12-23 17:13:18 +00:00
Kirill Stoimenov ab3640aa0e [ASan] Moved optimized callbacks into a separate library.
This will allow linking in the callbacks directly instead of using PLT.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D116182
2021-12-23 16:40:36 +00:00
Andrew Browne d39d2acfdd [DFSan] Make dfsan_read_origin_of_first_taint public.
Makes origins easier to use with dfsan_read_label(addr, size).

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D116197
2021-12-22 23:45:30 -08:00
Azat Khuzhin 856550ca79 [Sanitizer] Fix setbuffer() interceptor (it accept size, not mode)
Fixes: 0c81a62d9d ("[Sanitizer] Adding setvbuf in supported platforms and other stream buffer functions")

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D116176
2021-12-22 22:13:36 -08:00
Vitaly Buka 9f3aca7eae [sanitizer] Support symbolize_inline_frames by addr2line 2021-12-22 21:28:38 -08:00
Vitaly Buka 4316859e6a [NFC][sanitizer] Format the test 2021-12-22 21:25:51 -08:00
Vitaly Buka 4126b08662 [NFC][sanitizer] Format a part of the file 2021-12-22 21:25:51 -08:00
Andrew Browne ed6c757d5c [DFSan] Add functions to print origin trace from origin id instead of address.
dfsan_print_origin_id_trace
dfsan_sprint_origin_id_trace

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D116184
2021-12-22 16:45:54 -08:00
Vitaly Buka 63997782a0 [NFC][sanitizer] Reformat script 2021-12-22 14:48:42 -08:00
Vitaly Buka 6c67ff4b05 [NFC][sanitizer] Reformat a part of the file 2021-12-22 14:48:42 -08:00
Nikita Popov a9bb97e841 [msan] Break optimization in memccpy tests
After D116148 the memccpy gets optimized away and the expected
uninitialized memory access does not occur.

Make sure the call does not get optimized away.
2021-12-22 14:45:20 +01:00
Julian Lettner 63ddf0baf3 [TSan] Don't instrument code that is executed from __tsan_on_report()
See also: https://reviews.llvm.org/D111157
2021-12-21 17:02:51 -08:00
Kirill Stoimenov 2477e69c6d [ASan] Change optimized callbacks visibility to hidden.
Making callbacks hidden will remove PLT calls.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D116121
2021-12-21 21:32:30 +00:00
Dmitry Vyukov f78d49e068 tsan: remove old vector clocks
They are unused in the new tsan runtime.

Depends on D112604.

Reviewed By: vitalybuka, melver

Differential Revision: https://reviews.llvm.org/D112605
2021-12-21 19:54:27 +01:00
Dmitry Vyukov 22a251c3d0 tsan: remove hacky call
It's unused in the new tsan runtime.

Depends on D112603.

Reviewed By: vitalybuka, melver

Differential Revision: https://reviews.llvm.org/D112604
2021-12-21 19:53:49 +01:00
Dmitry Vyukov 9789e74a90 tsan: reduce shadow ranges
The new tsan runtime has 2x more compact shadow.
Adjust shadow ranges accordingly.

Depends on D112603.

Reviewed By: vitalybuka, melver

Differential Revision: https://reviews.llvm.org/D113751
2021-12-21 19:53:19 +01:00
Dmitry Vyukov 53fc462513 tsan: remove unused variable
Depends on D113983.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113984
2021-12-21 19:52:34 +01:00
Dmitry Vyukov c82bd4c5ba tsan: use VReport instead of VPrintf in background thread
If there are multiple processes, it's hard to understand
what output comes from what process.
VReport prepends pid to the output. Use it.

Depends on D113982.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113983
2021-12-21 19:51:48 +01:00
Dmitry Vyukov 05ca57a054 tsan: better maintain current time in the background thread
Update now after long operations so that we don't use
stale value in subsequent computations.

Depends on D113981.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113982
2021-12-21 19:51:39 +01:00
Dmitry Vyukov d95baa98f3 tsan: fix failures after multi-threaded fork
Creating threads after a multi-threaded fork is semi-supported,
we don't give particular guarantees, but we try to not fail
on simple cases and we have die_after_fork=0 flag that enables
not dying on creation of threads after a multi-threaded fork.
This flag is used in the wild:
23c052e3e3/SConstruct (L3599)

fork_multithreaded.cpp test started hanging in debug mode
after the recent "tsan: fix deadlock during race reporting" commit,
which added proactive ThreadRegistryLock check in SlotLock.

But the test broke earlier after "tsan: remove quadratic behavior in pthread_join"
commit which made tracking of alive threads based on pthread_t stricter
(CHECK-fail on 2 threads with the same pthread_t, or joining a non-existent thread).
When we start a thread after a multi-threaded fork, the new pthread_t
can actually match one of existing values (for threads that don't exist anymore).
Thread creation started CHECK-failing on this, but the test simply
ignored this CHECK failure in the child thread and "passed".
But after "tsan: fix deadlock during race reporting" the test started hanging dead,
because CHECK failures recursively lock thread registry.

Fix this purging all alive threads from thread registry on fork.

Also the thread registry mutex somehow lost the internal deadlock detector id
and was excluded from deadlock detection. If it would have the id, the CHECK
wouldn't hang because of the nested CHECK failure due to the deadlock.
But then again the test would have silently ignore this error as well
and the bugs wouldn't have been noticed.
Add the deadlock detector id to the thread registry mutex.

Also extend the test to check more cases and detect more bugs.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D116091
2021-12-21 16:54:00 +01:00
Dmitry Vyukov d4d86fede8 tsan: always handle closing of file descriptors
If we miss both close of a file descriptor and a subsequent open
if the same file descriptor number, we report false positives
between operations on the old and on the new descriptors.

There are lots of ways to create new file descriptors, but for closing
there is mostly close call. So we try to handle at least it.
However, if the close happens in an ignored library, we miss it
and start reporting false positives.

Handle closing of file descriptors always, even in ignored libraries
(as we do for malloc/free and other critical functions).
But don't imitate memory accesses on close for ignored libraries.

FdClose checks validity of the fd (fd >= 0) itself,
so remove the excessive checks in the callers.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D116095
2021-12-21 13:35:34 +01:00
Dmitry Vyukov 52a4a4a53c tsan: remove unused ReportMutex::destroyed
Depends on D113980.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113981
2021-12-21 11:37:01 +01:00
Dmitry Vyukov 69807fe161 tsan: change ReportMutex::id type to int
We used to use u64 as mutex id because it was some
tricky identifier built from address and reuse count.
Now it's just the mutex index in the report (0, 1, 2...),
so use int to represent it.

Depends on D112603.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113980
2021-12-21 11:36:49 +01:00
Dmitry Vyukov abb825725e tsan: optimize __tsan_read/write16
These callbacks are used for SSE vector accesses.
In some computational programs these accesses dominate.
Currently we do 2 uninlined 8-byte accesses to handle them.
Inline and optimize them similarly to unaligned accesses.
This reduces the vector access benchmark time from 8 to 3 seconds.

Depends on D112603.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D114594
2021-12-21 11:33:28 +01:00
Vitaly Buka 8f85d5205d [tsan] Disable test from D115759 on Darwin 2021-12-20 19:41:09 -08:00
Xu Mingjie 95acd9241c [memprof][NFC] Fix mismatched-new-delete in memprof tests
Fix mismatched-new-delete in memprof test_new_load_store.cpp and test_terse.cpp

Reviewed By: snehasish

Differential Revision: https://reviews.llvm.org/D116024
2021-12-20 18:43:21 -08:00
Clemens Wasser 9b4f179bf8 Port __sanitizer::StopTheWorld to Windows
This also makes the sanitizer_stoptheworld_test cross-platform by using the STL, rather than pthread.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115204
2021-12-20 18:29:44 -08:00
Vitaly Buka 80c95bbdf3 [sanitizer] Fix compress_stack_depot.cpp test on Darwin
All platforms which can start the thread should stop it as well.
2021-12-20 18:15:23 -08:00
Philip Reames 9b955f77a1 Attempt to stablize compiler-rt/test/asan/TestCases/strncpy-overflow.cpp
This attempts to adjust the test to still exercise the expected codepath after D115904.  This test is fundementally rather fragile.

Unfortunately, I have not been able to confirm this workaround either does, or does not, work.  Attempting check-all with compiler-rt blows through an additional 30GB of disk space so my build config which exceeds my local disk space.
2021-12-20 17:51:11 -08:00
Vitaly Buka 700d16b6d6 [tsan] Fix Darwin crash after D115759
Remove global constructor which may or may not be needed for Android,
at it breaks Darwin now.
2021-12-20 17:05:41 -08:00
Dmitry Vyukov 4c5476b066 tsan: fix NULL deref in TraceSwitchPart
There is a small chance that the slot may be not queued in TraceSwitchPart.
This can happen if the slot has kEpochLast epoch and another thread
in FindSlotAndLock discovered that it's exhausted and removed it from
the slot queue. kEpochLast can happen in 2 cases: (1) if TraceSwitchPart
was called with the slot locked and epoch already at kEpochLast,
or (2) if we've acquired a new slot in SlotLock in the beginning
of the function and the slot was at kEpochLast - 1, so after increment
in SlotAttachAndLock it become kEpochLast.

If this happens we crash on ctx->slot_queue.Remove(thr->slot).
Skip the requeueing if the slot is not queued.
The slot is exhausted, so it must not be ctx->slot_queue.

The existing stress test triggers this with very small probability.
I am not sure how to make this condition more likely to be triggered,
it evaded lots of testing.

Depends on D116040.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D116041
2021-12-20 18:55:51 +01:00
Dmitry Vyukov 2eb3e20461 tsan: fix deadlock during race reporting
SlotPairLocker calls SlotLock under ctx->multi_slot_mtx.
SlotLock can invoke global reset DoReset if we are out of slots/epochs.
But DoReset locks ctx->multi_slot_mtx as well, which leads to deadlock.

Resolve the deadlock by removing SlotPairLocker/multi_slot_mtx
and only lock one slot for which we will do RestoreStack.
We need to lock that slot because RestoreStack accesses the slot journal.
But it's unclear why we need to lock the current slot.
Initially I did it just to be on the safer side (but at that time
we dit not lock the second slot, so it was easy just to lock the current slot).

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D116040
2021-12-20 18:52:48 +01:00
Ellis Hoag ac719d7c9a [InstrProf] Don't profile merge by default in lightweight mode
Profile merging is not supported when using debug info profile
correlation because the data section won't be in the binary at runtime.
Change the default profile name in this mode to `default_%p.proflite` so
we don't use profile merging.

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D115979
2021-12-20 09:51:49 -08:00
Julian Lettner 64f4041725 [TSan][Darwin] Fix shadow mapping for iOS simulator on Apple Silicon
With the introduction of Apple Silicon `defined(__aarch64__)` is not a
reliable way to check for the platform anymore.

We want to use the "normal" `Mapping48AddressSpace` mapping everywhere
except devices, including the iOS simulators on AS.

Relevant revisions:
https://reviews.llvm.org/D35147
https://reviews.llvm.org/D86377
https://reviews.llvm.org/D107743
https://reviews.llvm.org/D107888

Differential Revision: https://reviews.llvm.org/D115843
2021-12-17 15:59:43 -08:00
Julian Lettner 4399f3b6b0 [TSan][Darwin] Make malloc_size interceptor more robust
Previously we would crash in the TSan runtime if the user program passes
a pointer to `malloc_size()` that doesn't point into app memory.

In these cases, `malloc_size()` should return 0.

For ASan, we fixed a similar issue here:
https://reviews.llvm.org/D15008

Radar-Id: rdar://problem/86213149

Differential Revision: https://reviews.llvm.org/D115947
2021-12-17 15:38:08 -08:00
Ellis Hoag 3429c7c328 [InstrProf][NFC] Require zlib for debug info tests
There was a build failure on the `instrprof-debug-info-correlate.c` test
because zlib was missing so we need to require it to run the test.

Differential Revision: https://reviews.llvm.org/D115970
2021-12-17 14:06:05 -08:00
Ellis Hoag 65d7fd0239 [Try2][InstrProf] Add Correlator class to read debug info
Extend `llvm-profdata` to read in a `.proflite` file and also a debug info file to generate a normal `.profdata` profile. This reduces the binary size by 8.4% when building an instrumented Clang binary without value profiling (164 MB vs 179 MB).

This work is part of the "lightweight instrumentation" RFC: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

This was first landed in https://reviews.llvm.org/D114566 but had to be reverted due to build errors.

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D115915
2021-12-17 10:45:59 -08:00
Martin Storsjö cc324af0d6 Revert "Port __sanitizer::StopTheWorld to Windows"
This reverts commit 3f5f687e2e.

That commit broke building for mingw, where the sanitizers are
built with -nostdinc++, while the added source file includes
the C++ standard library's <algorithm>.

Additionally, the new code fails to build for i386, as it
unconditionally uses the CONTEXT member Rsp.
2021-12-17 20:41:14 +02:00
Nico Weber 5dd8ff7380 [asan/mac] Fix remaining -Wformat warnings
AARCH64_GET_REG() is used to initialize uptrs, and after D79132
the ptrauth branch of its implementation explicitly casts to uptr.

The non-ptrauth branch returns ucontext->uc_mcontext->__ss.__fp (etc),
which has either type void* or __uint64_t (ref usr/include/mach/arm/_structs.h)
where __uint64_t is a unsigned long long (ref usr/include/arm/_types.h).
uptr is an unsigned long (ref
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h). So explicitly
cast to uptr in this branch as well, so that AARCH64_GET_REG() has a
well-defined type.

Then change DUMPREGA64() tu use %lx instead of %llx since that's the right type
for uptr. (Most other places in compiler-rt print uptrs as %p and cast the arg
to (void*), but there are explicit 0x%016 format strings in the surroundings,
so be locally consistent with that.)

No behavior change, in the end it's just 64-bit unsigneds by slightly different
names.
2021-12-17 09:44:09 -05:00
Nico Weber 44f0e14537 [asan/mac] Fix a few -Wformat warnings
All other places cast uptrs to (void*) when printing it via
%p after D113099, so do that here too.
2021-12-17 09:17:52 -05:00
Nico Weber d412f35395 [asan/mac] Fix a -Wformat warning
internal_getpid() is manually cast to int in all other places that
pass its result to a printf string, so do that here too for now.
2021-12-17 09:17:52 -05:00
Clemens Wasser 3f5f687e2e Port __sanitizer::StopTheWorld to Windows
This also makes the sanitizer_stoptheworld_test cross-platform by using the STL, rather than pthread.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115204
2021-12-16 23:29:15 -08:00
Vitaly Buka 5ed03c1e10 [sanitizer] Simplify sanitizer_stoptheworld_test 2021-12-16 23:24:17 -08:00
Ellis Hoag bdc68ee70f Revert "[InstrProf] Add Correlator class to read debug info"
Also reverts an attempt to fix the build errors https://reviews.llvm.org/D115911

The original diff https://reviews.llvm.org/D114566 causes some build
errors that I need to investigate.

https://lab.llvm.org/buildbot/#/builders/118/builds/7037

This reverts commit 95946d2f85.

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D115913
2021-12-16 16:28:19 -08:00
Vitaly Buka b4618f576e [NFC][sanitizer] Remove unused variable 2021-12-16 15:24:45 -08:00
Ellis Hoag 95946d2f85 [InstrProf] Add Correlator class to read debug info
Extend `llvm-profdata` to read in a `.proflite` file and also a debug info file to generate a normal `.profdata` profile. This reduces the binary size by 8.4% when building an instrumented Clang binary without value profiling (164 MB vs 179 MB).

This work is part of the "lightweight instrumentation" RFC: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D114566
2021-12-16 15:18:12 -08:00
Ellis Hoag 58d9c1aec8 [Try2][InstrProf] Attach debug info to counters
Add the llvm flag `-debug-info-correlate` to attach debug info to instrumentation counters so we can correlate raw profile data to their functions. Raw profiles are dumped as `.proflite` files. The next diff enables `llvm-profdata` to consume `.proflite` and debug info files to produce a normal `.profdata` profile.

Part of the "lightweight instrumentation" work: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

The original diff https://reviews.llvm.org/D114565 was reverted because of the `Instrumentation/InstrProfiling/debug-info-correlate.ll` test, which is fixed in this commit.

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D115693
2021-12-16 14:20:30 -08:00
Vitaly Buka bc9688f4e4 [sanitizer] Define SANITIZER_ARM SANITIZER_X64 SANITIZER_ARM64 2021-12-16 13:26:33 -08:00
Vitaly Buka 72847ec8bf [sanitizer] Clang-format sanitizer_platform.h 2021-12-16 13:26:33 -08:00
Emily Shi fcfcc64ce9 [compiler-rt][NFC] add note to interface_symbols_linux.cpp about darwin
There were changes made to the linux version of this test that were not made for darwin
(see https://reviews.llvm.org/D115837) and this caused downstream failures.

Adding comment to this test to remind people to edit interface_symbols_darwin.cpp.
There is the reverse of this comment in the darwin file to remind us to edit the linux version already.

Differential Revision: https://reviews.llvm.org/D115899
2021-12-16 13:08:03 -08:00
Emily Shi db38527966 [compiler-rt] removed memory access callback from asan interface for darwin
These symbols were introduced in https://reviews.llvm.org/D114558 but were not properly guarded for mac which caused downstream CI failures

Reviewed By: kubamracek, yln

Differential Revision: https://reviews.llvm.org/D115837
2021-12-16 13:03:47 -08:00
Clemens Wasser 9991ab5df9 [sanitizer] Portable sanitizer_stoptheworld_test
Part of D115204
2021-12-16 12:53:53 -08:00
Vitaly Buka 9cf0ea3558 [sanitizer] Clang format before D115204 2021-12-16 12:52:36 -08:00
Julian Lettner dcf11af24b [Sanitizer] Disable LSan when testing on iOS simulators
LSan (`ASAN_OPTIONS=detect_leaks=1`) is supported on macOS, but disabled
by default on Darwin (`SANITIZER_MAC`):
```
COMMON_FLAG(bool, detect_leaks, !SANITIZER_MAC, "Enable memory leak detection.")
```

We enable it here for ASan tests to prevent regressions (per comment).
However, LSan is not supported for the iOS simulator and the tests fail
when it is enabled.

Make this "Is macOS?" check more precise since the current one (`Darwin
&& x86_64`) has two issues:
 * Includes the simulators
 * Excludes macOS on Apple Silicon

This will allow us to (re)enable simulator testing on Green dragon to
give open source better feedback about sanitizer changes:
https://green.lab.llvm.org

rdar://86529234

Differential Revision: https://reviews.llvm.org/D115816
2021-12-16 12:37:45 -08:00
Clemens Wasser 66d1fdb29b [lsan] Format CAN_SANITIZE_LEAKS defines
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115584
2021-12-16 11:55:16 -08:00
Matt Kulukundis 406b538dea Add a flag to force tsan's background thread
Reviewed By: dvyukov, vitalybuka

Differential Revision: https://reviews.llvm.org/D115759
2021-12-16 11:47:33 -08:00
Julian Lettner 3a1eb1cf2a [TSan] Make test fail more predictably
This test would hang when the system ran out of resources and we fail to
create all 300 threads.

Differential Revision: https://reviews.llvm.org/D115845
2021-12-16 08:33:32 -08:00
Vitaly Buka c209b7e3d5 [sanitizer] Update global_symbols.txt 2021-12-16 00:15:20 -08:00
Julian Lettner 8f1ea2e85c [TSan][Darwin] Fix CheckAndProtect() for MappingAppleAarch64
In the new TSan runtime refactoring this line was changed:
```
ProtectRange(MetaShadowEnd(), TraceMemBeg());
-->
ProtectRange(MetaShadowEnd(), HeapMemBeg());
```

But for `MappingAppleAarch64` the app heap comes before the shadow,
resulting in:
```
CHECK failed: tsan_platform_posix.cpp:83 "((beg)) <= ((end))" (0xe00000000, 0x200000000)
```

rdar://86521924

Differential Revision: https://reviews.llvm.org/D115834
2021-12-15 18:03:58 -08:00
Julian Lettner a7cbe198ce [Darwin] Remove workaround for symbolication in iOS simulator runtimes
A while ago we added some code to the sanitizer runtimes for iOS
simulators to allow `atos` (external process) to inspect the sanitized
process during report generation to enable symbolication.  This was done
by setting the `__check_mach_ports_lookup` env var early during process
startup which came with a couple of complications.

This workaround is not required anymore and removing it fixes TSan in
the iOS simulator after the new TSan runtime landed.
(https://reviews.llvm.org/D112603)

Relevant/reverted revisions:
https://reviews.llvm.org/D78178
https://reviews.llvm.org/D78179
https://reviews.llvm.org/D78525

rdar://86472733

Differential Revision: https://reviews.llvm.org/D115767
2021-12-15 17:22:13 -08:00
Stephen Hines cce4a7258b [compiler-rt][AArch64] Add a workaround for Exynos 9810
Big.LITTLE Heterogeneous architectures, as described by ARM [1],
require that the instruction set architecture of the big and little
cores be compatible. However, the Samsung Exynos 9810 is known to
have different ISAs in its core.
According to [2], some cores are ARMv8.2 and others are ARMv8.0.

Since LSE is for ARMv8.1 and later, it should be disabled
for this broken CPU.

[1] https://developer.arm.com/documentation/den0024/a/big-LITTLE-Technology
[2] https://github.com/golang/go/issues/28431

Patch by: Byoungchan Lee (byoungchan.lee@gmx.com)
Reviewed By: srhines

Differential Revision: https://reviews.llvm.org/D114523
2021-12-14 19:51:46 -08:00
Lang Hames 5255ca9726 [llvm-jitlink] Update handling of library options.
Adds -L<search-path> and -l<library> options that are analogous to ld's
versions.

Each instance of -L<search-path> or -l<library> will apply to the most recent
-jd option on the command line (-jd <name> creates a JITDylib with the given
name). Library names will match against JITDylibs first, then llvm-jitlink will
look through the search paths for files named <search-path>/lib<library>.dylib
or <search-path>/lib<library>.a.

The default "main" JITDylib will link against all JITDylibs created by -jd
options, and all JITDylibs will link against the process symbols (unless
-no-process-symbols is specified).

The -dlopen option is renamed -preload, and will load dylibs into the JITDylib
for the ORC runtime only.

The effect of these changes is to make it easier to describe a non-trivial
program layout to llvm-jitlink for testing purposes. E.g. the following
invocation describes a program consisting of three JITDylibs: "main" (created
implicitly) containing main.o, "Foo" containing foo1.o and foo2.o, and linking
against library "bar" (not a JITDylib, so it must be a .dylib or .a on disk)
and "Baz" (which is a JITDylib), and "Baz" containing baz.o.

llvm-jitlink \
  main.o \
  -jd Foo foo1.o foo2.o -L${HOME}/lib -lbar -lBaz
  -jd Baz baz.o
2021-12-15 13:49:30 +11:00
Kirill Stoimenov da7e9e3410 [ASan] Added NO_EXEC_STACK_DIRECTIVE to assembly callback file.
This is present in our assembly files. It should fix decorate_proc_maps.cpp failures because of shadow memory being allocated as executable.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115552
2021-12-14 18:34:17 -08:00
Kirill Stoimenov c13524856b [ASan] Shared optimized callbacks implementation.
This change moves optimized callbacks from each .o file to compiler-rt. Instead of using code generation it uses direct assembly implementation. Please note that the 'or' version is not implemented and it will produce unresolved external if somehow 'or' version is requested.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114558
2021-12-14 15:55:14 +00:00
Ellis Hoag c809da7d9c Revert "[InstrProf] Attach debug info to counters"
This reverts commit 800bf8ed29.

The `Instrumentation/InstrProfiling/debug-info-correlate.ll` test was
failing because I forgot the `llc` commands are architecture specific.
I'll follow up with a fix.

Differential Revision: https://reviews.llvm.org/D115689
2021-12-13 18:15:17 -08:00
Ellis Hoag 800bf8ed29 [InstrProf] Attach debug info to counters
Add the llvm flag `-debug-info-correlate` to attach debug info to instrumentation counters so we can correlate raw profile data to their functions. Raw profiles are dumped as `.proflite` files. The next diff enables `llvm-profdata` to consume `.proflite` and debug info files to produce a normal `.profdata` profile.

Part of the "lightweight instrumentation" work: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

Reviewed By: kyulee

Differential Revision: https://reviews.llvm.org/D114565
2021-12-13 17:51:22 -08:00
Arthur Eubanks fff876c20e Revert "[ASan] Shared optimized callbacks implementation."
This reverts commit ebc31d2e72.

Causes test failures on Windows, see comments on D114558.
2021-12-13 15:26:55 -08:00
Arthur Eubanks a357fad868 Revert "[ASan] Added NO_EXEC_STACK_DIRECTIVE to assembly callback file."
This reverts commit e31a5e0ba5.

Reverting dependent change D114558.
2021-12-13 15:26:55 -08:00
Noah Shutty 34491ca729 [Symbolizer][Debuginfo] Add debuginfod client to llvm-symbolizer.
Adds a fallback to use the debuginfod client library (386655) in `findDebugBinary`.
Fixed a cast of Erorr::success() to Expected<> in debuginfod library.
Added Debuginfod to Symbolize deps in gn.
Updates compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh to include Debuginfod library to fix sanitizer-x86_64-linux breakage.

Reviewed By: jhenderson, vitalybuka

Differential Revision: https://reviews.llvm.org/D113717
2021-12-13 23:00:32 +00:00
Vitaly Buka 75504789bd [NFC][asan] XFAIL a test on THUMB
Followup to D114934
2021-12-13 12:07:13 -08:00
Petr Hosek a65389849d Revert "[CMake] Update internal libc++ configuration"
This reverts commit e286fefa8c since
the issue affecting the sanitizer-ppc64le-linux builder is resolved.
2021-12-13 11:14:00 -08:00
Petr Hosek e286fefa8c [CMake] Update internal libc++ configuration
This is an attempt to address 458ead66dc
by better matching the previous configuration.
2021-12-13 11:07:53 -08:00
Dmitry Vyukov 9fb8058a80 tsan: enable the new runtime
This enables the new runtime (D112603) by default.

Depends on D112603.

Differential Revision: https://reviews.llvm.org/D115624
2021-12-13 12:50:13 +01:00
Dmitry Vyukov b332134921 tsan: new runtime (v3)
This change switches tsan to the new runtime which features:
 - 2x smaller shadow memory (2x of app memory)
 - faster fully vectorized race detection
 - small fixed-size vector clocks (512b)
 - fast vectorized vector clock operations
 - unlimited number of alive threads/goroutimes

Depends on D112602.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112603
2021-12-13 12:48:34 +01:00
Dmitry Vyukov b088833375 tsan: deflake dlopen_static_tls.cpp
Currently the test calls dlclose in the thread
concurrently with the main thread calling a function
from the dynamic library. This is not good.
Wait for the main thread to call the function
before calling dlclose.

Depends on D115612.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D115613
2021-12-13 12:01:40 +01:00
Dmitry Vyukov 7de546e9e8 tsan: deflake flush_memory.cpp
The test contains a race and checks that it's detected.
But the race may not be detected since we are doing aggressive flushes
and if the state flush happens between racing accesses, tsan won't
detect the race). So return 1 to make the test deterministic
regardless of the race.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D115612
2021-12-13 12:01:30 +01:00
Florian Mayer edd2b99a57 [sanitizers] include build ids in stacks on linux.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D114294
2021-12-10 14:24:03 -08:00
Kirill Stoimenov e31a5e0ba5 [ASan] Added NO_EXEC_STACK_DIRECTIVE to assembly callback file.
This is present in our assembly files. It should fix decorate_proc_maps.cpp failures because of shadow memory being allocated as executable.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115552
2021-12-10 21:53:13 +00:00
Florian Mayer 06430acc00 Revert "[sanitizers] include build ids in stacks on linux."
This reverts commit 2a31b240df.
2021-12-10 11:52:26 -08:00
Florian Mayer 2a31b240df [sanitizers] include build ids in stacks on linux.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D114294
2021-12-10 11:30:34 -08:00
Kirill Stoimenov ebc31d2e72 [ASan] Shared optimized callbacks implementation.
This change moves optimized callbacks from each .o file to compiler-rt. Instead of using code generation it uses direct assembly implementation. Please note that the 'or' version is not implemented and it will produce unresolved external if somehow 'or' version is requested.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114558
2021-12-10 15:34:05 +00:00
Nico Weber 30f221bba0 Revert "[Symbolizer][Debuginfo] Add debuginfod client to llvm-symbolizer."
This reverts commit 5bba0fe12b.
Makes lld depend on libcurl, see comments on https://reviews.llvm.org/D113717
2021-12-10 10:33:05 -05:00
Brian Cain 1e68c79987 Reapply [xray] add support for hexagon
Adds x-ray support for hexagon to llvm codegen, clang driver,
compiler-rt libs.

Differential Revision: https://reviews.llvm.org/D113638

Reapplying this after 543a9ad7c4,
which fixes the leak introduced there.
2021-12-10 05:32:28 -08:00
Vitaly Buka 2ff795a462 [sanitizer] Update symbols after D113717 2021-12-09 21:50:52 -08:00
Kirill Stoimenov ab396165fe Revert "[ASan] Shared optimized callbacks implementation."
This reverts commit 428ed61a92.

Build bot failure:
https://lab.llvm.org/buildbot/#/builders/37
https://lab.llvm.org/buildbot/#/builders/37/builds/9041

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115489
2021-12-10 02:13:34 +00:00
Noah Shutty 5bba0fe12b [Symbolizer][Debuginfo] Add debuginfod client to llvm-symbolizer.
Adds a fallback to use the debuginfod client library (386655) in `findDebugBinary`.
Fixed a cast of Erorr::success() to Expected<> in debuginfod library.
Added Debuginfod to Symbolize deps in gn.
Updates compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh to include Debuginfod library to fix sanitizer-x86_64-linux breakage.

Reviewed By: jhenderson, vitalybuka

Differential Revision: https://reviews.llvm.org/D113717
2021-12-10 01:32:36 +00:00
Noah Shutty afa3c14e2f Revert "[Symbolizer][Debuginfo] Add debuginfod client to llvm-symbolizer."
This reverts commit e2ad4f1756 because it
does not correctly fix the sanitizer buildbot breakage.
2021-12-10 00:59:13 +00:00
Noah Shutty e2ad4f1756 [Symbolizer][Debuginfo] Add debuginfod client to llvm-symbolizer.
Adds a fallback to use the debuginfod client library (386655) in `findDebugBinary`.
Fixed a cast of Erorr::success() to Expected<> in debuginfod library.
Added Debuginfod to Symbolize deps in gn.
Adds new symbolizer symbols to `global_symbols.txt`.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D113717
2021-12-10 00:23:00 +00:00
Kirill Stoimenov 76d3d07845 [ASan] Fixed Windows test by excluding macro instantiated INTERFACE_FUNCTION.
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115478
2021-12-10 00:04:37 +00:00
Kirill Stoimenov d3ca749288 [ASan] Fix Windows build by excluding a test which requires assembly callback versions.
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115475
2021-12-09 23:40:40 +00:00
Kirill Stoimenov 2f625ae9e4 [ASan] Fix Windows build by excluding asan_rtl_x86_64.S.
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115473
2021-12-09 23:25:27 +00:00
Kirill Stoimenov 428ed61a92 [ASan] Shared optimized callbacks implementation.
This change moves optimized callbacks from each .o file to compiler-rt. Instead of using code generation it uses direct assembly implementation. Please note that the 'or' version is not implemented and it will produce unresolved external if somehow 'or' version is requested.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114558
2021-12-09 23:04:56 +00:00
Matt Morehouse 2d6dfce4aa [libFuzzer] Remove entropic-scale-per-exec-time.test.
The test has been flaky for years, and I think we should remove it to
eliminate noise on the buildbot.

Neither me nor dokyungs have been able to fully deflake the test, and it
tests a non-default Entropic flag.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115453
2021-12-09 12:20:06 -08:00
Vitaly Buka f86deb18ca [lsan] Move out suppression of invalid PCs from StopTheWorld
This removes the last use of StackDepot from StopTheWorld.

Depends on D115284.

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D115319
2021-12-09 12:17:35 -08:00
Vitaly Buka 3c6c30677e [NFC][sanitizer] Relax InternalLowerBound interface
val can be of any type accepted by Compare.
2021-12-09 12:11:24 -08:00
Vitaly Buka f72e50946c [lsan] Reduce StopTheWorld access to StackDepot
StackDepot locks some stuff. As is there is small probability to
deadlock if we stop thread which locked the Depot.

We need either Lock/Unlock StackDepot for StopTheWorld, or don't
interact with StackDepot from there.

This patch does not run LeakReport under StopTheWorld. LeakReport
contains most of StackDepot access.

As a bonus this patch will help to resolve kMaxLeaksConsidered FIXME.

Depends on D114498.

Reviewed By: morehouse, kstoimenov

Differential Revision: https://reviews.llvm.org/D115284
2021-12-09 11:43:30 -08:00
Vitaly Buka a9a1499080 [NFC][lsan] Change LeakSuppressionContext interface
Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D115318
2021-12-09 11:38:02 -08:00
Vitaly Buka d71775cd2a [asan] Run background thread for asan only on THUMB
As in D114934, or lsan crashes on the same bot.
2021-12-09 10:43:06 -08:00
Vitaly Buka fa24c4a1c0 [sanitizer] Run Stack compression in background thread
Depends on D114495.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D114498
2021-12-09 10:29:50 -08:00
Petr Hosek a1e7f62801 Revert "[sanitizer] Run Stack compression in background thread"
This reverts commit e5c2a46c5e as this
change introduced a linker error when building sanitizer runtimes:

  ld.lld: error: undefined symbol: __sanitizer::internal_start_thread(void* (*)(void*), void*)
  >>> referenced by sanitizer_stackdepot.cpp:133 (compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp:133)
  >>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stackdepot.cpp.obj:(__sanitizer::(anonymous namespace)::CompressThread::NewWorkNotify())
2021-12-09 09:56:48 -08:00
Jonas Devlieghere 396113c19f Revert "tsan: new runtime (v3)"
This reverts commit 5a33e41281 becuase it
breaks LLDB.

https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/39208/
2021-12-09 09:18:10 -08:00
Brian Cain ab28cb1c5c Revert "[xray] add support for hexagon"
This reverts commit 543a9ad7c4.
2021-12-09 07:30:40 -08:00
Brian Cain 543a9ad7c4 [xray] add support for hexagon
Adds x-ray support for hexagon to llvm codegen, clang driver,
compiler-rt libs.

Differential Revision: https://reviews.llvm.org/D113638
2021-12-09 05:47:53 -08:00
Dmitry Vyukov 5a33e41281 tsan: new runtime (v3)
This change switches tsan to the new runtime which features:
 - 2x smaller shadow memory (2x of app memory)
 - faster fully vectorized race detection
 - small fixed-size vector clocks (512b)
 - fast vectorized vector clock operations
 - unlimited number of alive threads/goroutimes

Depends on D112602.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112603
2021-12-09 09:09:52 +01:00
Dmitry Vyukov 8e93d4c996 tsan: fork runtime
Fork the current version of tsan runtime before commiting
rewrite of the runtime (D112603). The old runtime can be
enabled with TSAN_USE_OLD_RUNTIME option.
This is a temporal measure for emergencies and is required
for Chromium rollout (for context see http://crbug.com/1275581).
The old runtime is supposed to be deleted soon.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D115223
2021-12-09 07:28:26 +01:00
Andrew Browne 02997febe6 Revert "[asan] Run background thread for asan only on THUMB"
This reverts commit 5c27740238.

Reverting due to Windows build issue:

sanitizer_stackdepot.cpp.obj : error LNK2005: "void __cdecl __sanitizer::StackDepotStopBackgroundThread(void)" (?StackDepotStopBackgroundThread@__sanitizer@@YAXXZ) already defined in sanitizer_common_libcdep.cpp.obj
LINK : fatal error LNK1181: cannot open input file 'projects\compiler-rt\lib\asan\CMakeFiles\RTAsan_dynamic.x86_64.dir\asan_rtl_x86_64.S.obj'
2021-12-08 16:41:36 -08:00
Kirill Stoimenov f75cce0be8 Revert "[ASan] Shared optimized callbacks implementation."
This reverts commit f71c553a30.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115407
2021-12-09 00:18:29 +00:00
Kirill Stoimenov f71c553a30 [ASan] Shared optimized callbacks implementation.
This change moves optimized callbacks from each .o file to compiler-rt. Instead of using code generation it uses direct assembly implementation. Please note that the 'or' version is not implemented and it will produce unresolved external if somehow 'or' version is requested.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114558
2021-12-09 00:00:08 +00:00
Kirill Stoimenov 00616123f8 [ASan] Added __cplusplus guard around the C++ code so it is safe to include asan_mapping.h in assembly files.
This will avoid addind asan_shadow_defines.h in D114558.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115348
2021-12-08 21:02:40 +00:00
Vitaly Buka e5c2a46c5e [sanitizer] Run Stack compression in background thread
Depends on D114495.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D114498
2021-12-08 13:00:09 -08:00
Petr Hosek 458ead66dc [compiler-rt] Use the runtimes build for custom libc++
Some of the compiler-rt runtimes use custom instrumented libc++ build.
Use the runtimes build for building this custom libc++.

Differential Revision: https://reviews.llvm.org/D114922
2021-12-08 12:52:48 -08:00
Vitaly Buka 5c27740238 [asan] Run background thread for asan only on THUMB
As in D114934, or lsan crashes on the same bot.
2021-12-08 12:43:56 -08:00
Vitaly Buka 9b9ee34d0e [NFC][sanitizer] Move/rename macro into sanitizer_platform.h
Folloup for D114934
2021-12-08 12:43:56 -08:00
Vitaly Buka 8de23903e3 [compiler-rt] Disabled tests and benchmarks for libc++
We don't run tests or benchmarks from this build anyway.
Benchmarks in custom libc++ break my local build.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D115375
2021-12-08 12:43:55 -08:00
Kirill Stoimenov 277f86d610 [ASan] Ran clang-format on asan_mapping.h.
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115371
2021-12-08 20:15:32 +00:00
Petr Hosek 824ddeb994 Revert "[compiler-rt] Use the runtimes build for custom libc++"
This reverts commit bda3f2dd76 since
it broke MSan tests.
2021-12-08 09:14:26 -08:00
Petr Hosek 40028eaf70 [CMake] Specify byproducts for custom libcxx builds
These were removed in bda3f2dd76 but
are needed as it turned out for the MSan tests.
2021-12-07 23:14:58 -08:00
Vitaly Buka b1c369e01f [lsan] Replace atomic_store/atomic_load with atomic_fetch_add 2021-12-07 22:39:12 -08:00
Vitaly Buka 9601085bc5 [NFC][asan] Remove -std=c++20 from test
Fails after D110215
with errors like
/usr/include/x86_64-linux-gnu/sys/types.h:33:9: error: unknown type name '__u_char'
typedef __u_char u_char;
2021-12-07 22:36:54 -08:00
Vitaly Buka dd1abb1102 [NFC][lsan] Move method implementation up 2021-12-07 21:45:26 -08:00
Vitaly Buka b79ea567cf [NFC][lsan] Clang-format lsan_common.cpp 2021-12-07 21:45:26 -08:00
Vitaly Buka 8ed4d2819d [NFC][lsan] Use kIgnored in MarkInvalidPCCb
kIgnored didn't exist when the code was added, but it should be
equivalent to kReachable.
The goal is to refactor MarkInvalidPCCb to avoid StackDepotGet
in StopTheWorld.
2021-12-07 19:53:08 -08:00
Vitaly Buka 5ff52be5d9 [sanitizer] Restore __thumb__ workaround
It was removed in D114934 and failed clang-thumbv7-full-2stage.
2021-12-07 18:04:06 -08:00
Kirill Stoimenov 572d1ecccc [ASan] Missed some SHADOW_XYZ uses on non-Linux platforms.
Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115307
2021-12-08 00:39:26 +00:00
Kirill Stoimenov ad56941a57 [ASan] Renamed SHADOW_XYZ to ASAN_SHADOW_XYZ.
Follow up from D115271.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115293
2021-12-08 00:22:56 +00:00
Petr Hosek bda3f2dd76 [compiler-rt] Use the runtimes build for custom libc++
Some of the compiler-rt runtimes use custom instrumented libc++ build.
Use the runtimes build for building this custom libc++.

Differential Revision: https://reviews.llvm.org/D114922
2021-12-07 16:08:16 -08:00
Kirill Stoimenov 8421fa5d53 [ASan] Removed ASAN_SHADOW_SCALE.
This is additional cleanup as follow-up of D104279.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115271
2021-12-07 22:55:48 +00:00
Kirill Stoimenov 36529a28c7 Revert "[ASan] Removed ASAN_SHADOW_SCALE."
This reverts commit e4800fc099.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115286
2021-12-07 22:19:50 +00:00
Kirill Stoimenov e4800fc099 [ASan] Removed ASAN_SHADOW_SCALE.
This is additional cleanup as follow-up of D104279.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115271
2021-12-07 22:11:40 +00:00
Kirill Stoimenov 84dbfe1642 [ASan] Replaced constants for SHADOW_OFFSET with defines.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115214
2021-12-07 19:34:17 +00:00
Vitaly Buka 81f9dc8eee [sanitizer] Lock/Unlock stack store on fork
Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D115210
2021-12-07 11:17:16 -08:00
Clemens Wasser d9aa5f6158 Format lsan.h
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115262
2021-12-07 10:52:35 -08:00
Clemens Wasser 33e3554ea3 Change __lsan::kMaxAllowedMallocSize literal types to unsigned long long
It is required for the [Leak Sanitizer port to Windows](https://reviews.llvm.org/D115103).
The currently used `unsigned long` type is 64 bits wide on UNIX like systems but only 32 bits wide on Windows.
Because of that, the literal `8UL << 30` causes an integer overflow on Windows.
By changing the type of the literals to `unsigned long long`, we have consistent behavior and no overflows on all Platforms.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115186
2021-12-07 10:38:13 -08:00
Kirill Stoimenov 591eb2bdb6 [ASan] Refactored SHADOW_OFFSET implementation to use SHADOW_OFFSET_CONST.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115213
2021-12-07 17:53:38 +00:00
David Spickett 6bfbb89e96 [compiler-rt][libFuzzer] Disable counters test on arm
This test is either very slow or loops forever on 32 bit Arm.

One of a few tests causing timeouts on our buildbots:
https://lab.llvm.org/buildbot/#/builders/190/builds/513
2021-12-07 11:55:11 +00:00
Vitaly Buka fc3a260a0f [sanitizer] Don't lock for StackStore::Allocated() 2021-12-07 01:00:01 -08:00
Vitaly Buka 7151c71481 [sanitizer] Fix CompressStackStore VPrint message 2021-12-07 01:00:01 -08:00
Vitaly Buka faf694b662 [NFC][sanitizer] Non-copyable ScopedBlockSignals 2021-12-06 22:37:28 -08:00
Vitaly Buka 061f22dda9 [NFC][lsan] Refactor LockThreadRegistry/LockAllocator calls 2021-12-06 22:27:11 -08:00
Vitaly Buka aa407c102d [NFC][sanitizer] Fix typo in comment 2021-12-06 22:27:11 -08:00
Nico Weber 63d518f31a [tsan] Move tsan/rtl build rules into tsan/rtl/CMakeLists.txt
That way, the build rules are closer to the source files they describe.

No intended behavior change.

Differential Revision: https://reviews.llvm.org/D115155
2021-12-06 19:58:30 -05:00
Kirill Stoimenov f4606d2b70 Revert "[ASan] Added asan_shadow_defines.h, which contatins shadow offset for various platforms."
This reverts commit 2f3bb59f51.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D115193
2021-12-06 23:13:31 +00:00
Kirill Stoimenov 2f3bb59f51 [ASan] Added asan_shadow_defines.h, which contatins shadow offset for various platforms.
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D115075
2021-12-06 21:45:46 +00:00
Dmitry Vyukov 954582cdfc tsan: disable dlopen_static_tls.cpp test on powerpc64
Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D115142
2021-12-06 13:13:43 +01:00
Dimitry Andric bbba9d8c1b [XRay] fix more -Wformat warnings
Building xray with recent clang on a 64-bit system results in a number
of -Wformat warnings:

    compiler-rt/lib/xray/xray_allocator.h:70:11: warning: format specifies type 'int' but the argument has type '__sanitizer::uptr' (aka 'unsigned long') [-Wformat]
              RoundedSize, B);
              ^~~~~~~~~~~
    compiler-rt/lib/xray/xray_allocator.h:119:11: warning: format specifies type 'int' but the argument has type '__sanitizer::uptr' (aka 'unsigned long') [-Wformat]
              RoundedSize, B);
              ^~~~~~~~~~~

Since `__sanitizer::uptr` has the same size as `size_t`, these can be
fixed by using the printf specifier `%zu`.

    compiler-rt/lib/xray/xray_basic_logging.cpp:348:46: warning: format specifies type 'int' but the argument has type '__sanitizer::tid_t' (aka 'unsigned long long') [-Wformat]
          Report("Cleaned up log for TID: %d\n", GetTid());
                                          ~~     ^~~~~~~~
                                          %llu
    compiler-rt/lib/xray/xray_basic_logging.cpp:353:62: warning: format specifies type 'int' but the argument has type '__sanitizer::tid_t' (aka 'unsigned long long') [-Wformat]
          Report("Skipping buffer for TID: %d; Offset = %llu\n", GetTid(),
                                           ~~                    ^~~~~~~~
                                           %llu

Since `__sanitizer::tid_t` is effectively declared as `unsigned long
long`, these can be fixed by using the printf specifier `%llu`.

    compiler-rt/lib/xray/xray_basic_logging.cpp:354:14: warning: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                 TLD.BufferOffset);
                 ^~~~~~~~~~~~~~~~

Since `BufferOffset` is declared as `size_t`, this one can be fixed by
using `%zu` as a printf specifier.

    compiler-rt/lib/xray/xray_interface.cpp:172:50: warning: format specifies type 'int' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
        Report("Unsupported sled kind '%d' @%04x\n", Sled.Address, int(Sled.Kind));
                                       ~~            ^~~~~~~~~~~~
                                       %lu

Since ``xray::SledEntry::Address` is declared as `uint64_t`, this one
can be fixed by using `PRIu64`, and adding `<cinttypes>`.

    compiler-rt/lib/xray/xray_interface.cpp:308:62: warning: format specifies type 'long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
        Report("System page size is not a power of two: %lld\n", PageSize);
                                                        ~~~~     ^~~~~~~~
                                                        %zu
    compiler-rt/lib/xray/xray_interface.cpp:359:64: warning: format specifies type 'long long' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
        Report("Provided page size is not a power of two: %lld\n", PageSize);
                                                          ~~~~     ^~~~~~~~
                                                          %zu

Since `PageSize` is declared as `size_t`, these can be fixed by using
`%zu` as a printf specifier.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114469
2021-12-04 20:01:20 +01:00
Dmitry Vyukov fd26417a74 tsan: disable dlopen_static_tls.cpp test on aarch64
Fails on bots: https://lab.llvm.org/buildbot#builders/184/builds/1580

Differential Revision: https://reviews.llvm.org/D115095
2021-12-04 13:01:47 +01:00