Commit Graph

4899 Commits

Author SHA1 Message Date
Dmitry Vyukov debac0ef37 tsan: add a benchmark for vector memory accesses
Depends on D114592.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D114593
2021-11-25 17:07:46 +01:00
Dmitry Vyukov 5cac2b956b tsan: add a test for vector memory accesses
Add a basic test that checks races between vector/non-vector
read/write accesses of different sizes/offsets in different orders.
This gives coverage of __tsan_read/write16 callbacks.

Depends on D114591.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D114592
2021-11-25 17:07:18 +01:00
Dmitry Vyukov d841086ae6 tsan: enable -msse4 when compiling tests
Vector SSE accesses make compiler emit __tsan_[unaligned_]read/write16 callbacks.
Make it possible to test these.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D114591
2021-11-25 17:07:02 +01:00
Dmitry Vyukov a68b52e0a3 tsan: add another fork deadlock test
The test tries to provoke internal allocator to be locked during fork
and then force the child process to use the internal allocator.
This test sometimes deadlocks with the new tsan runtime.

Depends on D114514.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D114515
2021-11-24 13:25:53 +01:00
Dmitry Vyukov 764b35d89f tsan: extend mmap test
Test size larger than clear_shadow_mmap_threshold,
which is handled differently.

Depends on D114348.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114366
2021-11-24 10:57:21 +01:00
Weverything 1150f02c77 Revert "tsan: new runtime (v3)"
This reverts commit ebd47b0fb7.
This was causing unexpected behavior in programs.
2021-11-23 18:32:32 -08:00
Dmitry Vyukov d75ed9864a tsan: disable signal_sync2.cpp test on powerpc64
Fails 1 out of 10 runs on powerpc bots:
https://lab.llvm.org/buildbot/#/builders/121/builds/13391

Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D114426
2021-11-23 17:58:26 +01:00
Dmitry Vyukov ebd47b0fb7 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

Differential Revision: https://reviews.llvm.org/D112603
2021-11-23 11:44:59 +01:00
Snehasish Kumar a4b92d6158 [memprof] Remove the "Live on exit:" print for text format.
We dropped the printing of live on exit blocks in rG1243cef245f6 -
the commit changed the insertOrMerge logic. Remove the message since it
is no longer needed (all live blocks are inserted into the hashmap)
before serializing/printing the profile. Furthermore, the original
intent was to capture evicted blocks so it wasn't entirely correct.

Also update the binary format test invocation to remove the redundant
print_text directive now that it is the default.

Differential Revision: https://reviews.llvm.org/D114285
2021-11-22 13:30:48 -08:00
Matt Morehouse 615ecd8afc [HWASan] Move LTO test to separate file.
The test fails on Android for an unknown reason but is still worth
having for x86.
2021-11-22 13:19:11 -08:00
Matt Morehouse 5684a614dd [HWASan] Remove -Wa,-mrelax-relocations=no flag.
We no longer need it after https://reviews.llvm.org/D113220.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113221
2021-11-22 11:21:27 -08:00
Manoj Gupta 2e67276d98 libfuzzer: Disable broken tests for arm
libfuzzer was recently enabled for Arm32 in D112091.
A few tests apparently do not work with arm32 so disable them.
The list of tests was obtained from
https://lab.llvm.org/buildbot/#/builders/190/builds/513

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D114312
2021-11-22 10:33:14 -08:00
Dmitry Vyukov 5f18ae3988 Revert "tsan: new runtime (v3)"
Summary:
This reverts commit 1784fe0532.

Broke some bots:
https://lab.llvm.org/buildbot#builders/57/builds/12365
http://green.lab.llvm.org/green/job/clang-stage1-RA/25658/

Reviewers: vitalybuka, melver

Subscribers:
2021-11-22 19:08:48 +01:00
Dmitry Vyukov 1784fe0532 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-11-22 15:55:39 +01:00
Dmitry Vyukov e69d50d9ff tsan: disable instrumentation in runtime callbacks in tests
All runtime callbacks must be non-instrumented with the new tsan runtime
(it's now more picky with respect to recursion into runtime).
Disable instrumentation in Darwin tests as we do in all other tests now.

Differential Revision: https://reviews.llvm.org/D114348
2021-11-22 15:48:29 +01:00
Dmitry Vyukov 6a3958247a tsan: add another fork test
Add a fork test that models what happens on Mac
where fork calls malloc/free inside of our atfork
callbacks.

Reviewed By: vitalybuka, yln

Differential Revision: https://reviews.llvm.org/D114250
2021-11-22 08:36:51 +01:00
Vitaly Buka b6169e231e [nfc][dfsan] Remove obsolete comment 2021-11-18 18:37:13 -08:00
Dmitry Vyukov d0c138ec8a tsan: disable bench_threads.cpp on aarch64
The new test started failing on bots with:

CHECK failed: tsan_rtl.cpp:327 "((addr + size)) <= ((TraceMemEnd()))"
   (0xf06200e03010, 0xf06200000000) (tid=4073872)

https://lab.llvm.org/buildbot#builders/179/builds/1761

This is a latent bug in aarch64 virtual address space layout,
there is not enough address space to fit traces for all threads.
But since the trace space is going away with the new tsan runtime
(D112603), disable the test.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113990
2021-11-16 16:53:04 +01:00
Dmitry Vyukov c7081b5b4c tsan: fix crash during thread exit
Use of gethostent provokes caching of some resources inside of libc.
They are freed in __libc_thread_freeres very late in thread lifetime,
after our ThreadFinish. __libc_thread_freeres calls free which
previously crashed in malloc hooks.
Fix it by setting ignore_interceptors for finished threads,
which in turn prevents malloc hooks.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113989
2021-11-16 16:43:09 +01:00
Dmitry Vyukov 64b45399e5 tsan: speed up pthread_setname_np
pthread_setname_np does linear search over all thread descriptors
to map pthread_t to the thread descriptor. This has O(N^2) complexity
and becomes much worse in the new tsan runtime that keeps all ever
existed threads in the thread registry.
Replace linear search with direct access if pthread_setname_np
is called for the current thread (a very common case).

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113916
2021-11-16 07:51:08 +01:00
ZijunZhao d2b43605c9 add tsan shared lib
Change-Id: Ic83ff1ec86d6a7d61b07fa3df7e0cb2790b5ebc7
2021-11-16 00:42:30 +00:00
Vitaly Buka 118757af11 [msan] Disabled test failing on new GLIBC 2021-11-15 11:18:52 -08:00
Matt Kulukundis 2d9bdd9dba Fix a deadlock in __cxa_guard_abort in tsan
hat tip: @The_Whole_Daisy for helping to isolate

Reviewed By: dvyukov, fowles

Differential Revision: https://reviews.llvm.org/D113713
2021-11-15 10:39:08 +01:00
Vitaly Buka 846f33572e [sanitizer] Disable test incompartible with recert GLIBC 2021-11-14 16:25:29 -08:00
Vitaly Buka dd63c6e6b9 [sanitizer] Fix test with GLIBC 2.34 2021-11-14 11:30:50 -08:00
Vitaly Buka 7e980c46ed [sanitizer] Another try to fix the test with GLIBC 2.34 2021-11-14 00:32:23 -08:00
Vitaly Buka e56d680fe8 [sanitizer] Fix test for GLIBC 2.31
Newer GLIBC uses sysconf to get SIGSTKSZ.
2021-11-13 14:28:38 -08:00
Vitaly Buka dd87c5b322 Revert "[sanitizer] Fix test linking"
This reverts commit afafa883a4.

-pthread was not the fix. Symbols removed from GLIBC 2.34
Fixed with e60b3fcefa.
2021-11-12 23:42:35 -08:00
Vitaly Buka e60b3fcefa [sanitizer] Don't test __pthread_mutex_lock with GLIBC 2.34 2021-11-12 23:42:04 -08:00
Vitaly Buka 89fb2c71a2 [asan] More leaks in test
It fails to detect a single leak with GLIBC 2.34.
2021-11-12 17:59:14 -08:00
Vitaly Buka 4b768eeb97 [asan] Fix "no matching function" on GCC 2021-11-12 17:42:25 -08:00
Vitaly Buka afafa883a4 [sanitizer] Fix test linking 2021-11-12 16:52:58 -08:00
Ben Langmuir 2a739f2789 [ORC][ORC-RT] Register type metadata from __swift5_types MachO section
Similar to how the other swift sections are registered by the ORC
runtime's macho platform, add the __swift5_types section, which contains
type metadata. Add a simple test that demonstrates that the swift
runtime recognized the registered types.

rdar://85358530

Differential Revision: https://reviews.llvm.org/D113811
2021-11-12 16:39:59 -08:00
Dmitry Vyukov 79fbba9b79 Revert "tsan: new runtime (v3)"
Summary:
This reverts commit ac95b8d954.
There is a number of bot failures:
http://45.33.8.238/mac/38755/step_4.txt
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/38135/consoleFull#-148886289949ba4694-19c4-4d7e-bec5-911270d8a58c

Reviewers: vitalybuka, melver

Subscribers:
2021-11-12 17:49:47 +01:00
Dmitry Vyukov ac95b8d954 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-11-12 14:31:49 +01:00
Dmitry Vyukov 19c1d03f97 tsan: ignore some errors in the clone_setns test
Some bots failed with:
unshare failed: 1
https://lab.llvm.org/buildbot/#/builders/70/builds/14101

Look only for the target EINVAL error.

Differential Revision: https://reviews.llvm.org/D113759
2021-11-12 14:12:36 +01:00
Dmitry Vyukov e91595bf94 tsan: don't start background thread after clone
Start the background thread only after fork, but not after clone.
For fork we did this always and it's known to work (or user code has adopted).
But if we do this for the new clone interceptor some code (sandbox2) fails.
So model we used to do for years and don't start the background thread after clone.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113744
2021-11-12 12:58:49 +01:00
Dmitry Vyukov a6728382c6 tsan: fix XMM register corruption in hacky call
The compiler does not recognize HACKY_CALL as a call
(we intentionally hide it from the compiler so that it can
compile non-leaf functions as leaf functions).
To compensate for that hacky call thunk saves and restores
all caller-saved registers. However, it saves only
general-purposes registers and does not save XMM registers.
This is a latent bug that was masked up until a recent "NFC" commit
d736002e90 ("tsan: move memory access functions to a separate file"),
which allowed more inlining and exposed the 10-year bug.
Save and restore caller-saved XMM registers (all) as well.

Currently the bug manifests as e.g. frexp interceptor messes the
return value and the added test fails with:
  i=8177 y=0.000000 exp=4

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113742
2021-11-12 12:53:47 +01:00
Simon Moll 496e7f330c [VE] Disable incompatible compiler-rt tests
Some compiler-rt tests are inherently incompatible with VE because..

* No consistent denormal support on VE. We skip denormal fp inputs in builtin tests.
* `madvise` unsupported on VE.
* Instruction alignment requirements.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D113093
2021-11-12 08:40:03 +01:00
Snehasish Kumar aacaebc6c2 [memprof] Make the raw binary format the default.
Set the default memprof serialization format as binary. 9 tests are
updated to use print_text=true. Also fixed an issue with concatenation
of default and test specified options (missing separator).

Differential Revision: https://reviews.llvm.org/D113617
2021-11-11 11:29:36 -08:00
Snehasish Kumar 545866cb05 [memprof] Add a raw binary format to serialize memprof profiles.
This change implements the raw binary format discussed in
https://lists.llvm.org/pipermail/llvm-dev/2021-September/153007.html

Summary of changes
* Add a new memprof option to choose binary or text (default) format.
* Add a rawprofile library which serializes the MIB map to profile.
* Add a unit test for rawprofile.
* Mark sanitizer procmaps methods as virtual to be able to mock them.
* Extend memprof_profile_dump regression test.

Differential Revision: https://reviews.llvm.org/D113317
2021-11-11 11:29:36 -08:00
Snehasish Kumar 1243cef245 [memprof] Replace the block cache with a hashmap.
The existing implementation uses a cache + eviction based scheme to
record heap profile information. This design was adopted to ensure a
constant memory overhead (due to fixed number of cache entries) along
with incremental write-to-disk for evictions. We find that since the
number to entries to track is O(unique-allocation-contexts) the overhead
of keeping all contexts in memory is not very high. On a clang workload,
the max number of unique allocation contexts was ~35K, median ~11K.
For each context, we (currently) store 64 bytes of data - this amounts
to 5.5MB (max). Given the low overheads for a complex workload, we can
simplify the implementation by using a hashmap without eviction.

Other changes:
* Memory map is dumped at the end rather than startup. The relative
order in the profile dump is unchanged since we no longer have evicted
entries at runtime.
* Added a test to check meminfoblocks are merged.

Differential Revision: https://reviews.llvm.org/D111676
2021-11-11 11:29:36 -08:00
Dmitry Vyukov bc84b2857f tsan: enable clone interceptor only on Linux
Clone does not exist on Mac.
There are chances it will break on other OSes.
Enable it incrementally starting with Linux only,
other OSes can enable it later as needed.

Reviewed By: melver, thakis

Differential Revision: https://reviews.llvm.org/D113693
2021-11-11 19:27:47 +01:00
Dmitry Vyukov 82de586d4b tsan: intercept clone
gtest uses clone for death tests and it needs the same
handling as fork to prevent deadlock (take runtime mutexes
before and release them after).

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113677
2021-11-11 18:55:54 +01:00
Emily Shi 919ca9fc04 [compiler-rt] separate lsan, ubsan, stats configuration from SANITIZER_COMMON_SUPPORTED_OS
Currently, SANITIZER_COMMON_SUPPORTED_OS is being used to enable many libraries.
Unfortunately this makes it impossible to selectively disable a library based on the OS.
This patch removes this limitation by adding a separate list of supported OSs for the lsan, ubsan, ubsan_minimal, and stats libraries.

Reviewed By: delcypher

Differential Revision: https://reviews.llvm.org/D113444
2021-11-10 19:16:20 -08:00
Dokyung Song 614b8bac01 [libFuzzer] Deflake entropic exec-time test.
Entropic scheduling with exec-time option can be misled, if inputs
on the right path to become crashing inputs accidentally take more
time to execute before it's added to the corpus. This patch, by letting
more of such inputs added to the corpus (four inputs of size 7 to 10,
instead of a single input of size 2), reduces possibilities of being
influenced by timing flakiness.

A longer-term fix could be to reduce timing flakiness in the fuzzer;
one way could be to execute inputs multiple times and take average of
their execution time before they are added to the corpus.

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D113544
2021-11-10 07:43:21 -08:00
Kostya Serebryany b7f3a4f4fa [sancov] add tracing for loads and store
add tracing for loads and stores.

The primary goal is to have more options for data-flow-guided fuzzing,
i.e. use data flow insights to perform better mutations or more agressive corpus expansion.
But the feature is general puspose, could be used for other things too.

Pipe the flag though clang and clang driver, same as for the other SanitizerCoverage flags.
While at it, change some plain arrays into std::array.

Tests: clang flags test, LLVM IR test, compiler-rt executable test.

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D113447
2021-11-09 14:35:13 -08:00
zijunzhao 45d28e3a30 Revert "add tsan shared lib"
This reverts commit 92c9b340be.
2021-11-09 16:36:06 +00:00
Matt Morehouse 846ec2c3cc [HWASan] Ensure RNG is initialized in GenerateRandomTag
Fixes a CHECK-failure caused by glibc's pthread_getattr_np
implementation calling realloc.  Essentially, Thread::GenerateRandomTag
gets called during Thread::Init and before Thread::InitRandomState:

  HWAddressSanitizer: CHECK failed: hwasan_thread.cpp:134 "((random_buffer_)) != (0)" (0x0, 0x0) (tid=314)
    #0 0x55845475a662 in __hwasan::CheckUnwind()
    #1 0x558454778797 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long)
    #2 0x558454766461 in __hwasan::Thread::GenerateRandomTag(unsigned long)
    #3 0x55845475c58b in __hwasan::HwasanAllocate(__sanitizer::StackTrace*, unsigned long, unsigned long, bool)
    #4 0x55845475c80a in __hwasan::hwasan_realloc(void*, unsigned long, __sanitizer::StackTrace*)
    #5 0x5584547608aa in realloc
    #6 0x7f6f3a3d8c2c in pthread_getattr_np
    #7 0x5584547790dc in __sanitizer::GetThreadStackTopAndBottom(bool, unsigned long*, unsigned long*)
    #8 0x558454779651 in __sanitizer::GetThreadStackAndTls(bool, unsigned long*, unsigned long*, unsigned long*, unsigned long*)
    #9 0x558454761bca in __hwasan::Thread::InitStackAndTls(__hwasan::Thread::InitState const*)
    #10 0x558454761e5c in __hwasan::HwasanThreadList::CreateCurrentThread(__hwasan::Thread::InitState const*)
    #11 0x55845476184f in __hwasan_thread_enter
    #12 0x558454760def in HwasanThreadStartFunc(void*)
    #13 0x7f6f3a3d6fa2 in start_thread
    #14 0x7f6f3a15b4ce in __clone

Also reverts 7a3fb71c3c, as it's now
unneeded.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113045
2021-11-09 07:01:55 -08:00
ZijunZhao 92c9b340be add tsan shared lib
Change-Id: Ic83ff1ec86d6a7d61b07fa3df7e0cb2790b5ebc7
2021-11-09 02:34:37 +00:00
Vitaly Buka 33af9a31c0 [NFC] Move setuid.c test into sanitizer_common 2021-11-08 18:24:01 -08:00
Snehasish Kumar 9305e3b6d7 [NFC] Update the test compiler to use clangxx.
This ensures that the c++ test gets the right CXXFLAGS if required.
2021-11-08 13:57:32 -08:00
Vitaly Buka bbc213afd1 [asan] compiler-rt version of D113143 2021-11-04 23:51:16 -07:00
Julian Lettner f643afa25f Revert "Mark tsan cxa_guard_acquire test as unsupported on Darwin"
This reverts commit 593275c93c.

This test now passes again.
2021-11-03 19:07:56 -07:00
Vitaly Buka 91f0a6ad4e [asan] Disable test on Android Arm 32bit
Caused by D111703.
2021-11-03 13:12:56 -07:00
Vitaly Buka e28c64ecb1 [sanitizer] Disable new test on Android
Test added with D113055
2021-11-03 11:57:04 -07:00
Tamir Duberstein f639882be8 [sanitizer] Allow getsockname with NULL addrlen
This is already permitted in getpeername, and returns EFAULT
on Linux (does not crash the program).

Fixes https://github.com/google/sanitizers/issues/1451.

Differential Revision: https://reviews.llvm.org/D113055
2021-11-03 10:23:01 -07:00
Matt Morehouse 498a4c2fd7 [HWASan] Print short tags in tag mismatch description.
I recently spent some extra time debugging a false positive because I
didn't realize the "real" tag was in the short granule.  Adding the
short tag here makes it more obvious that we could be dealing with a
short granule.

Reviewed By: hctim, eugenis

Differential Revision: https://reviews.llvm.org/D112949
2021-11-02 08:00:33 -07:00
Matt Morehouse 8c60e0b632 [HWASan] Print short tags in __hwasan_print_shadow.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D112959
2021-11-02 07:59:25 -07:00
Vitaly Buka 869989dd71 [sanitizer] Restore trivial posix_spawn init in test
It's still needed on Darwin.
2021-11-01 23:58:18 -07:00
Vitaly Buka 57d34cb223 Revert "[sanitizer] Fix compilation of the test"
Revert "[sanitizer] Fix PosixSpawnImpl which fails exitcode test"

This reverts commit 8cabd8f0d2 and part of 9213202abd.

It is not enough for Android.
2021-11-01 22:25:26 -07:00
Vitaly Buka 8cabd8f0d2 [sanitizer] Fix compilation of the test 2021-11-01 21:50:50 -07:00
Vitaly Buka 15361a98aa [sanitizer] Add test for 9213202abd 2021-11-01 21:14:11 -07:00
Vitaly Buka 9213202abd [sanitizer] Fix PosixSpawnImpl which fails exitcode test 2021-11-01 21:03:02 -07:00
Vitaly Buka 0d59efbba4 [sanitizer] Fix test include on Darwin 2021-11-01 16:49:50 -07:00
Matt Morehouse 4d8b0aa5c0 [HWASan] Apply TagMaskByte to every global tag.
Previously we only applied it to the first one, which could allow
subsequent global tags to exceed the valid number of bits.

Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D112853
2021-11-01 06:31:44 -07:00
Matt Morehouse b298d6d162 [sanitizer] Disable posix_spawn.c test on Android. 2021-11-01 06:22:48 -07:00
Vitaly Buka e1240745ef [sanitizer] Add posix_spawn interceptor
To make pid initialized for Msan.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D112784
2021-10-31 12:10:54 -07:00
Dmitry Vyukov d31b2dc235 tsan: add debugging code for ptrace test failures
Debugging of crashes on powerpc after commit:
c80604f7a3 ("tsan: remove real func check from interceptors")
Somehow replacing if with DCHECK leads to strange failures in:
SanitizerCommon-tsan-powerpc64le-Linux :: Linux/ptrace.cpp
https://lab.llvm.org/buildbot/#/builders/105
https://lab.llvm.org/buildbot/#/builders/121
https://lab.llvm.org/buildbot/#/builders/57

The hypothesis is that something writes out-of-bounds
into pt_regs on stack and that corrupts internal tsan state.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112703
2021-10-29 17:37:02 +02:00
Dmitry Vyukov a871c34e8d sanitizer_common: fix up onprint.cpp test more
D112630 ("sanitizer_common: fix up onprint.cpp test")
added O_CREAT, but we also need O_TRUNC b/c the file
may not exist, or may exist as well.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112788
2021-10-29 13:44:04 +02:00
David CARLIER c9174f63b6 [compiler-rt] fix asan buildbot failure on unit test for darwin 2021-10-28 18:48:54 +01:00
David CARLIER bb168f3207 [compiler-rt] update detect_write_exec option for apple devices.
Reviewed By: yln, vitalybuka

Differential Revision: https://reviews.llvm.org/D111390
2021-10-28 17:08:23 +01:00
Florian Mayer dd943ebc6d [hwasan] print exact mismatch offset for short granules.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104463
2021-10-28 03:31:11 +01:00
Kai Luo 6ea2431d3f [clang][compiler-rt][atomics] Add `__c11_atomic_fetch_nand` builtin and support `__atomic_fetch_nand` libcall
Add `__c11_atomic_fetch_nand` builtin to language extensions and support `__atomic_fetch_nand` libcall in compiler-rt.

Reviewed By: theraven

Differential Revision: https://reviews.llvm.org/D112400
2021-10-28 02:18:43 +00:00
Ben Langmuir 3d13ee2891 [ORC][ORC-RT] Enable the MachO platform for arm64
Enables the arm64 MachO platform, adds basic tests, and implements the
missing TLV relocations and runtime wrapper function. The TLV
relocations are just handled as GOT accesses.

rdar://84671534

Differential Revision: https://reviews.llvm.org/D112656
2021-10-27 13:36:03 -07:00
Dmitry Vyukov 910aeed77e sanitizer_common: fix up onprint.cpp test
Commit D112602 ("sanitizer_common: tighten on_print hook test")
changed fopen to open in this test. fopen created the file
if if does not exist, but open does not. This was unnoticed
during local testing because lit is not hermetic and reuses
files from previous runs, but it started failing on bots.
Fix the open call.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112630
2021-10-27 18:17:15 +02:00
Dmitry Vyukov eae047afe0 sanitizer_common: tighten on_print hook test
The new tsan runtime does not support arbitrary forms
of recursing into the runtime from hooks.
Disable instrumentation of the hook and use write instead
of fwrite (calls malloc internally).
The new version still recurses (write is intercepted),
but does not fail now (the issue at hand was malloc).

Depends on D112601.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112602
2021-10-27 15:11:43 +02:00
Julian Lettner c79d484ab1 [TSan] Ensure test uses tagged pointer
This is a test-only failure. The test wrongly assumes that this gets us
a tagged pointer:
```
NSObject* num1 = @7;
assert(isTaggedPtr(num1));
```

However, on newer deployment targets that have “const data support” we
get a “normal” pointer to constant object.

Radar-Id: rdar://problem/83217293
2021-10-26 11:53:02 -07:00
Dmitry Vyukov f5a32f5a82 tsan: fix free_race3.c test
PPC64 bot failed with the following error.
The buildbot output is not particularly useful,
but looking at other similar tests, it seems
that there is something broken in free stacks on PPC64.
Use the same hack as other tests use to expect
an additional stray frame.

/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/tsan/free_race3.c:28:11: error: CHECK: expected string not found in input
// CHECK: Previous write of size 4 at {{.*}} by thread T1{{.*}}:
          ^
<stdin>:13:9: note: scanning from here
 #1 main /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/tsan/free_race3.c:17:3 (free_race3.c.tmp+0x1012fab8)
        ^
<stdin>:17:2: note: possible intended match here
ThreadSanitizer: reported 1 warnings
 ^

Input file: <stdin>
Check file: /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/tsan/free_race3.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
            8:  Previous write of size 4 at 0x7ffff4d01ab0 by thread T1:
            9:  #0 Thread /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/tsan/free_race3.c:8:10 (free_race3.c.tmp+0x1012f9dc)
           10:
           11:  Thread T1 (tid=3222898, finished) created by main thread at:
           12:  #0 pthread_create /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1001:3 (free_race3.c.tmp+0x100b9040)
           13:  #1 main /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/tsan/free_race3.c:17:3 (free_race3.c.tmp+0x1012fab8)
check:28'0             X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
           14:
check:28'0     ~
           15: SUMMARY: ThreadSanitizer: data race /home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/compiler-rt/test/tsan/free_race3.c:19:3 in main
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           16: ==================
check:28'0     ~~~~~~~~~~~~~~~~~~~
           17: ThreadSanitizer: reported 1 warnings
check:28'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:28'1      ?                                    possible intended match
>>>>>>

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112444
2021-10-25 14:51:24 +02:00
Dmitry Vyukov 269aa74aed tsan: add another use-after-free race test
Add a test where a race with free is called during the free itself
(we only have tests where a race with free is caught during the other memory acces).

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D112433
2021-10-25 14:06:55 +02:00
David Blaikie aee4925507 Recommit: Compress formatting of array type names (int [4] -> int[4])
Based on post-commit review discussion on
2bd8493847 with Richard Smith.

Other uses of forcing HasEmptyPlaceHolder to false seem OK to me -
they're all around pointer/reference types where the pointer/reference
token will appear at the rightmost side of the left side of the type
name, so they make nested types (eg: the "int" in "int *") behave as
though there is a non-empty placeholder (because the "*" is essentially
the placeholder as far as the "int" is concerned).

This was originally committed in 277623f4d5

Reverted in f9ad1d1c77 due to breakages
outside of clang - lldb seems to have some strange/strong dependence on
"char [N]" versus "char[N]" when printing strings (not due to that name
appearing in DWARF, but probably due to using clang to stringify type
names) that'll need to be addressed, plus a few other odds and ends in
other subprojects (clang-tools-extra, compiler-rt, etc).
2021-10-21 11:34:43 -07:00
Ben Langmuir 92a6dd6e50 [test][ORC-RT] Disable x86_64 tests when target arch does not match
When cross-compiling, these tests will fail. For now leave the host arch
check that was already there since I don't know why it was added.
2021-10-21 10:01:23 -07:00
Matt Morehouse e1e2635327 [HWASan] Use tagged-globals feature on x86.
Allows us to use the small code model when we disable relocation
relaxation.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D111344
2021-10-19 05:56:50 -07:00
Vitaly Buka e0f3a3b228 [ubsan] Remove REQUIRED from some TestCases
It's not obvious why they are needed, and tests pass.

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D111859
2021-10-15 10:20:34 -07:00
Dan Liew 2232a68b2d Fix another test not using the standard separator for sanitizer options.
rdar://83637067
2021-10-15 00:20:34 -07:00
Vitaly Buka a1e78aee66 [NFC][asan] Speedup uar_signals.cpp test
It was the slowest test:
--------------------------------------------------------------------------
41.77s: AddressSanitizer-x86_64-linux :: TestCases/Linux/uar_signals.cpp
26.64s: AddressSanitizer-i386-linux :: TestCases/Linux/uar_signals.cpp
14.82s: AddressSanitizer-x86_64-linux :: TestCases/Posix/current_allocated_bytes.cpp
14.79s: AddressSanitizer-i386-linux :: TestCases/Posix/current_allocated_bytes.cpp
11.55s: AddressSanitizer-x86_64-linux :: TestCases/scariness_score_test.cpp
10.15s: AddressSanitizer-x86_64-linux :: TestCases/Posix/stack-use-after-return.cpp
2021-10-14 17:05:19 -07:00
Vitaly Buka 882ce178b3 [NFC][sanitizer] Remove %stdcxx11
-std=c++14 is a default for a while.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D111848
2021-10-14 16:47:43 -07:00
Vitaly Buka 1274a07da0 [NFC][asan] Use more common socket type in test 2021-10-14 16:46:07 -07:00
Evgenii Stepanov 7a3fb71c3c [hwasan] Fix TestCases/thread-uaf.c.
On newer glibc, this test detects an extra match somewhere under
pthread_getattr_np. This results in Thread: lines getting spread out in
the report and failing to match the CHECKs.

Fix the CHECKs to allow this possibility.

Reviewed By: fmayer

Differential Revision: https://reviews.llvm.org/D111841
2021-10-14 14:56:57 -07:00
Collin Baker 8c66d78172 [test] Fix asan dynamic unit tests with per-target runtime dirs
When LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on
Asan-i386-calls-Dynamic-Test and Asan-i386-inline-Dynamic-Test fail to
run on a x86_64 host. This is because asan's unit test lit files are
configured once, rather than per target arch as with the non-unit
tests. LD_LIBRARY_PATH ends up incorrect, and the tests try linking
against the x86_64 runtime which fails.

This changes the unit test CMake machinery to configure the default
and dynamic unit tests once per target arch, similar to the other asan
tests. Then the fix from https://reviews.llvm.org/D108859 is adapted
to the unit test Lit files with some modifications.

Fixes PR52158.

Differential Revision: https://reviews.llvm.org/D111756
2021-10-14 16:47:25 -04:00
Jinsong Ji 4fee8a1691 [NFC][compiler-rt][profile] Remove non-Posix -h option from test
We are running `ls -lh` in gcov-execlp.c test in Posix folder.
However `-h` is not a POSIX option,ls on some POSIX system (eg: AIX)
may not support it.

This patch remove this option to avoid break.

Reviewed By: anhtuyen

Differential Revision: https://reviews.llvm.org/D111807
2021-10-14 15:08:38 +00:00
Jinsong Ji 666accf283 [compiler-rt][profile] Enable profile tests for AIX
This patch enable profile test for supported options on AIX.

Reviewed By: w2yehia

Differential Revision: https://reviews.llvm.org/D110945
2021-10-13 03:00:32 +00:00
Andrew Browne 50a08e2c6d [DFSan] Fix flakey release_shadow_space.c accounting for Origin chains.
Test sometimes fails on buildbot (after two non-Origins executions):

/usr/bin/ld: warning: Cannot export local symbol 'dfsan_flush'
RSS at start: 4620, after mmap: 107020, after mmap+set label: 209424, after fixed map: 4624, after another mmap+set label: 209424, after munmap: 4624
/usr/bin/ld: warning: Cannot export local symbol 'dfsan_flush'
RSS at start: 4620, after mmap: 107020, after mmap+set label: 209424, after fixed map: 4624, after another mmap+set label: 209424, after munmap: 4624
/usr/bin/ld: warning: Cannot export local symbol 'dfsan_flush'
RSS at start: 4620, after mmap: 107020, after mmap+set label: 317992, after fixed map: 10792, after another mmap+set label: 317992, after munmap: 10792
release_shadow_space.c.tmp: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c:91: int main(int, char **): Assertion `after_fixed_mmap <= before + delta' failed.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D111522
2021-10-11 00:35:12 -07:00
luxufan 590326382d [Orc] Support atexit in Orc(JITLink)
There is a bug reported at https://bugs.llvm.org/show_bug.cgi?id=48938

After looking through the glibc, I found the `atexit(f)` is the same as `__cxa_atexit(f, NULL, NULL)`. In orc runtime, we identify different JITDylib by their dso_handle value, so that a NULL dso_handle is invalid. So in this patch, I added a `PlatformJDDSOHandle` to ELFNixRuntimeState, and functions which are registered by atexit will be registered at PlatformJD.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D111413
2021-10-09 12:25:47 +08:00
Andrew Browne 61ec2148c5 [DFSan] Remove -dfsan-args-abi support in favor of TLS.
ArgsABI was originally added in https://reviews.llvm.org/D965

Current benchmarking does not show a significant difference.
There is no need to maintain both ABIs.

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D111097
2021-10-08 11:18:36 -07:00
David Spickett 30677a043c [compiler-rt][fuzzer] Re-enable flags test on AArch64 Linux
This is now passing after bots were upgraded to Ubuntu Focal,
which comes with ld 2.34.
2021-10-08 08:55:22 +00:00
Vitaly Buka ef85ea9a4f [msan] Print both shadow and user address
before:
00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00
Shadow map of [0x211000000005, 0x21100000012e), 297 bytes:
now:
0x2f60d213ac10[0x7f60d213ac10]  00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00
Shadow map [0x211000000005, 0x21100000012e) of [0x711000000005, 0x711000000135), 297 bytes:

Differential Revision: https://reviews.llvm.org/D111261
2021-10-07 17:56:46 -07:00
Leonard Chan 7afd956e0f [compiler-rt][memprof] Disambiguate checks for __tls_get_addr in output
TestCases/stress_dtls.c was failing when we ran memprof tests for the first
time. The test checks that __tls_get_addr is not in the output for the last
run when it is possible for the interceptor __interceptor___tls_get_addr to
be in the output from stack dumps. The test actually intends to check that
the various __tls_get_addr reports don't get emitted when intercept_tls_get_addr=0.
This updates the test to also check for the following `:` and preceding `==`
which should ignore the __interceptor___tls_get_addr interceptor.

Differential Revision: https://reviews.llvm.org/D111192
2021-10-06 13:54:42 -07:00
Leonard Chan 77d5ccdc6f [compiler-rt][test] Add shared_unwind requirement
When using a static libunwind, the check_memcpy.c can fail because it checks
that tsan intercepted all memcpy/memmoves in the final binary. Though if the
static libunwind is not instrumented, then this will fail because it may contain
regular memcpy/memmoves.

This adds a new REQUIRES check for ensuring that this test won't run unless a
dynamic libunwind.so is provided.

Differential Revision: https://reviews.llvm.org/D111194
2021-10-06 11:10:36 -07:00
David Spickett f8f1bb7462 [compiler-rt][lsan] Add backup AArch64 register for use_registers test
On Ubuntu Focal x13 is used by something in the process of calling
sched_yield. Causing the test to fail depending on when the thread
is stopped.

Adding x14 works around this and the test passes consistently.

Not switching to only x14 because that could make other platforms
fail. With both we'll always find at least one and even if both
values are present we'll only get one report.

Reviewed By: oontvoo, vitalybuka

Differential Revision: https://reviews.llvm.org/D110931
2021-10-06 09:45:53 +01:00