Commit Graph

11997 Commits

Author SHA1 Message Date
Vitaly Buka 36bdec44a2 [NFC][tsan] Use AddThread(Tid tid... 2022-08-17 13:53:13 -07:00
Maxim Schessler aa0e9046c1 Libfuzzer fix for Ctrl + c not working with -fork and -ignore_crashes=1
In some cases running Libfuzzer in fork mode with -ignore_crashes=1 counts ctrl+c as crash and restarts.

Thread: https://github.com/google/oss-fuzz/issues/4547

Credit: Marcel Boehme <marcel.boehme@acm.org>

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130990
2022-08-16 16:45:39 -07:00
Nico Weber f56e486fdc [gn build] Make ubsan_init_standalone_preinit.cpp syncable
...after https://reviews.llvm.org/D131916
2022-08-15 18:17:06 -04:00
Kevin Athey c22841049e [MSAN] clean up style from D131728
Depends on D131728

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131903
2022-08-15 11:46:07 -07:00
Martin Storsjö 156136502b [ORC_RT][COFF] Fix cross compilation with mingw headers
Mingw headers are all lowercase, and can be used for cross compilation
from case sensitive file systems.

The official Windows SDK headers aren't self-consistent wrt upper/lower
case, so those headers can't be used on case sensitive systems without
a layer providing case insensitivity anyway.

This matches other includes of windows.h throughout the codebase.
2022-08-14 14:23:25 +03:00
Kazu Hirata 062f157c7f Ensure newlines at the end of files (NFC) 2022-08-13 12:55:45 -07:00
Sunho Kim 9189a26664 [ORC_RT][COFF] Initial platform support for COFF/x86_64.
Initial platform support for COFF/x86_64.

Completed features:
* Statically linked orc runtime.
* Full linking/initialization of static/dynamic vc runtimes and microsoft stl libraries.
* SEH exception handling.
* Full static initializers support
* dlfns
* JIT side symbol lookup/dispatch

Things to note:
* It uses vc runtime libraries found in vc toolchain installations.
* Bootstrapping state is separated because when statically linking orc runtime it needs microsoft stl functions to initialize the orc runtime, but static initializers need to be ran in order to fully initialize stl libraries.
* Process symbols can't be used blidnly on msvc platform; otherwise duplicate definition error gets generated. If process symbols are used, it's destined to get out-of-reach error at some point.
* Atexit currently not handled -- will be handled in the follow-up patches.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D130479
2022-08-13 13:48:40 +09:00
Vitaly Buka 4b33ea052a [sanitizer] Add dn_comp interceptor
Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D129247
2022-08-12 16:57:49 -07:00
Kevin Athey 532564de17 [MSAN] add flag to suppress storage of stack variable names with -sanitize-memory-track-origins
Allows for even more savings in the binary image while simultaneously removing the name of the offending stack variable.

Depends on D131631

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131728
2022-08-12 11:59:53 -07:00
Kevin Athey ec277b67eb [MSAN] Separate id ptr from constant string for variable names used in track origins.
The goal is to reduce the size of the MSAN with track origins binary, by making
the variable name locations constant which will allow the linker to compress
them.

Follows: https://reviews.llvm.org/D131415

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131631
2022-08-12 08:47:36 -07:00
Kevin Athey 4735104f09 [MSAN] remove unused debugging statements (NFC)
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131748
2022-08-11 20:24:34 -07:00
Vitaly Buka aca1276160 [msan] Avoid unnecessary PC increment/decrement
Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D131692
2022-08-11 14:29:07 -07:00
Vitaly Buka 4248f32b9e [NFC][sanitizer] Use __builtin_extract_return_addr on all platforms
On most platforms it does nothing, so this eliminates a need for one #if.
2022-08-11 09:48:29 -07:00
Vitaly Buka e41c5aaebe [NFC][sanitizer] Add () into a few macros 2022-08-11 09:48:28 -07:00
Vitaly Buka af77e5e4c0 [msan] Extract SetAllocaOrigin 2022-08-10 20:53:02 -07:00
Vitaly Buka d1040c455f [msan] Another try for powerpc fix after D131205 2022-08-10 20:39:25 -07:00
Vitaly Buka 05b3374925 [msan] Try to fix powerpc after D131205 2022-08-10 19:28:30 -07:00
Phoebe Wang f061cfb317 [compiler-rt][BF16] Provide __truncdfbf2 and __truncsfbf2 only when __bf16 is available
Differential Revision: https://reviews.llvm.org/D131147
2022-08-11 09:20:08 +08:00
Kevin Athey 057cabd997 Remove function name from sanitize-memory-track-origins binary.
This work is being done to reduce the size of MSAN with track origins binary.

Builds upon: https://reviews.llvm.org/D131205

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131415
2022-08-10 15:45:40 -07:00
Kevin Athey d7a47a9bb5 Desist from passing function location to __msan_set_alloca_origin4.
This is done by calling __msan_set_alloca_origin and providing the location of the variable by using the call stack.
This is prepatory work for dropping variable names when track-origins is enabled.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D131205
2022-08-10 09:02:53 -07:00
Phoebe Wang 800d5e178f Revert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""
This reverts commit 0729d00135.

Buildbot https://lab.llvm.org/buildbot/#/builders/19/builds/11989 failed
with "error: ISO C requires a translation unit to contain at least one declaration [-Werror,-Wempty-translation-unit]"
2022-08-10 17:27:44 +08:00
Fangrui Song 0e08061229 tsan: update Go rules to use -std=c++17
llvm-project has switched to require C++17.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D131536
2022-08-10 00:32:40 -07:00
Phoebe Wang 0729d00135 Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
Disable the build on macOS due to the bot fail.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D131147
2022-08-10 13:27:21 +08:00
Med Ismail Bennani 5990cf3806 Revert "Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available""
This reverts commit ab4e5ed441 since it
causes a build failure on macOS:

https://green.lab.llvm.org/green/job/lldb-cmake/45984/
2022-08-09 21:45:21 -07:00
Phoebe Wang ab4e5ed441 Reland "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
Fix the mising change for truncdfbf2.c

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D131147
2022-08-10 10:22:15 +08:00
Phoebe Wang 00c0a34f6c Revert "[compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available"
This reverts commit 0ae2a41d80.

Revert due to buildbot fail.
2022-08-10 10:05:12 +08:00
Vitaly Buka 4a87afe25f
[sanitizer] Let internal symbolizer to use posix_memalign 2022-08-09 18:44:00 -07:00
Phoebe Wang 0ae2a41d80 [compiler-rt][BF16] Provide __truncsfbf2 only when __bf16 is available
#56854 shows a backwards compatibility problem when builtins of compiler-rt don't follow ABI. We need to prevent to fall into the trap again for BF16.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D131147
2022-08-10 09:13:44 +08:00
Evgenii Stepanov cf1d9a1fdc [sanitizer] Use C++17 to build the symbolizer. 2022-08-09 15:33:03 -07:00
Vitaly Buka ea42515dad [asan] Faster version of QuickCheckForUnpoisonedRegion
Slightly helps with performance regression after D128146.
2022-08-08 22:07:35 -07:00
Vitaly Buka 03e345b519 [asan] Avoid few branches on memcpy hot path 2022-08-08 19:20:06 -07:00
Vitaly Buka 341ee9c029 [NFC][asan] Fix Condition annotation after 30bbb73bb4 2022-08-08 19:20:06 -07:00
Fangrui Song 474145c0b2 [CMake] Build lib/gwp_asan/tests with -std=c++17
With the recent llvm-project C++17 switch (D130689), gwp_asan/tests may fail to
link with some versions of GCC (https://github.com/llvm/llvm-project/issues/56994):

> backtrace.cpp:(.text+0xca6): undefined reference to `gwp_asan::AllocationMetadata::kMaxTraceLengthToCollect'

I cannot reproduce this issue by myself, but notice that currently
lib/gwp_asan/*.cpp get -std=c++17 while lib/gwp_asan/tests/*.cpp don't
(therefore may use -std=g++14 default from Clang and older GCC). Using -std=c++17
for lib/gwp_asan/tests will ensure that backtrace.cpp uses inline variable and will assuredly avoid the
possible GCC issue.

In the long-term, we should add -std=c++17 to a central place like generate_compiler_rt_tests.

Reviewed By: dyung

Differential Revision: https://reviews.llvm.org/D131440
2022-08-08 17:51:17 -07:00
Vitaly Buka 30bbb73bb4 [NFC][asan] Add LIKELY/UNLIKELY on hot memcpy paths 2022-08-08 16:25:56 -07:00
Vitaly Buka 67c06c4731 [NFC][asan] Clang-format a file 2022-08-08 16:21:35 -07:00
Diana Picus 8342ea6eac [scudo] Try to fix standalone build on armv7
When linking scudo standalone on armv7, it can't find symbols related to
unwinding (e.g. __aeabi_unwind_cpp_pr0). This is because it is passing
--unwindlib=none. This patch hacks around the issue by adding
COMPILER_RT_UNWINDER_LINK_LIBS to the link line.

I don't know anything about scudo, so I'm not sure what the original
intention was.

See also https://github.com/llvm/llvm-project/issues/56900

Differential Revision: https://reviews.llvm.org/D131250
2022-08-08 10:19:12 +02:00
luxufan ace6e172bd [RISCV] Support fe_getround and fe_raise_inexact in builtins
Reviewed By: luismarques

Differential Revision: https://reviews.llvm.org/D128240
2022-08-08 09:58:27 +08:00
Lang Hames 608131b1f9 [ORC-RT] Fix missing #include <string_view>s.
1dcff823db updated the ORC runtime to use std::string_view, rather than its
own placeholder class (__orc_rt::string_view), but failed to add these
includes.
2022-08-07 14:32:28 -07:00
Lang Hames aa2a3196e2 [ORC-RT] Remove a stray __orc_rt::string_view helper.
This function was accidentally left in after 1dcff823db.
2022-08-07 11:23:09 -07:00
Lang Hames 1dcff823db [ORC-RT] Drop __orc_rt::string_view now that we have c++17.
b1356504e6 enabled the use of c++17 features in LLVM, which means that we can
drop the ORC runtime's placeholder string_view implemention in favor of
std::string_view.
2022-08-07 09:37:09 -07:00
Keith Smiley 9ec4ddd224
[Sanitizer][Darwin] Support OS versions before DRIVERKIT
Fixes https://github.com/llvm/llvm-project/issues/56960

Differential Revision: https://reviews.llvm.org/D131288
2022-08-05 15:39:05 -07:00
Florian Mayer 29ff262761 [HWASan] Remove incorrect unreachable.
This function could be called wih access_info & 0x20 or with
flags()->halt_on_error, in which case HandleTagMismatch returns (is not
fatal).

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D131279
2022-08-05 13:14:08 -07:00
Than McIntosh 24a62bfe9a tsan: fix bug in shadow reset introduced in D128909
Correct a bug in the code that resets shadow memory introduced as part
of a previous change for the Go race detector (D128909). The bug was
that only the most recently added shadow segment was being reset, as
opposed to the entire extent of the segment created so far. This
fixes a bug identified in Google internal testing (b/240733951).

Differential Revision: https://reviews.llvm.org/D131256
2022-08-05 11:36:58 -04:00
Nikita Popov 542977d438 Revert "[compiler-rt][CMake] Enable TF intrinsics on powerpc32 Linux"
As mentioned in https://reviews.llvm.org/D121379#3690593, this
change broke the build of compiler-rt targeting powerpc using GCC.
The 32-bit powerpc target is not supposed to emit 128-bit libcalls
-- if it does, then that's a backend bug and needs to be fixed there.

This reverts commit 8f24a56a3a.

Differential Revision: https://reviews.llvm.org/D130988
2022-08-05 16:43:44 +02:00
Ben Langmuir adea1fa047 [orc-rt] Fix swift protocol metadata registration
The __swif5_proto and __swift5_protos sections had their meaning
inverted. Fix, and rename the arrays so it is more obvious which is
which.

Differential Revision: https://reviews.llvm.org/D131206
2022-08-04 14:55:24 -07:00
Fangrui Song 71e8f79601 [ubsan] Make TypeCheckKinds const. NFC
Move it from .data to .data.rel.ro
2022-08-03 11:02:22 -07:00
Phoebe Wang b17c89d151 Revert "[compiler-rt] [builtins] Detect _Float16 support at compile time"
This reverts commit ce6d40f5c2.

Revert due to it broke the sanitizer-windows buildbot: https://lab.llvm.org/buildbot/#/builders/127/builds/33583/steps/4/logs/stdio
2022-07-30 09:41:33 +08:00
Dimitry Andric ce6d40f5c2 [compiler-rt] [builtins] Detect _Float16 support at compile time
Instead of detecting `_Float16` support at CMake configuration time,
detect it at compile time by checking for the predefined (by the
compiler) macro `__FLT16_MAX__` instead.

This solves the issue where compiler-rt is built simultaneously for both
x86_64 and i386 targets, and the CMake configuration uses x86_64
compilation to detect `_Float16` support, while it may not be supported
by the i386 target (if it does not have SSE2).

While here, rename `COMPILERT_RT_HAS_FLOAT16` to `CRT_HAS_FLOAT16`, to
conform more to the naming style used in `int_lib.h` and `int_types.h`.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D130718
2022-07-29 20:58:52 +02:00
Than McIntosh b6374437af tsan: capture shadow map start/end on init and reuse in reset
Capture the computed shadow begin/end values at the point where the
shadow is first created and reuse those values on reset. Introduce new
windows-specific function "ZeroMmapFixedRegion" for zeroing out an
address space region previously returned by one of the MmapFixed*
routines; call this function (on windows) from DoResetImpl
tsan_rtl.cpp instead of MmapFixedSuperNoReserve.

See https://github.com/golang/go/issues/53539#issuecomment-1168778740
for context; intended to help with updating the syso for Go's
windows/amd64 race detector.

Differential Revision: https://reviews.llvm.org/D128909
2022-07-26 10:04:39 -04:00
Dmitry Vyukov 7ec308715c tsan: prevent pathological slowdown for spurious races
Prevent the following pathological behavior:
Since memory access handling is not synchronized with DoReset,
a thread running concurrently with DoReset can leave a bogus shadow value
that will be later falsely detected as a race. For such false races
RestoreStack will return false and we will not report it.
However, consider that a thread leaves a whole lot of such bogus values
and these values are later read by a whole lot of threads.
This will cause massive amounts of ReportRace calls and lots of
serialization. In very pathological cases the resulting slowdown
can be >100x. This is very unlikely, but it was presumably observed
in practice: https://github.com/google/sanitizers/issues/1552
If this happens, previous access sid+epoch will be the same for all of
these false races b/c if the thread will try to increment epoch, it will
notice that DoReset has happened and will stop producing bogus shadow
values. So, last_spurious_race is used to remember the last sid+epoch
for which RestoreStack returned false. Then it is used to filter out
races with the same sid+epoch very early and quickly.
It is of course possible that multiple threads left multiple bogus shadow
values and all of them are read by lots of threads at the same time.
In such case last_spurious_race will only be able to deduplicate a few
races from one thread, then few from another and so on. An alternative
would be to hold an array of such sid+epoch, but we consider such scenario
as even less likely.
Note: this can lead to some rare false negatives as well:
1. When a legit access with the same sid+epoch participates in a race
as the "previous" memory access, it will be wrongly filtered out.
2. When RestoreStack returns false for a legit memory access because it
was already evicted from the thread trace, we will still remember it in
last_spurious_race. Then if there is another racing memory access from
the same thread that happened in the same epoch, but was stored in the
next thread trace part (which is still preserved in the thread trace),
we will also wrongly filter it out while RestoreStack would actually
succeed for that second memory access.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D130269
2022-07-25 10:40:11 +02:00