Commit Graph

10846 Commits

Author SHA1 Message Date
Kamil Rytarowski 0ef090cad1 Mark test/tsan/getline_nohang as XFAIL for NetBSD
llvm-svn: 345493
2018-10-29 09:44:42 +00:00
Kamil Rytarowski 43d1653fc0 Disable the GNU strerror_r TSan test for NetBSD
Revert older change that was incorrect in this test.
It was already reverted in the past after an attempt to port it to Darwin.

While there, mark FreeBSD as unsupported as well.

llvm-svn: 345492
2018-10-29 09:12:38 +00:00
Kamil Rytarowski 5267698376 Mark test/tsan/ignore_lib5 as unsupported for NetBSD
ReadProcMaps() on NetBSD does not handle >=1MB of memory layout information.

llvm-svn: 345490
2018-10-29 08:42:46 +00:00
Dean Michael Berris e01d25efbd [XRay] Guard call to postCurrentThreadFCT()
Summary:
Some cases where `postCurrentThreadFCT()` are not guarded by our
recursion guard. We've observed that sometimes these can lead to
deadlocks when some functions (like memcpy()) gets outlined and the
version of memcpy is XRay-instrumented, which can be materialised by the
compiler in the implementation of lower-level components used by the
profiling runtime.

This change ensures that all calls to `postCurrentThreadFCT` are guarded
by our thread-recursion guard, to prevent deadlocks.

Reviewers: mboerger, eizan

Subscribers: llvm-commits

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

llvm-svn: 345489
2018-10-29 05:39:43 +00:00
Dean Michael Berris 36d9746630 [XRay] Use more portable control block
Summary:
In D53560, we assumed a specific layout for memory without using an
explicit structure. This follow-up change uses more portable layout
control by using unions in a struct, and consolidating the memory
management code in the buffer queue.

We also take the opportunity to improve the documentation on the types
and operations, along with simplifying some of the logic in the buffer
queue implementation.

Reviewers: mboerger, eizan

Subscribers: jfb, llvm-commits

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

llvm-svn: 345485
2018-10-29 02:18:14 +00:00
Dean Michael Berris 299e9b8be0 [XRay] Refcount backing store for buffers
Summary:
This change implements the ref-counting for backing stores associated
with generational buffer management. We do this as an implementation
detail of the buffer queue, instead of exposing this to the interface.

This change allows us to keep the buffer queue interface and usage model
the same.

Depends on D53551.

Reviewers: mboerger, eizan

Subscribers: jfb, llvm-commits

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

llvm-svn: 345471
2018-10-28 09:12:43 +00:00
Dean Michael Berris 18024786b9 [XRay] Support generational buffers in FDR controller
Summary:
This is an intermediary step in the full support for generational buffer
management in the FDR runtime. This change makes the FDR controller
aware of the new generation number in the buffers handed out by the
BufferQueue type.

In the process of making this change, we've realised that the cleanest
way of ensuring that the backing store per generation is live while all
the threads that need access to it will need reference counting to tie
the backing store to the lifetime of all threads that have a handle on
buffers associated with the memory.

We also learn that we're missing the edge-case in the function exit
handler's implementation where the first record being written into the
buffer is a function exit, which is caught/fixed by the test for
generational buffer management.

We still haven't wired the controller into the FDR mode runtime, which
will need the reference counting on the backing store implemented to
ensure that we're being conservatively thread-safe with this approach.

Depends on D52974.

Reviewers: mboerger, eizan

Subscribers: llvm-commits

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

llvm-svn: 345445
2018-10-27 03:00:21 +00:00
Kuba Mracek 117360cc24 [sanitizer] Improve macOS version detection
Part of <https://reviews.llvm.org/D48445>.

llvm-svn: 345406
2018-10-26 17:19:41 +00:00
Evgeniy Stepanov f4a6f6424d [sanitizer] Fix mallopt test on Android.
There is not a single common mallopt option between gnu/linux and
android, so simply use a random number there.

llvm-svn: 345394
2018-10-26 15:13:20 +00:00
Evgeniy Stepanov ea857e8225 [sanitizer] Fix mallopt interceptor.
On error, mallopt is supposed to return 0, not -1.

llvm-svn: 345323
2018-10-25 22:15:44 +00:00
Kuba Mracek 6b6d9bbd48 [sanitizer] Avoid calling a nullptr in MonotonicNanoTime if interceptors are not yet initialized
There's a TSan startup crash on Linux when used in Swift programs, where MonotonicNanoTime will try to call real_clock_gettime and then jump to NULL because interceptors are not yet initialized. This is on Ubuntu 18.04. Looks like TSan's main Initialize() function is called at a point where __progname is already set, but interceptors aren't yet set up. Let's fix this by checking whether interceptors are initialized in MonotonicNanoTime.

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

llvm-svn: 345174
2018-10-24 18:40:08 +00:00
Kostya Serebryany ad11526c30 [hwasan] when printing a stack-related bugs, also print stack frame descriptions provided by the compiler
llvm-svn: 345110
2018-10-24 01:35:50 +00:00
Kostya Serebryany af95597c3c [hwasan] add stack frame descriptions.
Summary:
At compile-time, create an array of {PC,HumanReadableStackFrameDescription}
for every function that has an instrumented frame, and pass this array
to the run-time at the module-init time.
Similar to how we handle pc-table in SanitizerCoverage.
The run-time is dummy, will add the actual logic in later commits.

Reviewers: morehouse, eugenis

Reviewed By: eugenis

Subscribers: srhines, llvm-commits, kubamracek

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

llvm-svn: 344985
2018-10-23 00:50:40 +00:00
Kuba Mracek 975352c0b1 [interception] Switch to _type suffix instead of _f, NFC.
Some Darwin functions have pairs like dispatch_apply and dispatch_apply_f so the added _f to interceptor types causes a clash. Let's add _type suffix instead.

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

llvm-svn: 344954
2018-10-22 20:54:48 +00:00
Dean Michael Berris 2336dc3c51 [XRay] Account for virtual memory re-use
Change the assumption when releasing memory to a buffer queue that new
generations might not be able to re-use the memory mapped addresses.

llvm-svn: 344882
2018-10-22 06:11:50 +00:00
Dean Michael Berris 788b17ca78 [XRay][compiler-rt] Generational Buffer Management
Summary:
This change updates the buffer queue implementation to support using a
generation number to identify the lifetime of buffers. This first part
introduces the notion of the generation number, without changing the way
we handle the buffers yet.

What's missing here is the cleanup of the buffers. Ideally we'll keep
the two most recent generations. We need to ensure that before we do any
writes to the buffers, that we check the generation number(s) first.

Those changes will follow-on from this change.

Depends on D52588.

Reviewers: mboerger, eizan

Subscribers: llvm-commits, jfb

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

llvm-svn: 344881
2018-10-22 04:53:58 +00:00
Dean Michael Berris ebfbf89000 [XRay] Handle allocator exhaustion in segmented array
Summary:
This change allows us to handle allocator exhaustion properly in the
segmented array implementation. Before this change, we relied on the
caller of the `trim` function to provide a valid number of elements to
trim. This change allows us to do the right thing in case the elements
to trim is greater than the size of the container.

Reviewers: mboerger, eizan

Subscribers: llvm-commits

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

llvm-svn: 344880
2018-10-22 02:11:27 +00:00
David Carlier cea5db8302 [Sanitizer] openbsd does not have sysctlbyname call
Enabling only for FreeBSD.

Reviewers: krytarowski, vitalybuka

Reviewed By: krytarowski

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

llvm-svn: 344876
2018-10-21 21:17:03 +00:00
Craig Topper 3fe6470951 [X86][compiler-rt] Add additional CPUs and features to the cpu detection to match libgcc
Summary: This patch adds additional features and cpus from libgcc. Unfortunately we've overflowed the existing 32-bits of features so we had to add a new __cpu_features2 variable to hold the additional bits. This matches libgcc as far as I can tell.

Reviewers: echristo

Reviewed By: echristo

Subscribers: dberris, llvm-commits

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

llvm-svn: 344830
2018-10-20 03:49:04 +00:00
Douglas Yung e61c8eb98f Revert commit r344670 as the test fails on a bot http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/2683/.
llvm-svn: 344771
2018-10-19 04:09:32 +00:00
Dan Albert 98a6692380 [compiler-rt] Don't explicitly set CMAKE_CXX_FLAGS.
Summary:
C++ flags should not be used for not-C++ files as it may trigger
-Werror=unused-command-line-argument. CMake will use CMAKE_C_FLAGS,
CMAKE_CXX_FLAGS, and CMAKE_ASM_FLAGS as appropriate implicitly, so
this does not need to be explicitly handled here.

This change depends on https://reviews.llvm.org/D53301, since one of
the builders depended on this behavior because it was not configuring
CMAKE_ASM_FLAGS.

Reviewers: eugenis, vitalybuka

Reviewed By: eugenis, vitalybuka

Subscribers: dberris, mgorny, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 344751
2018-10-18 18:04:28 +00:00
Dean Michael Berris e85af163bc [XRay][compiler-rt] Generational Buffer Management
Summary:
This change updates the buffer queue implementation to support using a
generation number to identify the lifetime of buffers. This first part
introduces the notion of the generation number, without changing the way
we handle the buffers yet.

What's missing here is the cleanup of the buffers. Ideally we'll keep
the two most recent generations. We need to ensure that before we do any
writes to the buffers, that we check the generation number(s) first.

Those changes will follow-on from this change.

Depends on D52588.

Reviewers: mboerger, eizan

Subscribers: llvm-commits, jfb

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

llvm-svn: 344670
2018-10-17 06:57:50 +00:00
Petr Hosek 4886652773 [XRay] Use fully qualified name for LogWriter
This avoids the build error in newer versions of GCC.

llvm-svn: 344579
2018-10-16 02:06:08 +00:00
Petr Hosek 6a8cedef25 [XRay] Encapsulate all FD log related logic into a class
This abstracts away the file descriptor related logic which makes it
easier to port XRay to platform that don't use file descriptors or
file system for writing the log data, such as Fuchsia.

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

llvm-svn: 344578
2018-10-16 01:24:46 +00:00
Dean Michael Berris 3c01508409 [XRay][compiler-rt] FDR Mode Controller
Summary:
This change implements a controller for abstracting away the details of
what happens when tracing with FDR mode. This controller type allows us
to test in isolation the various cases where we're encountering function
entry, exit, and other kinds of events we are handling when FDR mode is
enabled.

This change introduces a number of testing facilities we've needed to
better support expressing the conditions we need for the unit tests. We
leave some TODOs for moving those utilities into the LLVM project,
sitting in the `Testing` library, to make matching conditions on XRay
`Trace` instances through googlemock more manageable and declarative.

We don't wire in the controller right away, to allow us to incrementally
update the implementation(s) as we increase testing coverage of the
controller type. There's a need to re-think the way we're managing
buffers in a multi-threaded environment, which is more invasive than
this implementation.

This step in the process allows us to encode our assumptions in the
implementation of the controller, and then evolve the buffer queue
implementation to support generational buffer management to ensure we
can continue to support the cases we're already supporting with the
controller.

Reviewers: mboerger, eizan

Subscribers: mgorny, llvm-commits, jfb

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

llvm-svn: 344488
2018-10-15 02:57:06 +00:00
Jonathan Metzman 9d0f3206ce [libfuzzer][Windows] Silence linker warning in unittest
Summary:
Silence warning when linking unittest binary by not passing
-lstdc++ to the linker since it is ignored.

Reviewers: morehouse

Reviewed By: morehouse

Subscribers: mgorny

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

llvm-svn: 344480
2018-10-14 17:07:40 +00:00
Dan Liew 74c6aaf81c [lit] Support the `%shared_libasan` lit substitution on Apple platforms.
Summary:
The previous value looks Linux specific so that has been guarded with
the host OS being Linux.

On Apple platforms `%shared_libasan` expands to the absolute path of the
ASan dylib.

Previously on Linux `%shared_libasan` expanded to just the file name
of the shared library rather than the absolute path to the library.
This is likely a bug because it would rely on the OS's dynamic linker
to find the shared library which could accidentally pick up a system copy
rather than the shared library that was just built.

For other platforms we emit a warning if `config.asan_dynamic` is true.

This patch also only defines the substitution when `config.asan_dynamic`
is true because using this substitution only makes sense when the
dynamic library is available.

Reviewers: kubamracek, george.karpenkov, mgorny, phosek, etienneb, samsonov, kcc

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 344434
2018-10-12 23:36:23 +00:00
Evgeniy Stepanov 9ab897dcb5 [sanitizer] Avoid extra newlines in syslog.
Fix line splitting logic to avoid sending empty lines to syslog, as
that adds extra newlines.

llvm-svn: 344426
2018-10-12 22:07:54 +00:00
Jonathan Metzman 0b94e88007 [SanitizerCoverage] Prevent /OPT:REF from stripping constructors
Summary:
Linking with the /OPT:REF linker flag when building COFF files causes
the linker to strip SanitizerCoverage's constructors. Prevent this by
giving the constructors WeakODR linkage and by passing the linker a
directive to include sancov.module_ctor.

Include a test in compiler-rt to verify libFuzzer can be linked using
/OPT:REF

Reviewers: morehouse, rnk

Reviewed By: morehouse, rnk

Subscribers: rnk, morehouse, hiraditya

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

llvm-svn: 344391
2018-10-12 18:11:47 +00:00
Max Moroz 6cbb3ca456 [libFuzzer] Add test for SanitizerCoverage working on Mac even with -Wl,-dead_strip.
Summary:
The corresponding asncov change: https://reviews.llvm.org/D53113.

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=892167

Reviewers: morehouse, kcc, george.karpenkov

Reviewed By: morehouse, george.karpenkov

Subscribers: delcypher, #sanitizers, llvm-commits

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

llvm-svn: 344346
2018-10-12 13:59:56 +00:00
Arnaud A. de Grandmaison b07b5a4115 [TSan] Cleanup TSan runtime support for Go on linux-aarch64. NFC.
This is a follow-up patch to r342541. After further investigations, only
48bits VMA size can be supported. As this is enforced in function
InitializePlatformEarly from lib/rt1/tsan_platform_linux.cc, the access
to the global variable vmaSize variable + switch can be removed. This
also addresses a comment from https://reviews.llvm.org/D52167.

vmaSize of 39 or 42bits are not compatible with a Go program memory
layout as the Go heap will not fit in the shadow memory area.

Patch by: Fangming Fang <Fangming.Fang@arm.com>

llvm-svn: 344329
2018-10-12 10:01:09 +00:00
Dan Liew d11aae5db5 Fix bug where `config.asan_dynamic` in generated ASan `lit.site.cfg` files was set to `False` for macOS.
`config.asan_dynamic` should actually be `True` because dylibs are the
only supported form of the ASan runtime on Apple platforms.

Reviewers: kubamracek, george.karpenkov, samsonov

Subscribers: srhines, mgorny, #sanitizers, llvm-commits

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

llvm-svn: 344324
2018-10-12 02:36:19 +00:00
Kostya Serebryany 0cb8710e11 [hwasan] relax a test
llvm-svn: 344289
2018-10-11 20:29:00 +00:00
Roman Lebedev d32c0d1466 [compiler-rt][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks
Summary:
This is compiler-rt part.
clang part is D50901.

Reviewers: rsmith, vsk, filcab, Sanitizers

Reviewed by: filcab

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

llvm-svn: 344231
2018-10-11 09:09:52 +00:00
Calixte Denizet 589fff9c71 [profile] Fix the gcov tests after the patch in D49853 landed.
Summary:
The goal of the patch in D49853 is to display counter on the line of function definition.
So some tests need to be fixed.

Reviewers: marco-c, davidxl

Reviewed By: marco-c

Subscribers: sylvestre.ledru, delcypher, llvm-commits, #sanitizers

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

llvm-svn: 344229
2018-10-11 08:53:55 +00:00
Kostya Serebryany 3d3d9d69fb [hwasan] extend the stack-uar test
llvm-svn: 344213
2018-10-11 01:05:18 +00:00
Kostya Serebryany dac7b2abaf [hwasan] more compact printing for 'Previosly allocated frames'
llvm-svn: 344210
2018-10-11 00:34:20 +00:00
Kostya Serebryany 7b2b0185ba [hwasan] simplify a test
llvm-svn: 344203
2018-10-10 23:57:38 +00:00
Kostya Serebryany d7c60e42e3 [hwasan] when reporting a bug, print some very basic information about the heap chunk (in addition to the more detailed info that we may fail to show)
llvm-svn: 344193
2018-10-10 22:24:44 +00:00
Kostya Serebryany a393399741 [hwasan] print all threads in a bug report
llvm-svn: 344174
2018-10-10 18:56:31 +00:00
Kostya Serebryany 3fc15200e2 [hwasan] print more tags around the buggy address, and do it with a single Printf
llvm-svn: 344169
2018-10-10 18:32:31 +00:00
Martin Storsjo f0c286f8fb [sanitizers] [windows] Use a linker directive pragma for psapi
This allows users of static libraries (such as ubsan) to link without
knowing about this transitive dependency, if using the psapi functions
that require linking to a separate psapi library. Since Windows 7,
these functions (EnumProcessModules, GetModuleInformation,
GetProcessMemoryInfo) are remapped to K32- prefixed ones, available in
kernel32.dll.

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

llvm-svn: 344126
2018-10-10 09:03:58 +00:00
George Karpenkov d2f6590285 [libFuzzer] Disable value profiling tests on ARM
Some seem fragile, some fail, and some just take a really long time to run.
It does not seem to make sense to support some subset of value profiling tests.

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

llvm-svn: 344105
2018-10-10 00:58:03 +00:00
George Karpenkov f28523bb3f [libFuzzer] Generalize the code for getting the previous offset for different architectures
Without this change, tests in coverage.test and dump_coverage.test are
failing on non-x86_64 platforms.
The diff is copied from sanitizer_common library, an alternative would
be to link it together with libFuzzer.

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

llvm-svn: 344104
2018-10-10 00:57:44 +00:00
Matt Davis 839ec9d9a4 [compiler-rt] Remove unused formal parameters from allocateOneNode. NFC.
Summary: This is just a minor cleanup to the allocateOneNode interface.  The formals are no-longer used, so I just removed them.

Reviewers: davidxl, void

Reviewed By: davidxl

Subscribers: dberris, llvm-commits

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

llvm-svn: 344073
2018-10-09 20:10:28 +00:00
Kamil Rytarowski 0b24a86f63 Mark intercept-rethrow-exception.cc as XFAIL on NetBSD
This is an ASan test for functionality that has not been
ported to NetBSD so far.

llvm-svn: 344047
2018-10-09 13:32:52 +00:00
Kamil Rytarowski d98081a783 Disable failing tests lib/asan/tests on NetBSD
These isses are not analyzed.

llvm-svn: 344045
2018-10-09 13:25:13 +00:00
Kamil Rytarowski daf662c492 Skip unsupported MSan tests on NetBSD
libm functions remquol and lgammal are missing on NetBSD.

llvm-svn: 344042
2018-10-09 12:58:35 +00:00
Kamil Rytarowski 9651178cd2 Mark 4 MSan tests as XFAIL for NetBSD
Failing ones:
 - chained_origin_with_signals
 - dtls_test
 - ioctl_custom
 - signal_stress_test

llvm-svn: 344041
2018-10-09 12:55:29 +00:00
Kamil Rytarowski d1d2e45218 Mark MSan fork test as UNSUPPORTED on NetBSD
This test sometimes hangs for unknown reason.

llvm-svn: 344038
2018-10-09 11:24:10 +00:00