Commit Graph

2287 Commits

Author SHA1 Message Date
Kostya Serebryany ad272b0861 [asan] fix one more case where stack-use-after-return is not async-signal-safe (during thread startup). beef-up the test to give it a chance to catch regressions. Also relax the lint to make C++11 more usable.
llvm-svn: 304598
2017-06-02 21:32:04 +00:00
Kostya Serebryany 124c2ae4fa [sanitizer-coverage] nuke more stale code
llvm-svn: 304508
2017-06-02 01:17:04 +00:00
Kostya Serebryany 70c64869b5 [sanitizer-coverage] nuke more stale code
llvm-svn: 304500
2017-06-01 23:56:49 +00:00
Vedant Kumar 41dfc4f1fa [ubsan] Runtime support for pointer overflow checking
Patch by John Regehr and Will Dietz!

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

llvm-svn: 304461
2017-06-01 19:40:59 +00:00
Vedant Kumar 8f5073446f Tighten up test to address bot failure. NFC.
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/32035

llvm-svn: 304440
2017-06-01 17:56:12 +00:00
Vedant Kumar 9af30e3541 Bug 33221 [UBSAN] segfault with -fsanitize=undefined
There is can be a situation when vptr is not initializing
by constructor of the object, and has a junk data which should
be properly checked, because c++ standard says:

"if default constructor is not specified
16 (7.3) no initialization is performed."

Patch by Denis Khalikov!

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

llvm-svn: 304437
2017-06-01 16:44:11 +00:00
Pierre Gousseau 183d1368f3 [asan] Add strndup/__strndup interceptors.
Recommit of r302781 with Vitaly Buka's fix for non zero terminated strings.

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

llvm-svn: 304399
2017-06-01 09:37:22 +00:00
Kostya Serebryany 9c50876120 [sanitizer-coverage] remove stale code (old coverage); compiler-rt part
llvm-svn: 304318
2017-05-31 18:26:32 +00:00
Maxim Ostapenko 62a0f55930 [sanitizer] Avoid possible deadlock in child process after fork
This patch addresses https://github.com/google/sanitizers/issues/774. When we
fork a multi-threaded process it's possible to deadlock if some thread acquired
StackDepot or allocator internal lock just before fork. In this case the lock
will never be released in child process causing deadlock on following memory alloc/dealloc
routine. While calling alloc/dealloc routines after multi-threaded fork is not allowed,
most of modern allocators (Glibc, tcmalloc, jemalloc) are actually fork safe. Let's do the same
for sanitizers except TSan that has complex locking rules.

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

llvm-svn: 304285
2017-05-31 07:28:09 +00:00
Alex Shlyapnikov f8f8f49a24 [asan] Enable back halt_on_error-torture.cc disabled on PowerPC.
Summary:
D33521 addressed a memory ordering issue in BlockingMutex, which seems
to be the cause of a flakiness of a few ASan tests on PowerPC.

Reviewers: eugenis

Subscribers: kubamracek, nemanjai, llvm-commits

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

llvm-svn: 304045
2017-05-26 23:14:06 +00:00
Vitaly Buka e8b09195fa [compiler-rt] Don't reset non-default user handler if allow_user_segv_handler is true.
Reviewers: eugenis, kcc

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 304039
2017-05-26 21:51:26 +00:00
Renato Golin 5ade1f1c86 [LSAN-ARM] Marking new test unsupported on ARMHF due to bot failures
The test was meant for Darwin anyway, so I'm not even sure it's supposed
to run on Linux. If it was, then we need time to investigate, but since
the test is new, there's no point in reverting the whole patch because
of it.

llvm-svn: 304010
2017-05-26 17:31:33 +00:00
Alex Shlyapnikov 23ff882e45 [asan] Enable back some ASan tests disabled on PowerPC.
Summary:
D33521 addressed a memory ordering issue in BlockingMutex, which seems
to be the cause of a flakiness of a few ASan tests on PowerPC.

Reviewers: eugenis

Subscribers: kubamracek, nemanjai, llvm-commits

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

llvm-svn: 303995
2017-05-26 14:49:42 +00:00
Vitaly Buka a05da1fca9 [compiler-rt] Replace allow_user_segv_handler=0 with kHandleSignalExclusive
Summary:
allow_user_segv_handler had confusing name did not allow to control behavior for
signals separately.

Reviewers: eugenis, alekseyshl, kcc

Subscribers: llvm-commits, dberris, kubamracek

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

llvm-svn: 303941
2017-05-25 23:42:33 +00:00
Kostya Serebryany f3509b6d9b [asan] relax sanbox_read_proc_self_maps_test to pass even if unshare() fails.
llvm-svn: 303911
2017-05-25 20:50:36 +00:00
Francis Ricci 86e070f7e9 Implement tls scanning for darwin LSan
Summary:
This required for any users who call exit() after creating
thread-specific data, as tls destructors are only called when
pthread_exit() or pthread_cancel() are used. This should also
match tls behavior on linux.

Getting the base address of the tls section is straightforward,
as it's stored as a section offset in %gs. The size is a bit trickier
to work out, as there doesn't appear to be any official documentation
or source code referring to it. The size used in this patch was determined
by taking the difference between the base address and the address of the
subsequent memory region returned by vm_region_recurse_64, which was
1024 * sizeof(uptr) on all threads except the main thread, where it was
larger. Since the section must be the same size on all of the threads,
1024 * sizeof(uptr) seemed to be a reasonable size to use, barring
a more programtic way to get the size.

1024 seems like a reasonable number, given that PTHREAD_KEYS_MAX
is 512 on darwin, so pthread keys will fit inside the region while
leaving space for other tls data. A larger size would overflow the
memory region returned by vm_region_recurse_64, and a smaller size
wouldn't leave room for all the pthread keys. In addition, the
stress test added here passes, which means that we are scanning at
least the full set of possible pthread keys, and probably
the full tls section.

Reviewers: alekseyshl, kubamracek

Subscribers: krytarowski, llvm-commits

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

llvm-svn: 303887
2017-05-25 17:41:13 +00:00
Adam Nemet 14205b4a76 Disable two more flaky ASan wait* tests temporarily on Darwin
llvm-svn: 303885
2017-05-25 17:24:54 +00:00
Dimitry Andric 8779ea7aed Add generic __bswap[ds]i2 implementations
Summary:
In FreeBSD we needed to add generic implementations for `__bswapdi2` and
`__bswapsi2`, since gcc 6.x for mips is emitting calls to these.  See:

https://reviews.freebsd.org/D10838 and https://reviews.freebsd.org/rS318601

The actual mips code generated for these generic C versions is pretty
OK, as can be seen in the (FreeBSD) review.

I checked over gcc sources, and it seems that it can emit these calls on
more architectures, so maybe it's best to simply always add them to the
compiler-rt builtins library.

Reviewers: howard.hinnant, compnerd, petarj, emaste

Reviewed By: compnerd, emaste

Subscribers: mgorny, llvm-commits, arichardson

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

llvm-svn: 303866
2017-05-25 14:52:14 +00:00
Bill Seurer ec372bd8ed [powerpc] deactivate flakey test halt_on_error-torture.cc on powerpc64 be
This test case occassionally fails when run on powerpc64 be.

asan/TestCases/Posix/halt_on_error-torture.cc

The failure causes false problem reports to be sent to developers whose
code had nothing to do with the failures.  Reactivate it when the real
problem is fixed.

This could also be related to the same problems as with the tests
ThreadedOneSizeMallocStressTest, ThreadedMallocStressTest, ManyThreadsTest,
and several others that do not run reliably on powerpc.

llvm-svn: 303864
2017-05-25 14:41:58 +00:00
Bill Seurer 37c9be9393 [PowerPC] Fix test case sem_init_glibc.cc for powerpc64be
This test case fails on powerpc64be with older glibcs because of the glibc
version test.

llvm-svn: 303863
2017-05-25 14:32:22 +00:00
Hans Wennborg 0eec1f0b96 Fix negate-overflow.cpp test on Windows after r303440
lit would interpret the exit code as failuire.

llvm-svn: 303809
2017-05-24 21:52:40 +00:00
Adam Nemet 4f4748557e Disable flaky ASan tests temporarily on darwin
llvm-svn: 303662
2017-05-23 17:50:48 +00:00
Dean Michael Berris 36778a54fe [XRay][compiler-rt] Add __xray_remove_customevent_handler(...)
This change adds __xray_remove_customevent_handler(...) to be consistent
with other APIs that add/remove handlers.

llvm-svn: 303526
2017-05-22 03:23:54 +00:00
Vitaly Buka 8018780d39 [compiler-rt] Switch handle_<signal> flags from bool to enum.
Summary: We are going to make it tri-state and remove allow_user_segv_handler.

Reviewers: eugenis, alekseys, kcc

Subscribers: kubamracek, dberris, llvm-commits

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

llvm-svn: 303464
2017-05-19 22:37:16 +00:00
Daniel Jasper f97310fb7a Revert r302781 and subsequent attempts to disable part of it.
The Msan unit tests are still broken and by this point, I think we
should start over.

llvm-svn: 303339
2017-05-18 09:31:37 +00:00
Diana Picus 44514860f4 Fixup r303324 - temporary disable stndup interceptor, due to r302781 being buggy
r303324 missed one of the tests added by r302781. This commit applies
the same fix as r303324 to the missed test (strndup.cc).

llvm-svn: 303338
2017-05-18 09:12:27 +00:00
Kostya Serebryany 9aa8ef8504 temporary disable stndup interceptor, due to r302781 being buggy
llvm-svn: 303324
2017-05-18 03:00:07 +00:00
Tim Shen af3ffcc1f8 [XRay] Fix __xray_function_address on PPC reguarding local entry points.
Reviewers: echristo, dberris

Subscribers: llvm-commits

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

llvm-svn: 303302
2017-05-17 21:20:00 +00:00
Francis Ricci 3b57da0c73 Revert "Implement tls scanning for darwin LSan"
This reverts r303262, due to TSan buildbot breakages.

llvm-svn: 303266
2017-05-17 15:25:41 +00:00
Francis Ricci eab89eb850 Implement tls scanning for darwin LSan
Summary:
This required for any users who call exit() after creating
thread-specific data, as tls destructors are only called when
pthread_exit() or pthread_cancel() are used. This should also
match tls behavior on linux.

Getting the base address of the tls section is straightforward,
as it's stored as a section offset in %gs. The size is a bit trickier
to work out, as there doesn't appear to be any official documentation
or source code referring to it. The size used in this patch was determined
by taking the difference between the base address and the address of the
subsequent memory region returned by vm_region_recurse_64, which was
1024 * sizeof(uptr) on all threads except the main thread, where it was
larger. Since the section must be the same size on all of the threads,
1024 * sizeof(uptr) seemed to be a reasonable size to use, barring
a more programtic way to get the size.

1024 seems like a reasonable number, given that PTHREAD_KEYS_MAX
is 512 on darwin, so pthread keys will fit inside the region while
leaving space for other tls data. A larger size would overflow the
memory region returned by vm_region_recurse_64, and a smaller size
wouldn't leave room for all the pthread keys. In addition, the
stress test added here passes, which means that we are scanning at
least the full set of possible pthread keys, and probably
the full tls section.

Reviewers: alekseyshl, kubamracek

Subscribers: krytarowski, llvm-commits

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

llvm-svn: 303262
2017-05-17 14:35:17 +00:00
Kostya Serebryany 130fca1882 [asan] make asan under sandboxes more robust
llvm-svn: 303132
2017-05-15 23:37:54 +00:00
Reid Kleckner 886d2e6ef0 [ubsan] Don't enable debug info in all tests
Add a lit substitution (I chose %gmlt) so that only stack trace tests
get debug info.

We need a lit substition so that this expands to -gline-tables-only
-gcodeview on Windows. I think in the future we should reconsider the
need for -gcodeview from the GCC driver, but for now, this is necessary.

llvm-svn: 303083
2017-05-15 17:25:10 +00:00
Reid Kleckner 999f74ad59 [ubsan] Enable debug info in test binaries
This fixes tests that use debug info to check ubsan stack traces.  One
was XFAILd on Windows and the other was actively failing for weeks.

llvm-svn: 302924
2017-05-12 17:06:16 +00:00
Francis Ricci fb3d1ea063 Disable two failing darwin lsan tests
These tests don't fail consistently in all cases, but they
fail most of the time on the buildbots. Mark as UNSUPPORTED for now to
avoid buildbots failing due to XPASS.

llvm-svn: 302920
2017-05-12 16:52:19 +00:00
Reid Kleckner 07c0dd7654 [asan/win] Re-enable Win64 asan tests on Win8+
Our theory is that reserving large amounts of shadow memory isn't
reliable on Win7 and earlier NT kernels. This affects the
clang-x64-ninja-win7 buildbot, which uses Windows 7.

llvm-svn: 302917
2017-05-12 16:30:56 +00:00
Francis Ricci b680e9742a Disable two failing darwin lsan tests
These are causing buildbot failures, disable for now.

llvm-svn: 302912
2017-05-12 16:01:15 +00:00
Francis Ricci fdcab2cbf2 Enable lsan test suite on Darwin x86_64 builds
Reviewers: kubamracek, alekseyshl

Subscribers: mgorny, llvm-commits

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

llvm-svn: 302904
2017-05-12 15:10:05 +00:00
Dean Michael Berris 1cc7504774 [XRay][compiler-rt] Only run custom event logging in x86_64-linux
We only have an implementation in x86_64 that works for the
patching/unpatching and runtime support (trampolines).

Follow-up to D30630.

llvm-svn: 302873
2017-05-12 05:13:11 +00:00
Dean Michael Berris 29e16deb17 [XRay][compiler-rt] Runtime changes to support custom event logging
Summary:
This change implements support for the custom event logging sleds and
intrinsics at runtime. For now it only supports handling the sleds in
x86_64, with the implementations for other architectures stubbed out to
do nothing.

NOTE: Work in progress, uploaded for exposition/exploration purposes.

Depends on D27503, D30018, and D33032.

Reviewers: echristo, javed.absar, timshen

Subscribers: mehdi_amini, nemanjai, llvm-commits

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

llvm-svn: 302857
2017-05-12 01:07:41 +00:00
Pierre Gousseau 9ce59db426 [asan] Test 'strndup_oob_test.cc' added in r302781 fails on the clang-cmake-thumbv7-a15-full-sh bot.
Marking as unsupported on armv7l-unknown-linux-gnueabihf, same as strdup_oob_test.cc

llvm-svn: 302807
2017-05-11 16:26:50 +00:00
Benjamin Kramer 71ed2e6457 Renumber test line number expectations after r302783.
Also remove a confused stable-runtimes requirement.

llvm-svn: 302801
2017-05-11 14:04:23 +00:00
Pierre Gousseau 24090e59ea [asan] Test 'strndup_oob_test.cc' added in r302781 fails on clang-s390x-linux.
Marking it as unsupported for now to hopefully make the bot green.

llvm-svn: 302789
2017-05-11 11:22:04 +00:00
Alexander Potapenko 65de57150e [msan] add a regression test for PR32842
Make sure MSan doesn't miss a bug comparing two integers with defined low bits.

llvm-svn: 302788
2017-05-11 11:12:26 +00:00
Renato Golin 29006dc724 [MSAN] test failed randomly on ARM when XFAILED for MIPS
llvm-svn: 302786
2017-05-11 11:05:52 +00:00
Simon Dardis 456218438a mips] XFAIL wcsncpy.cc test.
The stack unwinder fails to unwind the stack past the interceptor stack
frame, resulting in a test failure. XFAIL this for now.

llvm-svn: 302783
2017-05-11 09:56:01 +00:00
Pierre Gousseau 0550581070 [asan] Recommit of r301904: Add strndup/__strndup interceptors
Fix undeclared __interceptor_malloc in esan_interceptors.cc
Fix undeclared strnlen on OSX

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

llvm-svn: 302781
2017-05-11 08:53:24 +00:00
Tim Shen bb6fdd66fc [XRay] Fix XRay PPC return value bug.
Summary:
This bug is caused by the incorrect handling of return-value registers.

According to OpenPOWER 64-Bit ELF V2 ABI 2.2.5, up to 2 general-purpose
registers are going to be used for return values, and up to 8 floating
point registers or vector registers are going to be used for return
values.

Reviewers: dberris, echristo

Subscribers: nemanjai, llvm-commits

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

llvm-svn: 302691
2017-05-10 16:28:21 +00:00
Tim Shen 40c012654e [XRay] Fix the test func-id-utils.cc on PPC.
Summary:
The test fails on PPC, because the address of a function may vary
depending on whether the "taker" shares the same ToC (roughly, in the
same "module") as the function.

Therefore the addresses of the functions taken in func-id-utils.cc may be
different from the addresses taken in xray runtime.

Change the test to be permissive on address comparison.

Reviewers: dberris, echristo

Subscribers: llvm-commits

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

llvm-svn: 302686
2017-05-10 16:07:03 +00:00
Simon Dardis be1d6315e1 [mips] XFAIL getpwnam_r_invalid_user.cc test
XFAIL this test while we investigate the root cause.

llvm-svn: 302635
2017-05-10 10:58:11 +00:00
Ivan A. Kosarev e73af512a6 [Safestack] Fix the canary test to catch the libc's message regarding stack smashing
By default glibc writes its diagnostics directly to tty so the `2>&1 |`
redirection in the test doesn't catch the *** stack smashing detected ***
message, which in turn breaks printing the lit's progress bar. By defining
the LIBC_FATAL_STDERR_ environment variable we force glibc to direct
diagnostic messages to stderr.

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

llvm-svn: 302628
2017-05-10 08:06:42 +00:00