When the file is initialized, this patch checks whether the path
specifies a directory. If so, it creates the directory tree before
truncating the file.
Use default.profdata instead of pgo-data for default indexed profile name.
llvm-svn: 241824
The image-relative complete object locator contains a reference to itself,
which we can use to compute the image base without using VirtualQuery.
Spotted by David Majnemer.
llvm-svn: 241758
Specifically:
- Start using %expect_crash.
- Provide an implementation of __ubsan::getDynamicTypeInfoFromVtable
for the Microsoft C++ ABI. This is all that is needed for CFI
diagnostics; UBSan's -fsanitize=vptr also requires an implementation of
__ubsan::checkDynamicType.
- Build the sanitizer runtimes against the release version of the C
runtime, even in debug builds.
- Accommodate demangling differences in tests.
Differential Revision: http://reviews.llvm.org/D11029
llvm-svn: 241745
Since http://reviews.llvm.org/D10294, ASan test cases now respect default env. options via `ASAN_OPTION=$ASAN_OPTIONS:additional_options=xxx`. This patch adds this to a few test cases where it's still missing.
Differential Revision: http://reviews.llvm.org/D10988
llvm-svn: 241571
On OS X 10.11 (which is currently a public beta), the dynamic linker has been improved so that it doesn't require the use of DYLD_INSERT_LIBRARIES in order for interposition/wrappers to work. This patch adds support of this behavior into ASan – we no longer need to re-exec in case the env. variable is not set.
Reviewed at http://reviews.llvm.org/D10924
llvm-svn: 241487
On OS X, when the main instrumented binary contains a custom section with zero length, ASan will crash (assert failure) early in the initialization.
Reviewed at http://reviews.llvm.org/D10944
llvm-svn: 241474
Specifically:
- Disable int128 tests on Windows, as MSVC cl.exe does not support
int128, so we might not have been able to build the runtime
with int128 support.
- XFAIL the vptr tests as we lack Microsoft ABI support.
- XFAIL enum.cpp as UBSan fails to add the correct instrumentation code
for some reason.
- Modify certain tests that build executables multiple times to use
unique names for each executable. This works around a race condition
observed on Windows.
- Implement IsAccessibleMemoryRange for Windows to fix the last
misaligned.cpp test.
- Introduce a substitution for testing crashes on Windows using
KillTheDoctor.
Differential Revision: http://reviews.llvm.org/D10864
llvm-svn: 241303
POSIX states that "It shall be safe to destroy an initialized condition
variable upon which no threads are currently blocked", and later clarifies
"A condition variable can be destroyed immediately after all the threads
that are blocked on it are awakened) (in examples section). Tsan reported
such destruction as a data race.
Fixes https://llvm.org/bugs/show_bug.cgi?id=23616
Reviewed in http://reviews.llvm.org/D10693
llvm-svn: 241082
The test simulates a sandbox that prevents the program from calling readlink().
ASan is supposed to still be able to print the executable name regardless of that.
llvm-svn: 241072
struct sigaction was not initialized. As the result if SA_RESETHAND is set in sa_flags, then the handler is reset after first invocation leading to crash.
Initialize struct sigaction to zero.
Reviewed in http://reviews.llvm.org/D10803
llvm-svn: 240965
which caches the executable name upon the first invocation.
This is necessary because Google Chrome (and potentially other programs)
restrict the access to /proc/self/exe on linux.
This change should fix https://code.google.com/p/chromium/issues/detail?id=502974
llvm-svn: 240960
The new suppression type is called "race_top" and is matched only against top frame in report stacks.
This is required for situations when we want to suppress a race in a "thread pool" or "event loop" implementation.
If we simply use "race:ThreadPool::Execute" suppression, that can suppress everything in the program.
Reviewed in http://reviews.llvm.org/D10686
llvm-svn: 240949
Summary:
On PPC64, half the msan tests fail with an infinite recursion through
GetStackTrace like this:
#0 __msan::GetStackTrace
#1 __msan_memcpy
#2 ?? () from /lib64/libgcc_s.so.1
#3 ?? () from /lib64/libgcc_s.so.1
#4 _Unwind_Backtrace
#5 __sanitizer::BufferedStackTrace::SlowUnwindStack
#6 __sanitizer::BufferedStackTrace::Unwind
#7 __msan::GetStackTrace
#8 __interceptor_calloc
#9 _dl_allocate_tls
#10 pthread_create@@GLIBC_2.17
#11 __interceptor_pthread_create
#12 main
The problem is that we call _Unwind_Backtrace to get a stack trace; but
_Unwind_Backtrace calls memcpy, which we intercept and try to get
another stack trace.
This patch fixes it in __msan_memcpy by skipping the stack trace if
IsInSymbolizer(). This works because GetStackTrace already creates a
SymbolizerScope to "block reports from our interceptors during
_Unwind_Backtrace".
Reviewers: samsonov, wschmidt, eugenis
Reviewed By: eugenis
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10762
llvm-svn: 240878
We were unsetting DYLD_ROOT_PATH before calling atos on Darwin in order to
address it not working for symbolicating 32 bit binaries. (atos essentiall
tries to respawn as a 32 bit binary and it's disallowed to respawn if
DYLD_ROOT_PATH is set ... ) However, processes rely on having DYLD_ROOT_PATH
set under certain conditions, so this is not the right fix. In particular, this
always crashes when running ASanified process under the debugger in Xcode with
iOS simulator, which is a very important workflow for us to support.
This patch reverts the unsetting of the DYLD_ROOT_PATH. The correct fix to the
misbehavior on 32-bit binaries should happen inside atos.
http://reviews.llvm.org/D10722
llvm-svn: 240724
Summary:
This fixes test/msan/Linux/syscalls.cc, and should also fix the ppc64
sanitizer buildbots which are currently failing in
"make check-sanitizer".
Reviewers: samsonov, wschmidt, eugenis
Reviewed By: eugenis
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10734
llvm-svn: 240692
Summary:
On PPC64 if you disable ASLR (or run under gdb) you're likely to see
mmap returning a mapping right at the end of the application address
space region. This caused SetShadow to call MEM_TO_SHADOW() on the
last+1 address in the region, which seems wrong to me; how can
MEM_TO_SHADOW() distinguish this from the first address in the following
region?
Fixed by only calling MEM_TO_SHADOW() once, on the start address.
Reviewers: samsonov, wschmidt, eugenis
Reviewed By: eugenis
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10735
llvm-svn: 240690
-fsanitize=vptr is a UBSan feature that doesn't work on older Mac OS X
versions, and we don't want to penalize users that use modern OS with
default configuration. Those who want to target older OS versions, can
specify that versions explicitly.
llvm-svn: 240688
Previously tsan modelled dup2(oldfd, newfd) as write on newfd.
We hit several cases where the write lead to false positives:
1. Some software dups a closed pipe in place of a socket before closing
the socket (to prevent races actually).
2. Some daemons dup /dev/null in place of stdin/stdout.
On the other hand we have not seen cases when write here catches real bugs.
So model dup2 as read on newfd instead.
llvm-svn: 240687
Summary:
This patch adds basic memory sanitizer support for PPC64. PR23219.
I have further patches ready to enable it in LLVM and Clang, and to fix
most of the many failing tests in check-msan.
Reviewers: kcc, willschm, samsonov, wschmidt, eugenis
Reviewed By: eugenis
Subscribers: wschmidt, llvm-commits
Differential Revision: http://reviews.llvm.org/D10648
llvm-svn: 240623
Summary:
This patch implements step 1 from
https://llvm.org/bugs/show_bug.cgi?id=23539#c10
I'd appreciate if you could test it on Mac OS and verify that parts of UBSan
runtime that reference C++ ABI symbols are properly excluded, and fix ASan/UBSan
builds.
Test Plan: regression test suite
Reviewers: thakis, hans
Subscribers: llvm-commits, zaks.anna, kubabrecka
Differential Revision: http://reviews.llvm.org/D10621
llvm-svn: 240617
Summary: _Unwind_Backtrace is not available on iOS, so we should ifdef out the posix implementations of BufferedStackTrace::SlowUnwindStack and BufferedStackTrace::SlowUnwindStackWithContext on iOS.
Reviewers: samsonov
Reviewed By: samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10696
llvm-svn: 240586
We see false reports between dlopen and dl_iterate_phdr.
This happens because tsan does not see dynamic linker
internal synchronization. Unpoison module names
in dl_iterate_phdr callback.
llvm-svn: 240576
This happens only in corner cases, but we observed this on a real app.
See the test for description of the exact scenario that lead to unbounded memory consumption.
llvm-svn: 240535
This patch clarifies the TODO note at the top of safestack.cc and brings
it more in sync with what we (the CPI team) actually plan to work on in
the future.
Patch by Volodymyr Kuznetsov!
Differential Revision: http://reviews.llvm.org/D10600
llvm-svn: 240473
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.
Darwin doesn't have _Unwind_VRS_Get, instead use _Unwind_GetIP directly.
Note: this change does not enable building for iOS, as there are more changes to come.
Reviewers: kubabrecka, bogner, samsonov
Reviewed By: samsonov
Subscribers: samsonov, llvm-commits
Differential Revision: http://reviews.llvm.org/D10516
llvm-svn: 240470
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.
This change ifdefs out headers and functionality that aren't available on iOS, and adds support for iOS and the iOS simulator to as an.
Note: this change does not enable building for iOS, as there are more changes to come.
Reviewers: glider, kubabrecka, bogner, samsonov
Reviewed By: samsonov
Subscribers: samsonov, zaks.anna, llvm-commits
Differential Revision: http://reviews.llvm.org/D10515
llvm-svn: 240469
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.
This change ifdefs out headers and functionality that aren't available on iOS.
Note: this change does not enable building for iOS, as there are more changes to come.
Reviewers: glider, kubabrecka, bogner, samsonov
Reviewed By: samsonov
Subscribers: samsonov, llvm-commits
Differential Revision: http://reviews.llvm.org/D10514
llvm-svn: 240468
Summary:
This is one of many changes needed for compiler-rt to get it building on iOS.
This change does the following:
- Don't include crt_externs on iOS (it isn't available)
- Support ARM thread state objects
Note: this change does not enable building for iOS, as there are more changes to come.
Reviewers: glider, kubabrecka, bogner, samsonov
Reviewed By: samsonov
Subscribers: samsonov, aemerson, llvm-commits
Differential Revision: http://reviews.llvm.org/D10510
llvm-svn: 240467
Summary:
This patch fixes incorrect truncation when the input wider value is
exactly 2^dstBits. For that value, the overflow to infinity is not
correctly handled. The fix is to replace a strict '>' with '>='.
Currently,
__truncdfsf2(340282366900000000000000000000000000000.0) returns infinity
__truncdfsf2(340282366920938463463374607431768211456.0) returns 0
__truncdfsf2(400000000000000000000000000000000000000.0) returns infinity
Likewise, __truncdfhf2 and __truncsfhf2 (and consequently gnu_f2h_ieee)
are discontinuous at 65536.0.
This patch adds tests for all three cases, along with adding a missing
header include to fp_test.h.
Reviewers: joerg, ab, srhines
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10594
llvm-svn: 240450
Summary: This test uses x86 intrinsics, so it can't work on other platforms.
Reviewers: garious, eugenis, samsonov
Reviewed By: samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10652
llvm-svn: 240449
I have no idea how to directly test that as it depends on a particular
(micro-)architecure of the host processor.
Combined with llvm's r240339 this should fix issues people might have
be seeing intermitently on Darwin haswell machines (the symbolizer
would use the wrong slice of the binary, thus potentially resolving
to the wrong symbol).
llvm-svn: 240379
Make sure that sanitizer runtimes target OS X version provided in
-mmacosx-version-min= flag. Enforce that it should be at least 10.7.
llvm-svn: 240356
Summary:
Use CMake's cmake_parse_arguments() instead.
It's called in a slightly different way, but supports all our use cases.
It's in CMake 2.8.8, which is our minimum supported version.
CMake 3.0 doc (roughly the same. No direct link to 2.8.8 doc):
http://www.cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html?highlight=cmake_parse_arguments
Since I was already changing these calls, I changed ARCH and LIB into
ARCHS and LIBS to make it more clear that they're lists of arguments.
Reviewers: eugenis, samsonov, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10529
llvm-svn: 240120
Meta shadow is compressing and we don't flush it,
so it makes sense to mark it as NOHUGEPAGE to not over-allocate memory.
On one program it reduces memory consumption from 5GB to 2.5GB.
llvm-svn: 240028
This change makes cmake fail to even run on Darwin with errors
evaluating "$<TARGET_OBJECTS:RTInterception.x86_64>".
This reverts r239955
llvm-svn: 239985
This patch adds runtime support for the Safe Stack protection to compiler-rt
(see http://reviews.llvm.org/D6094 for the detailed description of the
Safe Stack).
This patch is our implementation of the safe stack on top of compiler-rt. The
patch adds basic runtime support for the safe stack to compiler-rt that
manages unsafe stack allocation/deallocation for each thread.
Original patch by Volodymyr Kuznetsov and others at the Dependable Systems
Lab at EPFL; updates and upstreaming by myself.
Differential Revision: http://reviews.llvm.org/D6096
llvm-svn: 239763
Summary:
This commit adds symbolize_vs_style=false to every instance of
ASAN_OPTIONS in the asan tests and sets
ASAN_OPTIONS=symbolize_vs_style=false in lit, for tests which don't set
it.
This way we don't need to make the tests be able to deal with both
symbolize styles.
This is the first patch in the series. I will eventually submit for the
other sanitizers too.
We need this change (or another way to deal with the different outputs) in
order to be able to default to symbolize_vs_style=true on some platforms.
Adding to this change, I'm also adding "env " before any command line
which sets environment variables. That way the test works on other host
shells, like we have if the host is running Windows.
Reviewers: samsonov, kcc, rnk
Subscribers: tberghammer, llvm-commits
Differential Revision: http://reviews.llvm.org/D10294
llvm-svn: 239754
Like we do for the various __*tf* tests, check that long double is the
128bit type we expect directly in the header. The latter is now used by
unrelated tests (__*hf* since r237161), and those tests will break for
no reason if uint128_t doesn't exist, and long double isn't fp128.
llvm-svn: 239630
Summary:
This change takes darwin-specific goop that was scattered around CMakeLists files and spread between add_compiler_rt_object_library and add_compiler_rt_darwin_object_library and moves it all under add_compiler_rt_object_library.
The goal of this is to try to push platform handling as low in the utility functions as possible.
Reviewers: rnk, samsonov
Reviewed By: rnk, samsonov
Subscribers: rnk, rsmith, llvm-commits
Differential Revision: http://reviews.llvm.org/D10250
llvm-svn: 239498
lib/Target/AArch64/AArch64FrameLowering.cpp:370: virtual void llvm::AArch64FrameLowering::emitPrologue(llvm::MachineFunction&, llvm::MachineBasicBlock&) const: Assertion `!(NeedsRealignment && NumBytes==0) && "NumBytes should never be 0 when realignment is needed"' failed.
llvm-svn: 239352
/code/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:971:8: error: address of function 'dl_iterate_phdr' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
if (!dl_iterate_phdr)
~^~~~~~~~~~~~~~~
/code/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc:971:8: note: prefix with the address-of operator to silence this warning
if (!dl_iterate_phdr)
^
&
llvm-svn: 239321
Summary:
With this patch, we have a flag to toggle displaying source locations in
the regular style:
file:line:column
or Visual Studio style:
file(line,column)
This way, they get picked up on the Visual Studio output window and one
can double-click them to get to that file location.
Reviewers: samsonov, rnk
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10113
llvm-svn: 239000
Summary:
This way, if they're set when running ninja check-ubsan (or another
sanitizer), they get cleared before we start invoking the programs.
Reviewers: samsonov, kcc
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10229
llvm-svn: 238991
This is done by creating a named shared memory region, unlinking it
and setting up a private (i.e. copy-on-write) mapping of that instead
of a regular anonymous mapping. I've experimented with regular
(sparse) files, but they can not be scaled to the size of MSan shadow
mapping, at least on Linux/X86_64 and ext3 fs.
Controlled by a common flag, decorate_proc_maps, disabled by default.
This patch has a few shortcomings:
* not all mappings are annotated, especially in TSan.
* our handling of memset() of shadow via mmap() puts small anonymous
mappings inside larger named mappings, which looks ugly and can, in
theory, hit the mapping number limit.
llvm-svn: 238621
Also, sized-delete with size_t == unsigned int.
These guys appear when building for Android with gnu-stl.
Fixes a number of ASan tests in that particular configuration.
llvm-svn: 238484
Python may not be /usr/bin/python on some systems. For example, on
FreeBSD it will be /usr/local/bin/python.
Reviewers: samsonov
Differential Revision: http://reviews.llvm.org/D9914
llvm-svn: 238428
CMake pre-3.1 has a bug where a shared library depending on a custom_target
does not really depend on it.
This commit implements a hilariously ugly workaround for this problem, see
code comments for more details.
llvm-svn: 238367
Fix 2 bugs in memory mapping setup:
- the invalid region at offset 0 was not protected because mmap at
address 0 fails with EPERM on most Linux systems. We did not
notice this because the check condition was flipped: the code was
checking that mprotect has failed. And the test that was supposed
to catch this was weakened by the mitigations in the mmap
interceptor.
- when running without origins, the origin shadow range was left
unprotected.
The new test ensures that mmap w/o MAP_FIXED always returns valid
application addresses.
llvm-svn: 238109
Windows does not use AAPCS, but rather AAPCS-VFP, and thus the functions which
are assumed to be AAPCS will cause invalid argument setup. Ensure that the
functions are marked as AAPCS.
llvm-svn: 238056
This reverts part of r237808.
The CMP0057 warnings came from an old development build of CMake that
nobody else has. We don't need the cruft.
llvm-svn: 237819
Fix a trivial instance of CMP0054 that came up on llvmdev.
The other warnings were CMP0057, which is about using the same file as a
MAIN_DEPENDENCY multiple times. The old behavior hasn't been a problem
yet, so I silenced the warning and filed PR23595 to document the issue
if someone cares.
llvm-svn: 237808
Without the --target flag, clang uses the mips64 triple which selects the n64 abi. We need to add --target=mips-linux-gnu, so that clang can select the correct abi for mips32r2.
Reviewers: dsanders, kcc, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9249
llvm-svn: 237675
Current code tries to find the dynamic TLS header to the left of the
TLS block without checking that it's not a static TLS allocation.
llvm-svn: 237495
Follow-up to r237161; seems like we can't use aliases, but we
can do better than duplicating the bodies, especially when that
body, after inlining, isn't as small as it looks.
Better approaches welcome. Perhaps the best thing is just to have
an #ifndef __APPLE__ over the GNUEABI names, since they're not used
there.
llvm-svn: 237323
Mostly uninteresting, except:
- in __extendXfYf2, when checking if the number is normal, the old
code relied on the unsignedness of src_rep_t, which is a problem
when sizeof(src_rep_t) < sizeof(int): the result gets promoted to
int, the signedness of which breaks the comparison.
I added an explicit cast; it shouldn't affect other types.
- we can't pass __fp16, so src_t and src_rep_t are the same.
- the gnu_*_ieee symbols are simply duplicated definitions, as aliases
are problematic on mach-o (where only weak aliases are supported;
that's not what we want).
Differential Revision: http://reviews.llvm.org/D9693
llvm-svn: 237161
Mark longjmp tests as XFAIL because longjmp assembly for mips is not yet implemented.
Reviewers: dsanders, dvyukov, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9526
llvm-svn: 236847
This test was failing on mips because mips addresses are 40-bit long.
Using regex for address solves this issue.
Reviewers: dsanders, kcc, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9516
llvm-svn: 236844
Talking to John and Doug, we concluded that these functions from
stdatomic really do belong here in compiler-rt rather than in libc,
since the compiler owns stdatomic.h and these need to refer to
clang-specific builtins. Nonetheless, I've only added these on darwin
for now - other platforms should probably do the same unless their
libc does implement these functions.
llvm-svn: 236805
Summary:
Add a weak hook to be called from dfsan's custom memcmp.
The primary user will be lib/Fuzzer.
If this works well we'll add more hooks (strcmp, etc).
Test Plan: Will be covered by lib/Fuzzer tests.
Reviewers: pcc
Reviewed By: pcc
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9541
llvm-svn: 236679
dl_iterate_phdr is somewhat broken in L (see the code for details).
We add runtime OS version detection and fallback to /proc/maps on L or earlier.
This fixes a number of ASan tests on L.
llvm-svn: 236628
Symbol for pc used in ucontext->uc_mcontext was wrong.
Reviewers: dsanders, kcc, samsonov
Subscribers: llvm-commits, mohit.bhakkad, jaydeep
Differential Revision: http://reviews.llvm.org/D9246
llvm-svn: 236572
They are not part of check-all :(
This change adds sized-delete operators to the version list, and disables the
hack that excluded versioned symbols from the dynamic list - this is not an
issue in this case.
llvm-svn: 236559
Summary:
The spec for these functions says that they should return 0 in this case but
this regressed in r234148. That revision essentially delegates the conversion
to the hardware, but that has different behavior on different platforms (e.g.
it is wrong on x86).
Also fix a typo in the name of __fixunsdfti
Test Plan: The existing unit tests now pass
Reviewers: joerg, howard.hinnant
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9305
llvm-svn: 236319
Fix a couple of new tests that were reverted because they were causing
intermittent test failures since they were writing the same default
"default.profraw" file. Fixed by creating a unique directory and
running tests in that directory.
Patch by Teresa Johnson. Thanks!
llvm-svn: 236168
* Remove __ubsan_default_options, so that test would work on Darwin
* Fix unintentional undefined behavior in the code (missing return)
* Build the test with -fno-sanitize-recover to distinguish expected
failures and expected passes by return code.
llvm-svn: 236152
This partially reverts commit r236056, as the two tests were using the same
names and, when executed in parallel, were having intermittent failures.
llvm-svn: 236101
the profile output from the command line via -fprofile-instr-generate=<path>,
where the specified output path/file will be overridden by the
LLVM_PROFILE_FILE environment variable.
Several changes are made to the runtime to support this:
Add a new interface __llvm_profile_override_default_filename that will
set the profile output filename, but allows LLVM_PROFILE_FILE to override.
This is the interface used by the new option.
Refactor the pid-expansion done for LLVM_PROFILE_FILE into a separate
routine that can be shared by the various filename setting routines
(so that the filename from the option can also use the "%p" syntax).
Move the truncation into setFilename, and only truncate if there is a
new filename specified (to maintain support for appending to the same
profile file in the case of multiple shared objects built with profiling).
Move the handling for a NULL filename passed to __llvm_profile_set_filename and
__llvm_profile_override_default_filename into the new setFilenamePossiblyWithPid
routine. This now correctly resets the output file to default.profraw
instead of NULL.
The handling for a null LLVM_PROFILE_FILE (which should not reset) is done
by caller setFilenameFromEnvironment.
Patch by Teresa Johnson.
llvm-svn: 236055
We incorrectly replaced shadow slots
when the new value is not stronger than the old one.
The bug can lead to false negatives.
The bug was detected by Go race test suite:
https://github.com/golang/go/issues/10589
llvm-svn: 236008
Embed UBSan runtime into TSan and MSan runtimes in the same as we do
in ASan. Extend UBSan test suite to also run tests for these
combinations.
llvm-svn: 235954
For now tsan_cxx and msan_cxx contain only operator new/delete
replacements. In the future, when we add support for running UBSan+TSan
and UBSan+MSan, they will also contain bits ubsan_cxx runtime.
llvm-svn: 235928
Summary:
During the review of http://reviews.llvm.org/D9199 where I had originally
changed the debug_mapping.cc test to accept hexadecimal values, we realized
that SHADOW_SCALE and SHADOW_GRANULARITY ought to be printed as decimal values.
This patch makes that change.
This patch also adds a '0x' prefix to the SHADOW_OFFSET to make it clear that
it is hexadecimal while the other two are decimal.
Reviewers: kcc, timurrrr, samsonov
Reviewed By: timurrrr, samsonov
Subscribers: samsonov, llvm-commits, sagar
Differential Revision: http://reviews.llvm.org/D9224
llvm-svn: 235798
Summary:
Add an interface function which can be used to periodically trigger
leak detection in a long-running process.
NB: The meaning of the kIgnored tag has been changed to allow easy clean-up
between subsequent leak checks. Previously, this tag was applied to explicitly
ignored (i.e. with __lsan_disable() or __lsan_ignore_object()) chunks *and* any
chunks only reachable from those. With this change, it's only applied to
explicitly ignored chunks.
Reviewers: samsonov
Reviewed By: samsonov
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9159
llvm-svn: 235728
Summary:
This makes their local declarations match their definitions for ARM targets,
where they have a different calling convention.
This really only affects functions that use floating point types (since the
runtime functions use soft-float, and some targets may default to hard-float)
but it seemed good to make it uniform and do the int-only ones too.
Differential Revision: http://reviews.llvm.org/D9062
llvm-svn: 235722
Summary:
On ppc64le Fedora 21, getpwnam_r("no-such-user", ...) returns ENOENT
instead of 0. Tolerate this in the test case.
Reviewers: eugenis
Reviewed By: eugenis
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9233
llvm-svn: 235654
Summary:
Previously the CHECK directive for SHADOW_SCALE only matched decimal digits
causing it to match '7' on x86_64 instead of the whole value.
This fixes a failure on mips-linux-gnu targets where the leading digit is 'a'.
Reviewers: kcc, sagar, timurrrr
Reviewed By: timurrrr
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9199
llvm-svn: 235594
float-cast-overflow handler doesn't have source location provided by the
compiler, but we still have *some* source location if we have a
symbolizer.
llvm-svn: 235567
Summary:
ubsan was correctly catching the undefined behaviour but lit's shell was
failing the test anyway because the exit code was non-zero as a result of the
undefined behaviour.
This fixes the test on a mips-linux-gnu target.
Reviewers: samsonov
Reviewed By: samsonov
Subscribers: samsonov, llvm-commits, rsmith, sagar
Differential Revision: http://reviews.llvm.org/D9155
llvm-svn: 235518
Summary:
This will allow us to enable it on the buildbot (and then enable a
sanitizer buildbot).
The problem is that gcc for Mips does not accept -m32/-m64 like clang does.
We therefore need to use the nearest equivalent -mips32r2/-mips64r2. We must
also specify -mabi=64 in the -mips64r2 case since gcc's default ABI has
traditionally been N32 whereas clang's is N64.
Reviewers: sagar
Reviewed By: sagar
Subscribers: llvm-commits, samsonov, kcc, mohit.bhakkad, Anand.Takale, sagar
Differential Revision: http://reviews.llvm.org/D8892
llvm-svn: 235299
Fixes https://llvm.org/bugs/show_bug.cgi?id=23235
If pthread_create is followed by pthread_detach,
the new thread may not acquire synchronize with
the parent thread.
llvm-svn: 235293
As with the other sanitizers, it is desirable to allow ubsan's output to be
redirected to somewhere other than stderr (and into per-process log files).
llvm-svn: 235277
Summary:
When running the compiler-rt testsuite on FreeBSD (it didn't matter which version), I always got the same error result:
FAILED: cd /home/dim/obj/llvm-234092-trunk-freebsd10-amd64-ninja-rel-1/projects/compiler-rt/lib && LLVM_CHECKOUT=/home/dim/src/llvm/trunk SILENT=1 TMPDIR= PYTHON_EXECUTABLE=/usr/local/bin/python2.7 COMPILER_RT=/home/dim/src/llvm/trunk/projects/compiler-rt /home/dim/src/llvm/trunk/projects/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh
The following differences between the implemented custom wrappers and the tests have been found:
--- /tmp/tmp.vPFEefvclf 2015-04-04 17:11:44.996734563 +0200
+++ /tmp/tmp.NbIuvjxKEe 2015-04-04 17:11:45.044734647 +0200
@@ -1,52 +0,0 @@
-calloc
-clock_gettime
-ctime_r
-dfsan_set_write_callback
-dl_iterate_phdr
-dlopen
-fgets
-fstat
-get_current_dir_name
-getcwd
-gethostname
-getpwuid_r
-getrlimit
-getrusage
-gettimeofday
-inet_pton
-localtime_r
-memchr
-memcmp
-memcpy
-memset
-nanosleep
-poll
-pread
-pthread_create
-read
-sched_getaffinity
-select
-sigaction
-sigemptyset
-snprintf
-socketpair
-sprintf
-stat
-strcasecmp
-strchr
-strcmp
-strcpy
-strdup
-strlen
-strncasecmp
-strncmp
-strncpy
-strrchr
-strstr
-strtod
-strtol
-strtoll
-strtoul
-strtoull
-time
-write
After some investigation, it turns out to be due to the regex used for search test_ symbols in lib/dfsan/scripts/check_customer_wrappers.sh:
grep -E "^\\s*test_.*\(\);" ${DFSAN_CUSTOM_TESTS}
This uses \s to search for whitespace at start of line, but support for \s was only introduced in GNU grep v2.5.4-112-gf979ca0, while both FreeBSD and OSX only have grep 2.5.1 (the last version released under GPLv2).
I propose to change \s into [[:space:]], which is the more portable notation.
Test Plan: Run regression tests, and see that they work now. :)
Reviewers: pcc, samsonov, emaste
Reviewed By: emaste
Subscribers: llvm-commits, emaste
Differential Revision: http://reviews.llvm.org/D8832
llvm-svn: 234704
The two subclasses of Symbolizer now only define two virtual functions, PlatformDemangle and PlatformPrepareForSandboxing. Let's make these non-virtual and directly defined by individual platforms.
Reviewed at http://reviews.llvm.org/D8912
llvm-svn: 234690
The patch is generated using clang-tidy misc-use-override check.
This command was used:
tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
-checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix \
-format
llvm-svn: 234680
On Windows, we have to know if a memory to be protected is mapped or not.
On POSIX, Mprotect was semantically different from mprotect most people know.
llvm-svn: 234602
Moving the implementation of several functions from sanitizer_symbolizer.cc into sanitizer_symbolizer_libcdep.cc.
Reviewed at http://reviews.llvm.org/D8858
llvm-svn: 234472
This patch is related to Issue 346: moar string interceptors: strstr, strcasestr, strcspn, strpbrk
As was suggested in original review http://reviews.llvm.org/D6056 a new "strict_string_checks" run-time flag introduced.
The flag support applied for existing common, asan, msan and tsan interceptors. New asan tests added.
Change by Maria Guseva reviewed in http://reviews.llvm.org/D7123
llvm-svn: 234187
This adds hard-float implementation for the following builtins:
* __fixdfdi()
* __fixsfdi()
* __fixunsdfdi()
* __fixunssfdi()
The soft-float implementation does never raise floating point
exceptions, which doesn't allow clients to detect floating point
conversion errors.
I must mention that I had to refer to libgcc's implementation to
write these functions.
Related unit-tests of compiler-rt passed with these changes.
Patch was somewhat out-dated, so was updated locally without any
functional changes.
Differential Revision: http://reviews.llvm.org/D5376
llvm-svn: 234148
MetaMap::ResetRange/FreeRange rounds the range up to at least kMetaShadowSize.
This is requried for e.g. free(malloc(0)). However, munmap returns EINVAL
and do not unmap any memory when length arguments is equal to 0.
So don't free meta shadow in this case as well.
llvm-svn: 234145
This avoids crashing or corrupting data if multiple concurrent
processes write to the same .gcda file. This is hard to test, since
the previous behaviour was a data race that often worked out, and it
ignores errors in flock to fall back to the old racy behaviour so that
it won't degrade the behaviour on filesystems that don't support
flock.
llvm-svn: 234036
Summary:
Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan
into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on
a platform, all UBSan sources are just compiled into dummy empty object
files. UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.
This mirrors the approach we already use for ASan+LSan. This change
doesn't modify the way we use standalone UBSan.
Test Plan: regression test suite
Reviewers: kubabrecka, zaks.anna, rsmith, kcc
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D8646
llvm-svn: 233861
This CL:
- moves PrepareForSandboxing() to sanitizer_posix_libcdep.cc
- fixes the coverage tests to use flag substitutions defined in r233802 and not rely on hardcoded shared library names
- moves those tests to TestCases/Posix so that they can be executed on Darwin
llvm-svn: 233828
r233802 has moved the tests above to Posix/ and introduced %ld_flags_rpath_so and %ld_flags_rpath_exe,
which haven't been defined for FreeBSD.
We expect the flags to be the same on Linux and FreeBSD. If there's another reason for the tests to fail on FreeBSD,
they'll need to be disabled.
llvm-svn: 233822
One test case is updated to allow for differences between power and other architectures in behavior when returning from main in certain instances
http://reviews.llvm.org/D8743
llvm-svn: 233813
Also make suppressions-library.cc use the same flags to avoid warnings about unused -rpath flags.
The same substitutions will be used to make coverage tests work on both Linux and Darwin without duplicating the code.
llvm-svn: 233802
It was happening when we looked up a PC for a module that was dlopen'ed/dlclose'd
after the last time we fetched the list of modules
Reviewed at http://reviews.llvm.org/D8618
llvm-svn: 233257
For OS X builds, both Make and CMake, let's be very explicit about using
libc++ and libc++abi with:
1) -stdlib=libc++ in CFLAGS and LDFLAGS for all platforms
2) -lc++ in LDFLAGS for all platforms
3) switch from -undefined dynamic_lookup to -lc++abi for UBSan in
Makefile-based builds
Reviewed at http://reviews.llvm.org/D8617
llvm-svn: 233215
On OS X 10.9 /usr/bin/atos prints the following warning upon invocation:
--
Warning: /usr/bin/atos is moving and will be removed from a future OS X release.
It is now available in the Xcode developer tools to be invoked via: `xcrun atos`
To silence this warning, pass the '-d' command-line flag to this tool.
--
AtosSymbolizer treats the warning as the symbolization result for the first PC passed to the symbolizer. As a result, for each of the following PCs the file:line info for the previous PC is printed, e.g.:
==97926==ERROR: AddressSanitizer: attempting double-free on 0x60200000dfb0 in thread T0:
==97926==Using atos at user-specified path: /usr/bin/atos
==97926==Using dladdr symbolizer.
#0 0x1007407e0 in -- (+0x427e0)
#1 0x1006f6f25 in wrap_free asan_malloc_mac.cc:114
#2 0x7fff916e05fc in main atos-symbolizer.cc:17
#3 0x0 (<unknown module>)
Unfortunately atos doesn't accept the -d switch on OSX versions other than 10.9, thus we have to check for the OSX version.
llvm-svn: 233180
This change caused test failures on darwin, and the followup which was
meant to fix those caused compiler-rt to start failing to link.
Reverting to get the build working again.
This reverts r233071 and r233036.
llvm-svn: 233097
Summary:
Switch to shared library for UBSan. Add support for building
UBSan on OSX and iossim by cargo-culting ASan build rules.
Test Plan: regression test suite
Reviewers: zaks.anna, kubabrecka
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D8473
llvm-svn: 233036
Get rid of "libclang_rt.san" library that used to contain
sanitizer_common pieces required by UBSan if it's used in a standalone
mode. Instead, build two variants of UBSan runtime: "ubsan" and
"ubsan_standalone" (same for "ubsan_cxx" and "ubsan_standalone_cxx").
Later "ubsan" and "ubsan_cxx" libraries will go away, as they will
embedded it into corresponding ASan runtimes.
llvm-svn: 233011