Commit Graph

95 Commits

Author SHA1 Message Date
Alexey Samsonov 9c85927012 [Sanitizer] Make StackTrace a lightweight reference to array of PCs, and
introduce a BufferedStackTrace class, which owns this array.

Summary:
This change splits __sanitizer::StackTrace class into a lightweight
__sanitizer::StackTrace, which doesn't own array of PCs, and BufferedStackTrace,
which owns it. This would allow us to simplify the interface of StackDepot,
and eventually merge __sanitizer::StackTrace with __tsan::StackTrace.

Test Plan: regression test suite.

Reviewers: kcc, dvyukov

Reviewed By: dvyukov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5985

llvm-svn: 220635
2014-10-26 03:35:14 +00:00
Alexey Samsonov 1947bf9921 PR20721: Don't let UBSan print inaccessible memory
Summary:
UBSan needs to check if memory snippet it's going to print resides
in addressable memory. Similar check might be helpful in ASan with
dump_instruction_bytes option (see http://reviews.llvm.org/D5167).

Instead of scanning /proc/self/maps manually, delegate this check to
the OS kernel: try to write this memory in a syscall and assume that
memory is inaccessible if the syscall failed (e.g. with EFAULT).

Fixes PR20721.

Test Plan: compiler-rt test suite

Reviewers: eugenis, glider

Reviewed By: glider

Subscribers: emaste, ygribov, llvm-commits, glider, rsmith

Differential Revision: http://reviews.llvm.org/D5253

llvm-svn: 217971
2014-09-17 17:56:15 +00:00
Dmitry Vyukov aa8fa60ba8 tsan: unbreak windows build
Currently it fails with:

# Testing race detector.
race_windows_amd64.syso:gotsan.cc:(.text+0x4d89): undefined reference to `__imp_SymGetModuleBase64'
race_windows_amd64.syso:gotsan.cc:(.text+0x4d90): undefined reference to `__imp_SymFunctionTableAccess64'
race_windows_amd64.syso:gotsan.cc:(.text+0x4dd8): undefined reference to `__imp_StackWalk64'
x86_64-w64-mingw32/bin/ld.exe: race_windows_amd64.syso
: bad reloc address 0x10 in section `.data'
collect2.exe: error: ld returned 1 exit status

llvm-svn: 216875
2014-09-01 11:44:59 +00:00
Alexey Samsonov 34e2b280da [TSan] Share the code the setup code calling getrlim/setrlim with sanitizer_common
llvm-svn: 215481
2014-08-12 22:31:19 +00:00
Timur Iskhodzhanov 19853dd28c [ASan/Win] Catch NULL derefs and page faults
Reviewed at http://reviews.llvm.org/D4471

llvm-svn: 212807
2014-07-11 11:57:41 +00:00
Evgeniy Stepanov a00ff194b7 [asan] Add a few stubs to fix windows build.
llvm-svn: 209717
2014-05-28 08:26:24 +00:00
Sergey Matveev 6cb47a083b [sanitizer] Support sandboxing in sanitizer coverage.
Summary:
Sandboxed code may now pass additional arguments to
__sanitizer_sandbox_on_notify() to force all coverage data to be dumped to a
single file (the default is one file per module). The user may supply a file or
socket to write to. The latter option can be used to broker out the file writing
functionality. If -1  is passed, we pre-open a file.

llvm-svn: 209121
2014-05-19 12:53:03 +00:00
Timur Iskhodzhanov 7d5c81db0a [ASan/Win] Don't crash when ASAN_OPTIONS have disable_core=1
Reviewed at http://reviews.llvm.org/D3610

llvm-svn: 208070
2014-05-06 08:21:50 +00:00
Timur Iskhodzhanov 364b8b8fe5 [ASan] Print mmap errno/GetLastError in a readable and consistent way
Reviewed at http://llvm-reviews.chandlerc.com/D3107

llvm-svn: 204218
2014-03-19 08:23:00 +00:00
Alexey Samsonov 3e8467b8b9 Avoid doing any work when unwinding stack traces with 0 or 1 frame
llvm-svn: 202837
2014-03-04 12:21:28 +00:00
Evgeniy Stepanov e5a447d947 [asan] Fix Windows build.
llvm-svn: 201154
2014-02-11 13:57:17 +00:00
Timur Iskhodzhanov aeefb6abce [ASan/Win] Fall back to stdout if we can't print the reports to stderr
llvm-svn: 200804
2014-02-04 23:28:30 +00:00
Dmitry Vyukov a538aac8ce tsan: fix windows build
llvm-svn: 200778
2014-02-04 17:27:29 +00:00
Alexander Potapenko ea4a0dbb8d [ASan] Implement __sanitizer::InstallDeadlySignalHandlers() and __asan::AsanOnSIGSEGV() on Windows.
llvm-svn: 200554
2014-01-31 15:11:11 +00:00
Alexander Potapenko 789e3e1b7c [ASan] Move the SIGSEGV/SIGBUS handling to sanitizer_common
This change is a part of refactoring intended to have common signal handling behavior in all tools.
This particular CL moves InstallSignalHandlers() into sanitizer_common (making it InstallDeadlySignalHandlers()), but doesn't enable default signal handlers for any tool other than ASan.

llvm-svn: 200542
2014-01-31 13:10:07 +00:00
Alexander Potapenko d8d490ed50 [ASan] Move the sigaltstack() bits to sanitizer_common.
This change is a part of refactoring intended to have common signal handling behavior in all tools.
Note that this particular change doesn't enable use_sigaltstack support in every tool.

llvm-svn: 200310
2014-01-28 11:12:29 +00:00
Kostya Serebryany 57bfdb080b [asan] add flag uar_noreserve to use noreserve mmap for fake stack. uar_noreserve=1 will save some memory but also negatively affect performance
llvm-svn: 197233
2013-12-13 15:03:49 +00:00
Timur Iskhodzhanov 89a346c2a1 [ASan] Fix StackTrace::SlowUnwindStack on Windows
llvm-svn: 196894
2013-12-10 08:30:39 +00:00
Timur Iskhodzhanov 895392d03f [ASan] Use ExitProcess rather than _exit on Windows to avoid calling global dtors etc
llvm-svn: 195723
2013-11-26 09:40:39 +00:00
Timur Iskhodzhanov e87f5701bb Remove a FIXME now that I can't reproduce the problem
llvm-svn: 194331
2013-11-09 15:01:23 +00:00
Timur Iskhodzhanov 1f1c7ec400 [Sanitizers] Share some stack walking code between Windows and Linux
Reviewed at http://llvm-reviews.chandlerc.com/D2126

llvm-svn: 194326
2013-11-09 13:59:12 +00:00
Alexey Samsonov 5d350b2ab6 [Sanitizer] Presumable fix stack trace unwinding on Windows
llvm-svn: 194195
2013-11-07 06:53:41 +00:00
Alexey Samsonov e13f775a63 [Sanitizer] Call Windows unwinder 'slow' and share StackTrace::Unwind across all platforms. No functionality change.
llvm-svn: 194193
2013-11-07 06:33:06 +00:00
Alexey Samsonov 7f5823844a [Sanitizer] Remove StackTrace::max_depth field
llvm-svn: 192534
2013-10-12 12:40:47 +00:00
Alexey Samsonov c129e65661 [Sanitizer] Turn GetStackTrace() into StackTrace::Unwind()
llvm-svn: 192533
2013-10-12 12:23:00 +00:00
Alexey Samsonov 7a36e6126b [Sanitizer] Refactor symbolization interface: use class instead of several functions. Move some code around to get rid of extra source files
llvm-svn: 190410
2013-09-10 14:36:16 +00:00
Reid Kleckner d483c072af sanitizers: Make sure Visual Studio gets error reports
Visual Studio appears to close stderr before launching a non-console
win32 program.  This means we don't see any sanitizer reports.  If
stderr printing fails, call OutputDebugStringA to get the reports into
the Visual Studio debugger console.

llvm-svn: 190030
2013-09-05 03:19:57 +00:00
Timur Iskhodzhanov 2eea5894fe [asan] Hopefully un-break the RTL on Windows
llvm-svn: 189821
2013-09-03 15:50:13 +00:00
Alexey Samsonov de647ddc8b [Sanitizer] Add the way to find binary in PATH
llvm-svn: 189799
2013-09-03 13:20:48 +00:00
Timur Iskhodzhanov 4245f78fdd [ASan] Use less shadow on Win 32-bit
llvm-svn: 186393
2013-07-16 09:47:39 +00:00
Dmitry Vyukov 7e4a18c4fb tsan: fix merge bug
llvm-svn: 183648
2013-06-10 11:11:29 +00:00
Dmitry Vyukov b278f1235f tsan: fix windows crash (incorrect stack boundaries)
llvm-svn: 183646
2013-06-10 10:30:54 +00:00
Dmitry Vyukov e979c5467c tsan: fix windows mingw build
llvm-svn: 183644
2013-06-10 10:02:02 +00:00
Peter Collingbourne ffaf2eac4d [nolibc] Move all platforms to internal_getpid.
Before, we had an unused internal_getpid function for Linux, and a
platform-independent GetPid function.  To make the naming conventions
consistent for syscall-like functions, the GetPid syscall wrapper
in sanitizer_posix.cc is moved to sanitizer_mac.cc, and GetPid is
renamed to internal_getpid, bringing the Linux variant into use.

llvm-svn: 182132
2013-05-17 16:56:53 +00:00
Peter Collingbourne 53caf563a9 Try to fix Windows build too
llvm-svn: 181457
2013-05-08 18:15:01 +00:00
Peter Collingbourne 6f4be19b57 [nolibc] Change internal syscall API to remove reliance on libc's errno.
This change moves to a model where the error value of a system call is
potentially contained in the return value itself rather than being
implicit in errno.  The helper function internal_iserror can be used
to extract the error value from a return value.  On platforms other
than Linux/x86_64 this still uses errno, but other platforms are free
to port their error handling to this new model.

Differential Revision: http://llvm-reviews.chandlerc.com/D756

llvm-svn: 181436
2013-05-08 14:43:49 +00:00
Sergey Matveev af179b8d63 [sanitizer] Move GetStackTrace from ASan to sanitizer_common.
llvm-svn: 181424
2013-05-08 12:45:55 +00:00
Sergey Matveev 954c6ef10f [sanitizer] Move GetThreadStackAndTls from TSan to sanitizer_common.
Move this function to sanitizer_common because LSan uses it too. Also, fix a bug
where the TLS range reported for main thread was off by the size of the thread
descriptor from libc (TSan doesn't care much, but for LSan it's critical).

llvm-svn: 181322
2013-05-07 14:41:43 +00:00
Timur Iskhodzhanov 2dee3dd61c Add a GetTid() implementation for Windows
llvm-svn: 177927
2013-03-25 22:04:29 +00:00
Evgeniy Stepanov 0af672326a [sanitizer] Replace more platform checks with SANITIZER_ constants.
llvm-svn: 177400
2013-03-19 14:33:38 +00:00
Alexey Samsonov a097f7b1e3 [Sanitizer] Add default constructor for BlockingMutex
llvm-svn: 177072
2013-03-14 13:30:56 +00:00
Alexey Samsonov 7d2385419a [Sanitizer] fix compilation for Windows
llvm-svn: 177054
2013-03-14 11:29:06 +00:00
Alexey Samsonov 83e7622df6 [Sanitizer] Write a slightly better implementation of GetEnv() function on Windows
llvm-svn: 177051
2013-03-14 11:10:23 +00:00
Evgeniy Stepanov 5697b58ec4 [sanitizer] Move GetTlsSize code from TSan to sanitizer_common.
llvm-svn: 176938
2013-03-13 08:19:53 +00:00
Alexey Samsonov db7d9656bb [Sanitizer] Implement BlockingMutex::CheckLocked()
llvm-svn: 176805
2013-03-11 15:45:20 +00:00
Alexey Samsonov aadd1f2ad6 [Sanitizer] use raw syscall instead of _exit() function on Linux
llvm-svn: 175622
2013-02-20 13:54:32 +00:00
Alexey Samsonov 9211bd33ec [Sanitizer] Make temporary filename depend on user ID
llvm-svn: 175424
2013-02-18 07:17:12 +00:00
Timur Iskhodzhanov 167f9e4395 [ASan] Switch Windows to allocator v2, also fixing some build errors
llvm-svn: 174707
2013-02-08 12:02:00 +00:00
Dmitry Vyukov fa67ed47e1 asan/tsan: fix failing CHECK on windows
llvm-svn: 174319
2013-02-04 10:42:38 +00:00
Alexey Samsonov 2c5cbd2b38 [Sanitizer] extend internal libc with stat/fstat/lstat functions
llvm-svn: 174316
2013-02-04 10:16:50 +00:00