Commit Graph

14611 Commits

Author SHA1 Message Date
Lang Hames 8614cb9f99 [ORC-RT] Add non-const WrapperFunctionResult data access, simplify allocate.
WrapperFunctionResult no longer supports wrapping constant data, so this patch
provides direct non-const access to the wrapped data. Since wrapped data can now
be written, the WrapperFunctionResult::allocate method can be simplified to
return a WrapperFunctionResult.

This is essentially the same change (and with the same motivation) as LLVM
commit 8b117830b1, but applied to the ORC runtime's WrapperFunctionResult code.
2021-08-24 17:34:59 +10:00
Petr Hosek 8111f2f7ee [profile] Update counter offset to account for binary ids
In the raw profile, binary ids immediately follow the header so when
computing counters offset we need to account for the new section.

Differential Revision: https://reviews.llvm.org/D108608
2021-08-23 21:43:30 -07:00
Amy Kwan 4cd8dd3fe0 [scudo][standalone] Link tests against libatomic if libatomic exists
It is possible that libatomic does not exist on some systems. This patch updates
the scudo standalone tests to link against libatomic if the library exists.

This is an update to the original patch: https://reviews.llvm.org/D64134 and
aims to resolve https://bugs.llvm.org/show_bug.cgi?id=51431.

Differential Revision: https://reviews.llvm.org/D108503
2021-08-22 13:47:04 -05:00
Florian Mayer de916a7b12 Revert "[hwasan] do not check if freed pointer belonged to allocator."
This reverts commit 119146f8ae.
2021-08-20 12:21:00 +01:00
Florian Mayer 119146f8ae [hwasan] do not check if freed pointer belonged to allocator.
In that case it is very likely that there will be a tag mismatch anyway.

We handle the case that the pointer belongs to neither of the allocators
by getting a nullptr from allocator.GetBlockBegin.

Reviewed By: hctim, eugenis

Differential Revision: https://reviews.llvm.org/D108383
2021-08-20 10:12:47 +01:00
Martin Storsjö e6407356ba [builtins] Move Windows/ARM frontends for fix/float functions into the individual source files
This avoids pulling in all of them if only one of them is needed
(if builtins are built without -ffunction-sections), and matches how
the similar aliases for AEABI are set up.

Differential Revision: https://reviews.llvm.org/D107815
2021-08-20 09:13:32 +03:00
Jinsong Ji 337bd67d83 [CRT][LIT] split target_cflags using shlex
Update the commit to use shlex.split, as the win32 is not supported.

See https://reviews.llvm.org/D108329 for discussions.
2021-08-19 21:44:20 -04:00
Brian Cain 68ab571e22 [sanitizer] Fix for CMAKE_CXX_FLAGS update
With unquoted ${CMAKE_CXX_FLAGS}, the REGEX fails when it's empty:

```CMake Error at lib/scudo/standalone/CMakeLists.txt:14 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.```
2021-08-19 12:05:55 -07:00
Jinsong Ji 0541ce4ef9 [CRT][LIT] build the target_cflags for Popen properly
We recently enabled crt for powerpc in
https://reviews.llvm.org/rGb7611ad0b16769d3bf172e84fa9296158f8f1910.

And we started to see some unexpected error message when running
check-runtimes.

eg:
https://lab.llvm.org/buildbot/#/builders/57/builds/9488/steps/6/logs/stdio
line 100 - 103:

"
clang-14: error: unknown argument: '-m64 -fno-function-sections'
clang-14: error: unknown argument: '-m64 -fno-function-sections'
clang-14: error: unknown argument: '-m64 -fno-function-sections'
clang-14: error: unknown argument: '-m64 -fno-function-sections'
"

Looks like we shouldn't strip the space at the beginning,
or else the command line passed to subprocess won't work well.

Reviewed By: phosek, MaskRay

Differential Revision: https://reviews.llvm.org/D108329
2021-08-19 15:39:53 +00:00
Marco Elver 303d278ad2 [tsan] Fix pthread_once() on Mac OS X
Change 636428c727 enabled BlockingRegion hooks for pthread_once().
Unfortunately this seems to cause crashes on Mac OS X which uses
pthread_once() from locations that seem to result in crashes:

| ThreadSanitizer:DEADLYSIGNAL
| ==31465==ERROR: ThreadSanitizer: stack-overflow on address 0x7ffee73fffd8 (pc 0x00010807fd2a bp 0x7ffee7400050 sp 0x7ffee73fffb0 T93815)
|     #0 __tsan::MetaMap::GetSync(__tsan::ThreadState*, unsigned long, unsigned long, bool, bool) tsan_sync.cpp:195 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x78d2a)
|     #1 __tsan::MutexPreLock(__tsan::ThreadState*, unsigned long, unsigned long, unsigned int) tsan_rtl_mutex.cpp:143 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x6cefc)
|     #2 wrap_pthread_mutex_lock sanitizer_common_interceptors.inc:4240 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x3dae0)
|     #3 flockfile <null>:2 (libsystem_c.dylib:x86_64+0x38a69)
|     #4 puts <null>:2 (libsystem_c.dylib:x86_64+0x3f69b)
|     #5 wrap_puts sanitizer_common_interceptors.inc (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x34d83)
|     #6 __tsan::OnPotentiallyBlockingRegionBegin() cxa_guard_acquire.cpp:8 (foo:x86_64+0x100000e48)
|     #7 wrap_pthread_once tsan_interceptors_posix.cpp:1512 (libclang_rt.tsan_osx_dynamic.dylib:x86_64+0x2f6e6)

From the stack trace it can be seen that the caller is unknown, and the
resulting stack-overflow seems to indicate that whoever the caller is
does not have enough stack space or otherwise is running in a limited
environment not yet ready for full instrumentation.

Fix it by reverting behaviour on Mac OS X to not call BlockingRegion
hooks from pthread_once().

Reported-by: azharudd

Reviewed By: glider

Differential Revision: https://reviews.llvm.org/D108305
2021-08-19 13:17:45 +02:00
Vitaly Buka 03bd05f0e8 [sanitizer] Use TMPDIR in Android test
TMPDIR was added long time ago, so no need to use EXTERNAL_STORAGE.
2021-08-18 19:05:21 -07:00
Vitaly Buka 3d4d1b9b29 [scudo] Don't build SCUDO for Android
Android 11 uses scudo_standalone as default
allocator making difficult to test legacy scudo.
2021-08-18 18:32:54 -07:00
Azharuddin Mohammed b4b8e1446a [tsan] Disable all Trace unit tests on Mac
In an earlier commit (7338be0e6e), only the MemoryAccessSize unit test
was disabled whereas the other tests which are also failing were not.
2021-08-18 11:47:51 -07:00
Mitch Phillips fd51ab6341 [hwasan] Don't report short-granule shadow as overwritten.
The shadow for a short granule is stored in the last byte of the
granule. Currently, if there's a tail-overwrite report (a
buffer-overflow-write in uninstrumented code), we report the shadow byte
as a mismatch against the magic.

Fix this bug by slapping the shadow into the expected value. This also
makes sure that if the uninstrumented WRITE does clobber the shadow
byte, it reports the shadow was actually clobbered as well.

Reviewed By: eugenis, fmayer

Differential Revision: https://reviews.llvm.org/D107938
2021-08-18 11:25:57 -07:00
Jinsong Ji 66e2772e42 [InstrProfiling] Support relative CountersPtr for PlatformOther
D104556 change the CountersPtr to be relative, however, it did not
update the pointer initialization in  __llvm_profile_register_function,
so the platform (eg:AIX) that use __llvm_profile_register_function is now totaly
broken, any PGO code will SEGV.

This patch update the code to reflect that the Data->CountersPtr is now
relative.

Reviewed By: MaskRay, davidxl

Differential Revision: https://reviews.llvm.org/D108304
2021-08-18 17:45:39 +00:00
Alexander Potapenko 7338be0e6e [tsan] Disable Trace.MemoryAccessSize on Mac
According to comments at https://reviews.llvm.org/D107911,
Trace.MemoryAccessSize fails on Mac buildbots.
Because this test is newly introduced, and is the only user of the code
added in that patch, disable the test on Mac till the problem is
resolved.

Differential Revision: https://reviews.llvm.org/D108294
2021-08-18 15:09:36 +02:00
Lang Hames 45ac5f5441 Revert "[ORC-RT][ORC] Introduce ELF/*nix Platform and runtime support."
This reverts commit e256445bff.

This commit broke some of the bots (see e.g.
https://lab.llvm.org/buildbot/#/builders/112/builds/8599). Reverting while I
investigate.
2021-08-18 20:42:23 +10:00
David Spickett 6c7956ea49 [compiler-rt][fuzzer] Explain why fuzzer-flags test is unsupported on AArch64
See https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=4d1c6335455aeeda9de8a5eb58998f919ea35a1e
for the specific change that fixes the issue.
2021-08-18 10:10:19 +00:00
Azharuddin Mohammed 593275c93c Mark tsan cxa_guard_acquire test as unsupported on Darwin
This test started failing after recent commit `636428c727cd`. Marking it
as unsupported to get the bot back to green until we get it sorted out.
2021-08-18 01:44:20 -07:00
Lang Hames e256445bff [ORC-RT][ORC] Introduce ELF/*nix Platform and runtime support.
This change adds support to ORCv2 and the Orc runtime library for static
initializers, C++ static destructors, and exception handler registration for
ELF-based platforms, at present Linux and FreeBSD on x86_64. It is based on the
MachO platform and runtime support introduced in bb5f97e3ad.

Patch by Peter Housel. Thanks very much Peter!

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D108081
2021-08-18 15:00:22 +10:00
Brian Cain f2880329eb [compiler-rt] Add hexagon support to profile
Adds build support for hexagon linux to profile
2021-08-17 19:59:24 -07:00
Brian Cain 065274b9cf [compiler-rt] Add hexagon support to safestack
Adds build support for hexagon linux to safestack.
2021-08-17 19:59:24 -07:00
Brian Cain c172726f6f [compiler-rt] Add hexagon support to CFI
Adds build support for hexagon linux to cfi.
2021-08-17 19:59:24 -07:00
Brian Cain 5b650b1467 [sanitizer] Add hexagon support to scudo
Adds build support for hexagon linux to scudo, scudo-standalone
2021-08-17 19:59:24 -07:00
Brian Cain 217191b70a [sanitizer] Add hexagon support to ubsan
Adds build support for hexagon linux to ubsan.
2021-08-17 19:59:24 -07:00
Brian Cain 043926a3a0 [sanitizer] Add hexagon support to asan
Adds build support for hexagon linux to asan.
2021-08-17 19:59:24 -07:00
Brian Cain 5ac9d41067 [sanitizer] Add hexagon support to lsan
Adds build support for hexagon linux to lsan.
2021-08-17 19:59:24 -07:00
Brian Cain 9ea59e1cd0 [sanitizer] Add hexagon support to sanitizer-common
Adds build support for hexagon linux to sanitizer common.
2021-08-17 19:59:24 -07:00
Evgenii Stepanov 8a570a873b [hwasan] Support malloc in atfork.
Before this change we were locking the StackDepot in the fork()
interceptor. This results in a deadlock when allocator functions are
used in a pthread_atfork() callback.

Instead, set up a pthread_atfork() callback at init that locks/unlocks
both StackDepot and the allocator. Since our callback is set up very
early, the pre-fork callback is executed late, and both post-fork ones
are executed early, which works perfect for us.

Differential Revision: https://reviews.llvm.org/D108063
2021-08-17 15:29:49 -07:00
Evgenii Stepanov c9ce76febb (NFC) clang-format hwasan/hwasan_linux.cpp
Differential Revision: https://reviews.llvm.org/D108224
2021-08-17 15:03:46 -07:00
Martin Storsjö 18e06e3e2f [sanitizers] Fix building on 32 bit Windows after 7256c05ecb
On 32 bit, 'long' (which is 32 bit on Windows) is used as base
type for SIZE_T and similar.

Differential Revision: https://reviews.llvm.org/D108191
2021-08-17 21:36:09 +03:00
Marco Elver f3b3c964c3 Revert "[tsan] Fix GCC 8.3 build after D107911"
This reverts commit 797fe59e6b.

The use of "EventType type : 3" is replicated for all Event structs and
therefore was still present. As a result this still caused failures on
older GCCs (9.2 or 8.3 or earlier).

The particular bot that was failing due to buggy GCC was fixed by
fef39cc472.

Therefore, no reason to keep the workaround around; revert it.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D108192
2021-08-17 19:26:20 +02:00
Peter Collingbourne affb132ab8 hwasan: Move stack ring buffer initialization before InitStackAndTls.
D104248 moved the call to GetThreadStackAndTls to before the
initialization of the ring buffer TLS slot. As a result, if libc
is instrumented we crash in pthread_getattr_np which is called from
__sanitizer::GetThreadStackTopAndBottom.

Fix the problem by moving the stack ring buffer initialization before
the call to InitStackAndTls.

Differential Revision: https://reviews.llvm.org/D108184
2021-08-17 10:18:07 -07:00
Kostya Kortchinsky 5009be2f09 [scudo] Fix format string specifiers
Enable `-Wformat` again, and fix the offending instances.

Differential Revision: https://reviews.llvm.org/D108168
2021-08-17 08:37:49 -07:00
Marco Elver d2b574a4de tsan: test: Initialize all fields of Params struct
Some compilers started complaining about the test:

	tsan_trace_test.cpp:128:21: error: missing field 'type' initializer

Fix it by initializing all 5 fields, even though the type field will be
reset in the for loop.

Differential Revision: https://reviews.llvm.org/D108207
2021-08-17 16:58:00 +02:00
Douglas Yung fef39cc472 [tsan] Another attempt to fix GCC 8.3 build after D107911
This removes the -Werror compilation flag for x64 linux to work around a gcc bug.

GCC 8.3 reports '__tsan::v3::Event::type’ is too small to hold all values of ‘enum class __tsan::v3::EventType’
incorrectly which gets promoted to an error and causes the build to fail.
2021-08-16 17:01:57 -07:00
Vitaly Buka 797fe59e6b [tsan] Fix GCC 8.3 build after D107911
gcc 8.3 reports:
__tsan::v3::Event::type’ is too small to hold all values of ‘enum class __tsan::v3::EventType’
2021-08-16 16:18:42 -07:00
Vitaly Buka 7256c05ecb [sanitizer] Define 32bit uptr as uint
This makes it consistent with uintptr_t.

It's 45138f788c with Darwin fix.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D108163
2021-08-16 15:46:37 -07:00
Vitaly Buka 3a05af12b3 Revert "[sanitizer] Fix MAC build after D108163"
They still fail to fix Darwin builds
https://green.lab.llvm.org/green/job/clang-stage1-RA/23399/consoleFull#462858634a1ca8a51-895e-46c6-af87-ce24fa4cd561

This reverts commit ae0628f716.
This reverts commit 2c6448cdc2.
2021-08-16 15:46:37 -07:00
Vitaly Buka ae0628f716 [sanitizer] Fix MAC build after D108163 2021-08-16 15:22:55 -07:00
Kostya Kortchinsky b2aaafb837 [scudo] Use stdint types for internal types (redo)
This is a redo of D108089 that broke some 32-bit builds.

`scudo::uptr` was defined as an `unsigned long` on 32-b platform,
while a `uintptr_t` is usually defined as an `unsigned int`.
This worked, this was not consistent, particularly with regard to
format string specifiers.

As suggested by Vitaly, since we are including `stdint.h`, define
the internal scudo integer types to those.

Differential Revision: https://reviews.llvm.org/D108152
2021-08-16 14:46:42 -07:00
Vitaly Buka 2c6448cdc2 [sanitizer] Define 32bit uptr as uint
This makes it consistent with uintptr_t.

It's 45138f788c with Darwin fix.

Reviewed By: kstoimenov

Differential Revision: https://reviews.llvm.org/D108163
2021-08-16 14:23:45 -07:00
Evgenii Stepanov 8c23669eeb [hwasan] Ignore lit config.enable_aliases on non-x86.
This re-enables a number of Android tests that have been lost in
check-hwasan.

Differential Revision: https://reviews.llvm.org/D108064
2021-08-16 13:29:37 -07:00
Gulfem Savrun Yeniceri 6c0e6f91d7 [profile] Add static keyword to binary id functions
This patch adds static keyword to internal functions that write
binary id to restrict visibility to the file that they are declared.

Differential Revision: https://reviews.llvm.org/D108154
2021-08-16 19:36:47 +00:00
Rong Xu 9b8425e42c Reapply commit b7425e956
The commit b7425e956: [NFC] fix typos
is harmless but was reverted by accident. Reapply.
2021-08-16 12:18:40 -07:00
Kostya Kortchinsky 427c9aa7c4 Revert "[scudo] Use stdint types for internal scudo types"
This reverts commit 5fc841d8a2.
2021-08-16 11:13:48 -07:00
Kostya Kortchinsky 80ed75e7fb Revert "[NFC] Fix typos"
This reverts commit b7425e956b.
2021-08-16 11:13:05 -07:00
Kostya Kortchinsky 5fc841d8a2 [scudo] Use stdint types for internal scudo types
`scudo::uptr` was defined as an `unsigned long` on 32-b platform,
while a `uintptr_t` is usually defined as an `unsigned int`.
This worked, this was not consistent, particularly with regard to
format string specifiers.

As suggested by Vitaly, since we are including `stdint.h`, define
the internal `scudo` integer types to those.

Differential Revision: https://reviews.llvm.org/D108089
2021-08-16 10:52:56 -07:00
Rong Xu b7425e956b [NFC] Fix typos
s/senstive/senstive/g
2021-08-16 10:15:30 -07:00
Nikita Popov 4cfb047d6a [profile] Don't use pragma comment linker on mingw
At least when compiling with gcc, this is not supported and will
result in errors when linking against the profiler runtime. Only
use the pragma comment linker based code with MSVC, but not with
a mingw toolchain. This also undoes D107620, which shouldn't be
relevant anymore.

Differential Revision: https://reviews.llvm.org/D108095
2021-08-16 18:20:32 +02:00