Commit Graph

10934 Commits

Author SHA1 Message Date
Kamil Rytarowski 4a282024db Correct atexit(3) support in MSan/NetBSD
Summary:
The NetBSD specific implementation of cxa_atexit() does not
preserve the 2nd argument if dso is equal to NULL.

Changes:

 - Split paths of handling intercepted __cxa_atexit() and atexit(3).
   This affects all supported Operating Systems.
 - Add a local stack-like structure to hold the __cxa_atexit() context.
   atexit(3) is documented in the C standard as calling callback from the
   earliest to the oldest entry. This path also fixes potential ABI
   problem of passing an argument to a function from the atexit(3)
   callback mechanism.
 - Allow usage of global vars with ctors in interceptors.
   This allows to use Vector without automatic cleaning up the structures.

This code has been modeled after TSan implementation for the same functions.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, dvyukov, eugenis, vitalybuka, kcc

Reviewed By: vitalybuka

Subscribers: delcypher, devnexen, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 346579
2018-11-10 02:17:32 +00:00
Reid Kleckner 6c0bb3758e Re-land r343606 "[winasan] Unpoison the stack in NtTerminateThread"
This change was reverted because it caused some nacl tests in chromium
to fail. I attempted to reproduce those problems locally, but I was
unable to. Let's reland this and let Chromium's test infrastructure
discover any problems.

llvm-svn: 346560
2018-11-09 22:06:59 +00:00
Evgeniy Stepanov 771d6d37ca [hwasan] Add entire report to abort message on Android.
Summary:
When reporting a fatal error, collect and add the entire report text to
android_set_abort_message so that it can be found in the tombstone.

Reviewers: kcc, vitalybuka

Subscribers: srhines, kubamracek, llvm-commits

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

llvm-svn: 346557
2018-11-09 21:54:03 +00:00
Dean Michael Berris 9e089fca7e [XRay] Add a test for function id encoding/decoding (NFC)
Increase test coverage for function enter/exit encoding/decoding.

llvm-svn: 346477
2018-11-09 07:43:30 +00:00
Dean Michael Berris ead47aab78 [XRay] Add a static assertion on size of metadata payload (NFC)
This change adds a static check to ensure that all data metadata record
payloads don't go past the available buffers in Metadata records.

llvm-svn: 346476
2018-11-09 07:16:45 +00:00
Dean Michael Berris e39a89fbfb [XRay] Fix enter function tracing for record unwriting
Summary:
Before this change, we could run into a situation where we may try to
undo tail exit records after writing metadata records before a function
enter event. This change rectifies that by resetting the tail exit
counter after writing the metadata records.

Reviewers: mboerger

Subscribers: llvm-commits

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

llvm-svn: 346475
2018-11-09 06:49:00 +00:00
Dean Michael Berris aeae545064 [XRay] Add atomic fences around non-atomic reads and writes
Summary:
We need these fences to ensure that other threads attempting to read
bytes in the buffer will see thw writes committed before the extents are
updated. Without these, the writes can be un-committed by the time the
buffer extents counter is updated -- the fences should ensure that the
records written into the log have completed by the time we observe the
buffer extents from different threads.

Reviewers: mboerger

Subscribers: jfb, llvm-commits

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

llvm-svn: 346474
2018-11-09 06:39:45 +00:00
Dean Michael Berris da375a67f8 [XRay] Improve FDR trace handling and error messaging
Summary:
This change covers a number of things spanning LLVM and compiler-rt,
which are related in a non-trivial way.

In LLVM, we have a library that handles the FDR mode even log loading,
which uses C++'s runtime polymorphism feature to better faithfully
represent the events that are written down by the FDR mode runtime. We
do this by interpreting a trace that's serliased in a common format
agreed upon by both the trace loading library and the FDR mode runtime.
This library is under active development, which consists of features
allowing us to reconstitute a higher-level event log.

This event log is used by the conversion and visualisation tools we have
for interpreting XRay traces.

One of the tools we have is a diagnostic tool in llvm-xray called
`fdr-dump` which we've been using to debug our expectations of what the
FDR runtime should be writing and what the logical FDR event log
structures are. We use this fairly extensively to reason about why some
non-trivial traces we're generating with FDR mode runtimes fail to
convert or fail to parse correctly.

One of these failures we've found in manual debugging of some of the
traces we've seen involve an inconsistency between the buffer extents (a
record indicating how many bytes to follow are part of a logical
thread's event log) and the record of the bytes written into the log --
sometimes it turns out the data could be garbage, due to buffers being
recycled, but sometimes we're seeing the buffer extent indicating a log
is "shorter" than the actual records associated with the buffer. This
case happens particularly with function entry records with a call
argument.

This change for now updates the FDR mode runtime to write the bytes for
the function call and arg record before updating the buffer extents
atomically, allowing multiple threads to see a consistent view of the
data in the buffer using the atomic counter associated with a buffer.
What we're trying to prevent here is partial updates where we see the
intermediary updates to the buffer extents (function record size then
call argument record size) becoming observable from another thread, for
instance, one doing the serialization/flushing.

To do both diagnose this issue properly, we need to be able to honour
the extents being set in the `BufferExtents` records marking the
beginning of the logical buffers when reading an FDR trace. Since LLVM
doesn't use C++'s RTTI mechanism, we instead follow the advice in the
documentation for LLVM Style RTTI
(https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html). We then rely on
this RTTI feature to ensure that our file-based record producer (our
streaming "deserializer") can honour the extents of individual buffers
as we interpret traces.

This also sets us up to be able to eventually do smart
skipping/continuation of FDR logs, seeking instead to find BufferExtents
records in cases where we find potentially recoverable errors. In the
meantime, we make this change to operate in a strict mode when reading
logical buffers with extent records.

Reviewers: mboerger

Subscribers: hiraditya, llvm-commits, jfb

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

llvm-svn: 346473
2018-11-09 06:26:48 +00:00
Evgeniy Stepanov 4680386c34 [hwasan] Remove dead code.
llvm-svn: 346452
2018-11-09 00:03:39 +00:00
Dan Liew 7383b4fba4 Introduce `sanitizer_malloc_introspect_t` for Darwin which is a sub-class of Darwin's `malloc_introspection_t` and use it when setting up the malloc zone.
Summary:
Currently `sanitizer_malloc_introspection_t` just adds a version field
which is used to version the allocator ABI. The current allocator ABI
version is returned by the new `GetMallocZoneAllocatorEnumerationVersion()` function.

The motivation behind this change is to allow external processes to
determine the allocator ABI of a sanitized process.

rdar://problem/45284065

Reviewers: kubamracek, george.karpenkov, vitalybuka

Subscribers: #sanitizers, llvm-commits

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

llvm-svn: 346420
2018-11-08 17:50:34 +00:00
Calixte Denizet 692b34790f [Profile] The test for gcov-fork seems to be ok on arm
Summary: Remove the XFAIL for arm since it seems to be ok

Reviewers: marco-c

Reviewed By: marco-c

Subscribers: javed.absar, kristof.beyls, delcypher, chrib, llvm-commits, #sanitizers, sylvestre.ledru

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

llvm-svn: 346409
2018-11-08 16:16:04 +00:00
Kamil Rytarowski e06fb482a9 Split lgammal() from INIT_LGAMMAL
Summary:
Introduce SANITIZER_INTERCEPT_LGAMMAL
dedicated for lgammal(). Disable it for NetBSD
as this routine is not implemented in this OS.

Installation of supernumerary interceptors causes
leaking of errors to dlsym(3)-like operations.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 346352
2018-11-07 20:19:53 +00:00
Kamil Rytarowski c4dfb42897 Split remquol() from INIT_REMQUO
Summary:
Introduce SANITIZER_INTERCEPT_REMQUOL
dedicated for remquol(). Disable for for NetBSD
as this routine is not implemented in this OS.

Installation of supernumerary interceptors causes
leaking of errors to dlsym(3)-like operations.

Reviewers: joerg, vitalybuka

Reviewed By: vitalybuka

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

Tags: #sanitizers

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

llvm-svn: 346351
2018-11-07 20:18:36 +00:00
Petr Hosek 5dc0fba2e3 [CMake][ASan][HWASan] Set an explicit dependency on libc++ headers
We have seen failing builds due to a race condition between
RTAsan_dynamic and libc++ headers builds, specifically libc++
headers depend on __config and if this header hasn't been copied
into the final location, including other headers will typically
result in failure. To avoid this race, we add an explicit dependency
on libc++ headers which ensures that they've been copied into place
before the sanitizer object library build starts.

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

llvm-svn: 346339
2018-11-07 18:35:44 +00:00
Calixte Denizet db7f78a2cb [Profile] Mark gcov-fork test as failing for arm
Summary: instrprof-gcov-fork.test is failing with arm so mark it as XFAIL

Reviewers: marco-c

Reviewed By: marco-c

Subscribers: javed.absar, kristof.beyls, delcypher, chrib, llvm-commits, sylvestre.ledru, #sanitizers

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

llvm-svn: 346329
2018-11-07 15:58:18 +00:00
Calixte Denizet 5e09c49499 [Profile] Fix fork test and add tests for execlp and execvp after patch https://reviews.llvm.org/D53593
Summary: This is a follow-up of patch https://reviews.llvm.org/D53593

Reviewers: marco-c

Reviewed By: marco-c

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

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

llvm-svn: 346314
2018-11-07 13:51:17 +00:00
Marco Castelluccio ed4bb266c8 [GCOV] Close file mapping handle on Windows, so flushed gcda files can be removed while the process is in execution
llvm-svn: 346300
2018-11-07 09:38:26 +00:00
Dean Michael Berris 59439dd069 [XRay] Use TSC delta encoding for custom/typed events
Summary:
This change updates the version number for FDR logs to 5, and update the
trace processing to support changes in the custom event records.

In the runtime, since we're already writing down the record preamble to
handle CPU migrations and TSC wraparound, we can use the same TSC delta
encoding in the custom event and typed event records that we use in
function event records. We do the same change to typed events (which
were unsupported before this change in the trace processing) which now
show up in the trace.

Future changes should increase our testing coverage to make custom and
typed events as first class entities in the FDR mode log processing
tools.

This change is also a good example of how we end up supporting new
record types in the FDR mode implementation. This shows the places where
new record types are added and supported.

Depends on D54139.

Reviewers: mboerger

Subscribers: hiraditya, arphaman, jfb, llvm-commits

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

llvm-svn: 346293
2018-11-07 04:37:42 +00:00
Evgeniy Stepanov d657f109d7 [sanitizer] Only set soft coredump limit.
Summary: If user wants to raise it back, let them.

Reviewers: kcc, vitalybuka

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 346284
2018-11-07 01:03:26 +00:00
Jonathan Metzman 39b6ba9f33 [fuzzer] Read files as binary
Summary: Read corpus files as binary to avoid automatic conversions

Reviewers: Dor1s, morehouse

Reviewed By: Dor1s, morehouse

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

llvm-svn: 346279
2018-11-06 23:25:25 +00:00
Vedant Kumar 9e41b5eb6e [Darwin] Export new weak external symbols when compiling with coverage
Some weak external symbols were added to the profile runtime in D49953,
and on Darwin, these need to be exported for tapi verification purposes.

I've tightened the test so that future breakages can be caught earlier.

rdar://45831054

llvm-svn: 346276
2018-11-06 22:25:00 +00:00
Vitaly Buka 34e6f0b872 [sanitizer] Return headed to fix build after r346258
llvm-svn: 346270
2018-11-06 21:49:53 +00:00
Benjamin Kramer b23fded901 [dfsan] Fix build after r346262
compiler-rt/lib/dfsan/dfsan.cc:426:3: error: call to 'InitializePlatformEarly' is ambiguous
  InitializePlatformEarly();
  ^~~~~~~~~~~~~~~~~~~~~~~
compiler-rt/lib/dfsan/../sanitizer_common/sanitizer_common.h:901:6: note: candidate function
void InitializePlatformEarly();
     ^
compiler-rt/lib/dfsan/dfsan.cc:391:13: note: candidate function
static void InitializePlatformEarly() {
            ^

llvm-svn: 346264
2018-11-06 20:42:19 +00:00
Kuba Mracek c4b8eb53c4 [sanitizer] Use "fast mmap" kernel flag for shadow memory on macOS 10.13.4+
This speeds up process startup and teardown and also reduces lock contention when running multiple ASanified/TSanified processes simultaneously. Should greatly improve lit testing time.

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

llvm-svn: 346262
2018-11-06 19:55:19 +00:00
Vitaly Buka bcee83da3e [sanitizer] Fix nolibc unittests broken by r346215
Subscribers: kubamracek, krytarowski, fedor.sergeev, llvm-commits

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

llvm-svn: 346258
2018-11-06 19:23:22 +00:00
Vitaly Buka ecb2eb46bc [sanitizer] Add char **GetEnviron() on all other platforms
Subscribers: kubamracek, llvm-commits

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

llvm-svn: 346257
2018-11-06 19:23:12 +00:00
Kamil Rytarowski 37eefc07d0 Adapt UBSan integer truncation tests to NetBSD
Summary:
The NetBSD headers use internal indirect type for
standard *int*_t  definitions. The internal type is unrolled
inside the sanitizer into e.g. __int32_t from int32_t.

This symbol mangling causes pattern mismatch in
the interger truncation tests as they expect exact
types such as 'int32_t'.

Change the pattern rules so every acceptable internal
form of *int*_t will be accepted flawlessly.

Reviewers: lebedev.ri, vitalybuka, joerg

Reviewed By: lebedev.ri

Subscribers: kubamracek, dmgreen, llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 346228
2018-11-06 14:18:05 +00:00
Kamil Rytarowski cc297272c7 Prioritize the constructor call of __local_xray_dyninit()
Summary:
For platforms without preinit support (such as NetBSD/amd64) the
initialization routine __xray_init() was called in non-deterministic order
compared to other constructors. This caused breakage failures
as xray routines attempted to execute code with assumption of
being initialized, which was no always true.

Use GCC/Clang extension to set maximal priority to the constructor
calling __xray_init(). This code switches away from C++ lambda form,
as it did not allow to specify this compiler extension.

Reviewers: dberris, joerg

Reviewed By: dberris

Subscribers: llvm-commits, mgorny, #sanitizers

Tags: #sanitizers

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

llvm-svn: 346222
2018-11-06 10:59:21 +00:00
Benjamin Kramer 178d26fa18 [sanitizer] Use AT_EXECFN in ReExec() if available
execve("/proc/self/exe") will not work if the binary relies on
$EXEC_ORIGIN in an rpath. Query AT_EXECFN instead, which will give the
same string that the current binary was exec'd with.

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

llvm-svn: 346215
2018-11-06 08:53:38 +00:00
Dean Michael Berris 25f8d204b8 [XRay] Update XRayRecord to support Custom/Typed Events
Summary:
This change cuts across LLVM and compiler-rt to add support for
rendering custom events in the XRayRecord type, to allow for including
user-provided annotations in the output YAML (as raw bytes).

This work enables us to add custom event and typed event records into
the `llvm::xray::Trace` type for user-provided events. This can then be
programmatically handled through the C++ API and can be included in some
of the tooling as well. For now we support printing the raw data we
encounter in the custom events in the converted output.

Future work will allow us to start interpreting these custom and typed
events through a yet-to-be-defined API for extending the trace analysis
library.

Reviewers: mboerger

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 346214
2018-11-06 08:51:37 +00:00
Kamil Rytarowski 927c8803c1 Disable XRay test fork_basic_logging for NetBSD
This code has not been ported so far.

llvm-svn: 346196
2018-11-06 01:53:54 +00:00
Kamil Rytarowski 2e61186c42 Follow Windows' approach for NetBSD in AlarmCallback()
NetBSD's current behavior needs to ignore check for
InFuzzingThread() in Fuzzer::AlarmCallback().

llvm-svn: 346194
2018-11-06 01:28:01 +00:00
George Karpenkov fd68e3e2e3 [libFuzzer] Disable value-profile-cmp.test and fuzzer-oom.test on ARM64
value-profile-cmp was always flaky, and OOM fails to work in some environments.
counters.test fails when vectorization is enabled, and it is more likely
to kick in when compiling for ARM.

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

llvm-svn: 346193
2018-11-06 01:15:51 +00:00
Rainer Orth 682ee6c3bc [Sanitizers] Disable SANITIZER_CAN_FAST_UNWIND on all SPARC targets
While testing my to-be-submitted Solaris sanitizer support on gcc mainline, I ran into
an issue on Solaris/SPARC (sparc-sun-solaris2.11). Initially libasan.so failed to link:

  Undefined                       first referenced
   symbol                             in file
  __sanitizer::BufferedStackTrace::FastUnwindStack(unsigned long, unsigned long, unsigned long, unsigned long, unsigned int) /var/gcc/gcc-9.0.0-20181024/11.5-gcc-gas/sparc-sun-solaris2.11/./libsanitizer/asan/.libs/libasan.so

This happens because SANITIZER_CAN_FAST_UNWIND is enabled on non-Linux
SPARC targets (cf. sanitizer_stacktrace.h), but the guard around the SPARCv8-only
definition in sanitizer_stacktrace_sparc.cc only works with clang:

clang predefines __sparcv8__ on non-Solaris, and __sparcv8 only on Solaris
gcc predefines __sparcv8 on Solaris, but __sparc_v8__ on non-Solaris

The attached patch allows for all three variants.

However, disabling SANITIZER_CAN_FAST_UNWIND on all SPARC targets
fixes a couple of testsuite failures in the Solaris asan testsuite, so for now it's better
to keep it disabled everywhere.

This allowed the libsanitizer build to complete and gave reasonable (though slightly
worse than on Solaris/x86) testsuite results.

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

llvm-svn: 346155
2018-11-05 19:22:54 +00:00
Rainer Orth 1a9b072338 [Sanitizers] Solaris largefile fixes
While testing the Solaris libsanitizer port on GCC mainline, I found that
I'd messed up
the largefile checks in various ways, some of which showed as compile failures
(wrong structure sizes and member offsets), others at runtime, some of those only
on sparc as a big-endian target.

This patch fixes all of them:

- OFF_T is now correctly defined for 32-bit largefile and traditional
  environments, and 64-bit.

- The definition of __sanitizer_dirent now checks the correct conditionals.

- sanitizer_procmaps_solaris.cc undefines _FILE_OFFSET_BITS: before
  Solaris 11.4 <procfs.h> doesn't even compile with largefile support
  enabled, but the use at hand doesn't need it anyway while g++ 9 will
  define _FILE_OFFSET_BITS=64 out of the box.

- With full largefile support enabled, one needs to use e.g. mmap64
  instead of mmap; this is hidden behind macros.

With this patch I could bootstrap gcc mainline on both sparc-sun-solaris2.11 and
i386-pc-solaris2.11.  In addition, I've successfully built llvm on
i386-pc-solaris2.11.

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

llvm-svn: 346153
2018-11-05 19:19:15 +00:00
David Carlier a7b4ae9d37 [UBsan] disable few tests for FreeBSD
Reviewers: krytarowsky, vitalybuka

Reviewed By: vitalybuka

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

llvm-svn: 346145
2018-11-05 17:18:23 +00:00
Martin Liska 5f60861be7 Fix build on sparc64-linux-gnu.
Differential Revision: https://reviews.llvm.org/D54030

llvm-svn: 346129
2018-11-05 12:27:43 +00:00
Fangrui Song 342ca71145 [hwasan] Fix stack-uar.c after rCRT345110
Set -fno-discard-value-names so that the frame description string contains the variable name.

llvm-svn: 346120
2018-11-05 07:16:25 +00:00
Dean Michael Berris 1e255e7a7b [XRay] Update TSC math to handle wraparound
Summary:
Prior to this change, we can run into situations where the TSC we're
getting when exiting a function is less than the TSC we got when
entering it. This would sometimes cause the counter for cumulative call
times overflow, which was erroneously also being stored as a signed
64-bit integer.

This change addresses both these issues while adding provisions for
tracking CPU migrations. We do this because moving from one CPU to
another doesn't guarantee that the timestamp counter for some
architectures aren't guaranteed to be synchronised. For the moment, we
leave the provisions there until we can update the data format to
include the counting of CPU migrations we can catch.

We update the necessary tests as well, ensuring that our expectations
for the cycle accounting to be met in case of counter wraparound.

Reviewers: mboerger

Subscribers: llvm-commits

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

llvm-svn: 346116
2018-11-05 05:43:22 +00:00
Kamil Rytarowski 538d678737 Disable recursive interception for tzset in MSan
This fixes sanitization of this library call on NetBSD.
Extracted as a part of D42050.

llvm-svn: 346098
2018-11-04 15:30:38 +00:00
Petr Hosek 4dc4d6eaca [compiler-rt] Support for passing through linker flags to libc++ build
This may be needed when cross-compiling to certain platforms.

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

llvm-svn: 346063
2018-11-03 01:38:26 +00:00
Petr Hosek 466f0f028a [compiler-rt][Fuzzer] Fix the fuzzer test build
This fixes the issue introduced in r345765 which changed the way in
which the embedded libc++ is being built but omitted tests.

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

llvm-svn: 346052
2018-11-02 23:29:13 +00:00
Dan Albert 9628392224 Workaround using new Clang with an old NDK.
We're using an old NDK and a new Clang. New Clangs default to
`-stdlib=libc++` for Android, but those libraries cannot be found by
default with an old NDK. Use an explicit `-stdlib=libstdc++` in the
cxx_mode_flags.

llvm-svn: 346051
2018-11-02 22:57:04 +00:00
Kamil Rytarowski 3095874d3c Try to unbreak the build of sanitizers on !NetBSD
Include the build of unpoison_passwd() and unpoison_group() for
SANITIZER_INTERCEPT_FGETPWENT_R and SANITIZER_INTERCEPT_FGETGRENT_R.
 static void unpoison_passwd(

llvm-svn: 346042
2018-11-02 21:06:05 +00:00
Kamil Rytarowski 8deda5fbd8 Split getpwent and fgetgrent functions in interceptors
Summary:
NetBSD does not ship with fgetpwent_r() and fgetgrent_r().
Split their interceptors from getpwent_r() and getgrent_r()
and disable for this OS.

Installation of supernumerary interceptors causes leaking of
errors to dlsym(3)-like operations.

No functional change for other OSes.

Reviewers: vitalybuka, joerg

Reviewed By: vitalybuka

Subscribers: srhines, kubamracek, fedor.sergeev, llvm-commits, #sanitizers, mgorny

Tags: #sanitizers

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

llvm-svn: 346038
2018-11-02 20:28:10 +00:00
Lei Huang 78f7a6eaa6 [PowerPC]Disable randomized address space on Linux ppc64le
Recent versions of Ubuntu (17.04 and 18.04) on PowerPC have introduced changes
to Address Space Layout Randomization (ASLR) that is causing 500+ sanitizer
failures. This patch disables ASLR when running the sanitizers on PowerPC 64bit
LE.

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

llvm-svn: 346030
2018-11-02 19:00:23 +00:00
Dan Liew a8eaaa8006 [NFC] Refactor initialisation of Darwin malloc zone fields into separate function called `InitMallocZoneFields()` which is now called from `ReplaceSystemMalloc()`.
Summary:
The motivation here is to be able support initialisation of the
malloc zone on other code paths.

rdar://problem/45284065

Reviewers: kubamracek, george.karpenkov

Subscribers: llvm-commits, #sanitizers

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

llvm-svn: 345983
2018-11-02 15:28:11 +00:00
Dean Michael Berris 0c96ae3d6e [XRay] Update delta computations in runtime
Summary:
Fix some issues discovered from mostly manual inspection of outputs from
the `llvm-xray fdr-dump` tool.

It turns out we haven't been writing the deltas properly, and have been
writing down zeros for deltas of some records. This change fixes this
oversight born by the recent refactoring.

Reviewers: mboerger

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 345954
2018-11-02 08:07:38 +00:00
Dean Michael Berris e8c650ab12 [XRay] Fix TSC and atomic custom/typed event accounting
Summary:
This is a follow-on change to D53858 which turns out to have had a TSC
accounting bug when writing out function exit records in FDR mode.

This change adds a number of tests to ensure that:

- We are handling the delta between the exit TSC and the last TSC we've
  seen.

- We are writing the custom event and typed event records as a single
  update to the buffer extents.

- We are able to catch boundary conditions when loading FDR logs.

We introduce a TSC matcher to the test helpers, which we use in the
testing/verification of the TSC accounting change.

Reviewers: mboerger

Subscribers: mgorny, hiraditya, jfb, llvm-commits

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

llvm-svn: 345905
2018-11-01 22:57:50 +00:00
Dean Michael Berris 6b67ff0300 [XRay] Add CPU ID in Custom Event FDR Records
Summary:
This change cuts across compiler-rt and llvm, to increment the FDR log
version number to 4, and include the CPU ID in the custom event records.

This is a step towards allowing us to change the `llvm::xray::Trace`
object to start representing both custom and typed events in the stream
of records. Follow-on changes will allow us to change the kinds of
records we're presenting in the stream of traces, to incorporate the
data in custom/typed events.

A follow-on change will handle the typed event case, where it may not
fit within the 15-byte buffer for metadata records.

This work is part of the larger effort to enable writing analysis and
processing tools using a common in-memory representation of the events
found in traces. The work will focus on porting existing tools in LLVM
to use the common representation and informing the design of a
library/framework for expressing trace event analysis as C++ programs.

Reviewers: mboerger, eizan

Subscribers: hiraditya, mgrang, llvm-commits

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

llvm-svn: 345798
2018-11-01 00:18:52 +00:00