Commit Graph

15031 Commits

Author SHA1 Message Date
Vitaly Buka d591a46d17 [NFC][sanitizer] Fix naming in StackStore 2021-11-18 19:39:20 -08:00
Vitaly Buka 8210948a46 [NFC][sanitizer] constexpr StackStore::StackStore() 2021-11-18 19:24:29 -08:00
Vitaly Buka bb50e97103 [NFC][sanitizer] Change StackStore API to use StackTrace 2021-11-18 18:53:51 -08:00
Vitaly Buka 6bf71be9f9 [NFC][sanitizer] Move inline implementation of StackStore into cpp 2021-11-18 18:38:06 -08:00
Vitaly Buka 368a3b5221 [NFC][sanitizer] Rename PersistentAllocator to StackStore 2021-11-18 18:37:51 -08:00
Vitaly Buka b6169e231e [nfc][dfsan] Remove obsolete comment 2021-11-18 18:37:13 -08:00
Vitaly Buka 930ccf0191 [NFC][sanitizer] Rename persistent_allocator to stack_store 2021-11-18 18:36:58 -08:00
Vitaly Buka b0ea7ef0d6 [msan] Clang-format the test 2021-11-18 18:30:49 -08:00
Manoj Gupta 2782cb8da0 libfuzzer: All building libfuzzer for ARM32
We need libfuzzer libraries on Arm32 so that we can fuzz
Arm32 binaries on Linux (Chrome OS). Android already
allows Arm32 for libfuzzer.

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D112091
2021-11-18 17:30:24 -08:00
Dmitry Vyukov 111d8f785b tsan: remove quadratic behavior in pthread_join
pthread_join needs to map pthread_t of the joined thread to our Tid.
Currently we do this with linear search over all threads.
This has quadratic complexity and becomes much worse with the new
tsan runtime, which memorizes all threads that ever existed.

To resolve this add a hash map of live threads only (that are still
associated with pthread_t) and use it for the mapping.

With the new tsan runtime some programs spent 1/3 of time in this mapping.
After this change the mapping disappears from profiles.

Depends on D113996.

Reviewed By: vitalybuka, melver

Differential Revision: https://reviews.llvm.org/D113997
2021-11-17 19:41:49 -08:00
Vitaly Buka c26dbc4ab4 [sanitizer] Fix DenseMap for compiler-rt
Depends on D114047.

Differential Revision: https://reviews.llvm.org/D114048
2021-11-17 19:10:20 -08:00
Vitaly Buka 7612cfd31d [NFC][sanitizer] Fix headers of DenseMap
Depends on D114046.

Differential Revision: https://reviews.llvm.org/D114047
2021-11-17 19:10:20 -08:00
Vitaly Buka 234a8301cd [NFC][sanitizer] Clang format copied code
Depends on D114045.

Differential Revision: https://reviews.llvm.org/D114046
2021-11-17 19:10:20 -08:00
Vitaly Buka 54adc1675e [NFC][sanitizer] Add unchanged DenseMap
It's just a copy even without reformatting.

Reviewed By: dvyukov, melver

Differential Revision: https://reviews.llvm.org/D114045
2021-11-17 19:10:19 -08:00
Vitaly Buka 254f9311fe [NFC][sanitizer] Fix veradic-macro warning in RAW_CHECK 2021-11-17 18:10:54 -08:00
Vitaly Buka 02eca53a50 [sanitizer] Add a few of type_traits tools
For D114047
2021-11-17 17:52:40 -08:00
Leonard Chan 1a84d1c81e [compiler-rt][asan] Re-add `self`
We ran into errors where this wasn't defined in Fuchsia's asan implementation.
2021-11-17 15:48:41 -08:00
Vitaly Buka 22e66a97cb Revert "[sanitizer] Add a few of type_traits tools"
Does not work with GCC

This reverts commit a82ee2be9c.
2021-11-17 15:46:16 -08:00
Vitaly Buka a82ee2be9c [sanitizer] Add a few of type_traits tools
For D114047
2021-11-17 15:06:38 -08:00
Jonas Paulsson 4c32e3d967 [SystemZ] [Sanitizer] Bugfixes in internal_clone().
The __flags variable needs to be of type 'long' in order to get sign extended
properly.

internal_clone() uses an svc (Supervisor Call) directly (as opposed to
internal_syscall), and therefore needs to take care to set errno and return
-1 as needed.

Review: Ulrich Weigand
2021-11-17 14:42:08 -05:00
Dmitry Vyukov bdabf3c38a asan: don't use thread user_id
asan does not use user_id for anything,
so don't pass it to ThreadCreate.
Passing a random uninitialized field of AsanThread
as user_id does not make much sense anyway.

Depends on D113921.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113922
2021-11-17 14:49:33 +01:00
Dmitry Vyukov d1f72f02d0 memprof: don't use thread user_id
memprof does not use user_id for anything,
so don't pass it to ThreadCreate.
Passing a random field of MemprofThread as user_id
does not make much sense anyway.

Depends on D113920.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113921
2021-11-17 14:49:25 +01:00
Dmitry Vyukov 033b94ab52 lsan: remove pthread_detach/join interceptors
They don't seem to do anything useful in lsan.
They are needed only if a tools needs to execute
some custom logic during detach/join, or if it uses
thread registry quarantine. Lsan does none of this.
And if a tool cares then it would also need to intercept
pthread_tryjoin_np and pthread_timedjoin_np, otherwise
it will mess thread states.
Fwiw, asan does not intercept these functions either.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113920
2021-11-17 14:49:15 +01:00
Vitaly Buka 82fc4cc60b [scudo] Handle mallinfo2
mallinfo is deprecated by GLIBC

Reviewed By: cryptoad

Differential Revision: https://reviews.llvm.org/D113951
2021-11-16 19:29:37 -08:00
Evgenii Stepanov 913d78c40c [scudo] Regression test for the MTE crash in storeEndMarker.
The original problem was fixed in D105261.

Differential Revision: https://reviews.llvm.org/D114022
2021-11-16 13:43:15 -08:00
Pirama Arumuga Nainar 078279ff01 [compiler-rt/profile] Reland mark __llvm_profile_raw_version as hidden
Since libclang_rt.profile is added later in the command line, a
definition of __llvm_profile_raw_version is not included if it is
provided from an earlier object, e.g.  from a shared dependency.

This causes an extra dependence edge where if libA.so depends on libB.so
and both are coverage-instrumented, libA.so uses libB.so's definition of
__llvm_profile_raw_version.  This leads to a runtime link failure if the
libB.so available at runtime does not provide this symbol (but provides
the other dependent symbols).  Such a scenario can occur in Android's
mainline modules.
E.g.:
  ld -o libB.so libclang_rt.profile-x86_64.a
  ld -o libA.so -l B libclang_rt.profile-x86_64.a

libB.so has a global definition of __llvm_profile_raw_version.  libA.so
uses libB.so's definition of __llvm_profile_raw_version.  At runtime,
libB.so may not be coverage-instrumented (i.e. not export
__llvm_profile_raw_version) so runtime linking of libA.so will fail.

Marking this symbol as hidden forces each binary to use the definition
of __llvm_profile_raw_version from libclang_rt.profile.  The visiblity
is unchanged for Apple platforms where its presence is checked by the
TAPI tool.

Reviewed By: MaskRay, phosek, davidxl

Differential Revision: https://reviews.llvm.org/D111759
2021-11-16 11:37:00 -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 c971f989ee tsan: de-hardcode number of unused bits in trace events
Precisely specifying the unused parts of the bitfield is critical for
performance. If we don't specify them, compiler will generate code to load
the old value and shuffle it to extract the unused bits to apply to the new
value. If we specify the unused part and store 0 in there, all that
unnecessary code goes away (store of the 0 const is combined with other
constant parts).

I don't see a good way to ensure we cover all of u64 bits with fields.
So at least introduce named kUnusedBits consts and check that bits
sum up to 64.

Depends on D113978.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113979
2021-11-16 16:00:14 +01:00
Dmitry Vyukov fa24d58279 tsan: use smaller trace parts for Go
In the old runtime we used to use different number of trace parts
for C++ and Go to reduce trace memory consumption for Go.
But now it's easier and better to use smaller parts because
we already use minimal possible number of parts for C++ (3).

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113978
2021-11-16 15:59:33 +01:00
Dmitry Vyukov 87261caa55 tsan: use pthread_equal instead of direct pthread_t comparison
man pthread_equal:
  The pthread_equal() function is necessary because thread IDs
  should be considered opaque: there is no portable way for
  applications to directly compare two pthread_t values.

Depends on D113916.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113919
2021-11-16 07:51:24 +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 cda72e9297
[msan] Fix test with GLIBC 2.34
PTHREAD_STACK_MIN is not a constexpr
2021-11-14 20:15:45 -08: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
hyeongyu kim 7f7cab6bb1 [sanitizer][aarch64] fix clone system call's inline assembly
Return value of the system call was not returned normally.
It was discussed at https://reviews.llvm.org/D105169.
2021-11-14 09:45:40 +09: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
Dmitry Vyukov b5ff187b7b tsan: mmap shadow stack
We used to mmap C++ shadow stack as part of the trace region
before ed7f3f5bc9 ("tsan: move shadow stack into ThreadState"),
which moved the shadow stack into TLS. This started causing
timeouts and OOMs on some of our internal tests that repeatedly
create and destroy thousands of threads.
Allocate C++ shadow stack with mmap and small pages again.
This prevents the observed timeouts and OOMs.
But we now need to be more careful with interceptors that
run after thread finalization because FuncEntry/Exit and
TraceAddEvent all need the shadow stack.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D113786
2021-11-13 09:12:55 +01: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
Vitaly Buka cb0e14ce6d [sanitizer] Switch dlsym hack to internal_allocator
Since glibc 2.34, dlsym does
  1. malloc 1
  2. malloc 2
  3. free pointer from malloc 1
  4. free pointer from malloc 2
These sequence was not handled by trivial dlsym hack.

This fixes https://bugs.llvm.org/show_bug.cgi?id=52278

Reviewed By: eugenis, morehouse

Differential Revision: https://reviews.llvm.org/D112588
2021-11-12 16:11:10 -08:00
Vitaly Buka 07092ea6bd [asan] Fix GCC warning "left shift count >= width"
Fixes PR52385
2021-11-12 13:04:00 -08:00