Commit Graph

124 Commits

Author SHA1 Message Date
Alexey Samsonov 1be519876d [Sanitizer] Fix StripPathPrefix function and improve test case.
llvm-svn: 230986
2015-03-02 18:55:46 +00:00
Alexey Samsonov 0b0cafc8fc [Sanitizer] Print column number in SUMMARY line if it's available.
llvm-svn: 230721
2015-02-27 02:29:25 +00:00
Alexey Samsonov d2c20c49f8 [Sanitizer] Move TemplateMatch() to sanitizer_common.cc. NFC.
llvm-svn: 229923
2015-02-19 22:56:47 +00:00
Evgeniy Stepanov f074b3c2de [asan] Allow changing verbosity in activation flags.
This change removes some debug output in asan_flags.cc that
was reading the verbosity level before all the flags were parsed.

llvm-svn: 226566
2015-01-20 13:21:20 +00:00
Evgeniy Stepanov 5450a9635a [sanitizer] Additional error checking.
llvm-svn: 226279
2015-01-16 15:25:16 +00:00
Alexey Samsonov a04ca22edf Fix memory leaks in GetListOfModules() users.
llvm-svn: 225472
2015-01-08 22:31:14 +00:00
Alexey Samsonov b40fd1b24e [Sanitizer] Remove the hardcoded limit of address ranges in LoadedModule.
This should fix https://code.google.com/p/address-sanitizer/issues/detail?id=368.

llvm-svn: 225469
2015-01-08 22:03:05 +00:00
Kostya Serebryany 42102b110e [asan] introduce __sanitizer_set_death_callback, deprecate __asan_set_death_callback
llvm-svn: 224286
2014-12-15 23:02:57 +00:00
Alexey Samsonov 2c3045f1b9 [Sanitizer] Don't modify mmap_limit_mb flag in runtime.
Instead, rely on the fact that RAW_CHECK doesn't call mmap(),
and we'll be able to print an error message and kill a program.

llvm-svn: 224034
2014-12-11 18:45:24 +00:00
Alexey Samsonov 3a41ed1574 [Sanitizer] Fix report_path functionality:
Summary:
  - Make sure mmap() is never called inside RawWrite function.
  - Wrap a bunch of standalone globals in a ReportFile object.
  - Make sure accesses to these globals are thread-safe.
  - Fix report_path functionality on Windows, where
    __sanitizer_set_report_path() would break program.

I've started this yak shaving in order to make
"CommonFlags::mmap_limit_mb" immutable. Currently we drop this flag
to zero before printing an error message.

Test Plan: regression test suite

Reviewers: kcc, glider

Subscribers: llvm-commits

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

llvm-svn: 224031
2014-12-11 18:30:25 +00:00
Alexey Samsonov 656c29b08f Replace InternalScopedBuffer<char> with InternalScopedString where applicable.
Summary: No functionality change.

Test Plan: make check-all

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 223164
2014-12-02 22:20:11 +00:00
Yury Gribov ecfa592671 Removed r221896, it seems to break build in various ways.
llvm-svn: 221912
2014-11-13 19:37:30 +00:00
Yury Gribov 17072ef348 [ASan] Add process basename to log name and error message to simplify analysis of sanitized systems logs.
Reviewed at http://reviews.llvm.org/D5724

llvm-svn: 221896
2014-11-13 16:01:23 +00:00
Alexey Samsonov 70f3897b0a [Sanitizer] Introduce generic stack frame rendering machinery
Summary:
This commit introduces function __sanitizer::RenderFrame()
that allows to render the contents of AddressInfo (essentially, symbolized stack frame)
using the custom format string. This function can be used to
implement stack frame formatting for both ThreadSanitizer and
generic StackTrace::Print(), used in another places. This paves the
way towards allowing user to control the format of stack frames,
obtaining them in any format he desires, and/or enforcing the consistent
output from all sanitizers.

Test Plan: compiler-rt test suite

Reviewers: kcc

Reviewed By: kcc

Subscribers: llvm-commits

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

llvm-svn: 221409
2014-11-05 22:44:36 +00:00
Alexey Samsonov 26ca05ad96 [Sanitizer] Get rid of unnecessary allocations in StripModuleName. NFC.
llvm-svn: 221287
2014-11-04 19:34:29 +00:00
Alexey Samsonov 611c906cb3 [Sanitizer] Get rid of Symbolizer::Get() and Symbolizer::GetOrNull().
We may as well just use Symbolizer::GetOrInit() in all the cases.
Don't call Symbolizer::Get() early in tools initialization: these days
it doesn't do any important setup work, and we may as well create the
symbolizer the first time it's actually needed.

llvm-svn: 217558
2014-09-10 22:45:09 +00:00
Evgeniy Stepanov b2b4c3ab32 [asan] Exclude non-executable mappings from coverage.
llvm-svn: 210649
2014-06-11 10:11:51 +00:00
Evgeniy Stepanov 567e516015 [asancov] Write coverage directly to a memory-mapped file.
This way does not require a __sanitizer_cov_dump() call. That's
important on Android, where apps can be killed at arbitrary time.

We write raw PCs to disk instead of module offsets; we also write
memory layout to a separate file. This increases dump size by the
factor of 2 on 64-bit systems.

llvm-svn: 209653
2014-05-27 12:37:52 +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
Dmitry Vyukov b7ebc53772 tsan: stop background thread when sandbox is enabled
Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=56

llvm-svn: 207114
2014-04-24 13:09:17 +00:00
Alexander Potapenko 65a6c57013 [ASan] Replace a CHECK for mmap_limit_mb with a RAW_CHECK.
In the case of a CHECK failure the program tries to fork and launch llvm-symbolizer,
but hangs in mz_force_lock because one of the allocator locks is already acquired.

llvm-svn: 206274
2014-04-15 11:36:18 +00:00
Kostya Serebryany b1232474b2 [asan] try fixing the mmap_limit_mb failure on buildbot (tests pass locally)
llvm-svn: 206262
2014-04-15 08:35:43 +00:00
Kostya Serebryany bcfbea6d4e [asan] added internal flag mmap_limit_mb
llvm-svn: 206178
2014-04-14 14:51:01 +00:00
Joerg Sonnenberger 9d09e2fe90 Reapply r201910. MSVC gets __func__ defined explicitly, even though it
can't build anything here.

llvm-svn: 202297
2014-02-26 20:33:22 +00:00
Reid Kleckner 324eee45a7 Revert "Replace __FUNCTION__ with __func__, the latter being standard C99/C++11."
This reverts commit r201910.

While __func__ may be standard in C++11, it was only recently added to
MSVC in 2013 CTP, and LLVM supports MSVC 2012.  __FUNCTION__ may not be
standard, but it's *very* portable.

llvm-svn: 201916
2014-02-22 00:37:45 +00:00
Joerg Sonnenberger b15779f307 Replace __FUNCTION__ with __func__, the latter being standard C99/C++11.
llvm-svn: 201910
2014-02-21 23:55:15 +00:00
Alexey Samsonov 6322e036aa [Sanitizer] Replace Symbolizer::IsAvailable and Symbolizer::IsExternalAvailable with Symbolizer::CanReturnFileLineInfo.
Remove now redundant checks in symbolizer initialization in TSan and MSan.

llvm-svn: 198000
2013-12-25 07:09:44 +00:00
Timur Iskhodzhanov b5f983e4b0 [Sanitizers] Rename Symbolizer::SymbolizeCode to Symbolizer::SymbolizePC
llvm-svn: 197569
2013-12-18 14:17:39 +00:00
Sergey Matveev 7bc300c8fc [sanitizer] Fix log_path behavior with StopTheWorld.
Summary:
Fix race on report_fd/report_fd_pid between the parent process and the
tracer task.

Reviewers: samsonov

Reviewed By: samsonov

CC: llvm-commits, kcc, dvyukov

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

llvm-svn: 196385
2013-12-04 14:37:01 +00:00
Bob Wilson a08e9ac927 Reapply asan coverage changes 194702-194704.
I still don't know what is causing our bootstrapped LTO buildbots to fail,
but llvm r194701 seems to be OK and I can't imagine that these changes could
cause the problem.

llvm-svn: 194790
2013-11-15 07:18:15 +00:00
Bob Wilson abc91eacac Speculatively revert asan coverage changes 194702-194704.
Apple's bootstrapped LTO builds have been failing, and these changes (along
with llvm 194701) are the only things on the blamelist.  I will either reapply
these changes or help debug the problem, depending on whether this fixes the
buildbots.

llvm-svn: 194779
2013-11-15 03:26:28 +00:00
Kostya Serebryany 91c52d9552 [asan] Poor man's coverage that works with ASan (compiler-rt part)
llvm-svn: 194702
2013-11-14 13:28:17 +00:00
Alexey Samsonov 4d369187ec [Sanitizer] Print symbolized stack frame using a single Printf() call.
This reduces the number of "write" syscalls performed to print a single
stack frame description, and makes sanitizer output less intermixed with
program output. Also, add a number of unit tests.

llvm-svn: 194686
2013-11-14 09:41:24 +00:00
Alexey Samsonov 498e5906ad [Sanitizer] Add print_summary runtime flag to disable error summaries (UBSan doesn't need them)
llvm-svn: 194685
2013-11-14 08:56:59 +00:00
Alexey Samsonov 31d4c34433 [Sanitizer] Fix Go build
llvm-svn: 193873
2013-11-01 18:00:22 +00:00
Alexey Samsonov 5dc6cff06a [Sanitizer] Unify summary reporting across all sanitizers.
This change unifies the summary printing across sanitizers:
now each tool uses specific version of ReportErrorSummary() method,
which deals with symbolization of the top frame and formatting a
summary message. This change modifies the summary line for ASan+LSan mode:
now the summary mentions "AddressSanitizer" instead of "LeakSanitizer".

llvm-svn: 193864
2013-11-01 17:02:14 +00:00
Nick Lewycky 622348e693 Hoist the addition of the prefix "SUMMARY: " from
__sanitizer_report_error_summary to ReportErrorSummary.

llvm-svn: 193231
2013-10-23 07:45:53 +00:00
Dmitry Vyukov 21e99319f4 tsan: be silent if verbosity=0
Currently tests fail with:
Check failed: 'AAA' == 'AAA ==26017==Could not detach from thread 361395 (errno 3).'

llvm-svn: 192711
2013-10-15 15:35:56 +00:00
Dmitry Vyukov 7ac0b2b0e1 tsan: use sanitizer::CommonFlags in tsan
llvm-svn: 192692
2013-10-15 12:25:29 +00:00
Alexey Samsonov f2b811a618 Refactor the usage of strip_path_prefix option and make it more consistent across sanitizers
llvm-svn: 191943
2013-10-04 08:55:03 +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
Sergey Matveev ef7db73e11 [sanitizer] Handle Die() in StopTheWorld.
Handle calls to Die() from the tracer thread. Fixes a bug where a CHECK
could fail in the tracer thread, resulting in a call to AsanDie. The tracer
thread then exited and the parent process continued execution despite its
address space being in an unusable state.

llvm-svn: 189216
2013-08-26 13:20:31 +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 6d4a7d3723 [nolibc] Begin moving sanitizer_common's libc-dependent code to a separate library
Introduce a new object library, RTSanitizerCommonLibc, which will contain
the subset of sanitizer_common with libc dependencies. RTSanitizerCommon
contains the remainder of sanitizer_common, and is intended to have no
libc dependencies. Begin moving code to RTSanitizerCommonLibc, starting
with sanitizer_common.cc, whose libc-dependent portion is moved to
sanitizer_common_libcdep.cc, the first member of the new library.

This split affects the CMake build only.  The makefile build continues
to produce the full sanitizer_common library.

llvm-svn: 182118
2013-05-17 16:17:19 +00:00
Sergey Matveev d9da20f56f [sanitizer] Generic sorting in sanitizer_common.
llvm-svn: 181698
2013-05-13 11:58:48 +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
Alexander Potapenko 845b575370 [libsanitizer] StopTheWorld in sanitizer_common
StopTheWorld puts the process in a suspended state before running the
user-supplied callback. To be used in TSan and in leak checking code.

Linux implementation provided.

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 177156
2013-03-15 14:37:21 +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
Kostya Serebryany 7b0b9b3b65 [msan] add strip_path_prefix flag; print error summary; don't crash while printing summary if debug info is missing. The tests will follow later once we establish the lit-like tests for msan.
llvm-svn: 174595
2013-02-07 08:04:56 +00:00
Kostya Serebryany 4fb340d972 [tsan] print error summary line
llvm-svn: 174505
2013-02-06 14:24:00 +00:00
Kostya Serebryany b4c2c5c8a6 [asan] print a short one-line report summary after the full report. Currently, works only if symbolization happens in-process.
llvm-svn: 174501
2013-02-06 12:36:49 +00:00
Alexey Samsonov 39313b780d [Sanitizer] make internal_open have the same interface as libc version
llvm-svn: 174187
2013-02-01 15:58:46 +00:00
Kostya Serebryany bda64b4d40 [sanitizer] make the error messages from sanitizer_common contain the actual tool name
llvm-svn: 174059
2013-01-31 14:11:21 +00:00
Alexey Samsonov 2d04812a45 Fixup for r172828: use InternalScopedBuffer in favor of large stack buffers
llvm-svn: 172975
2013-01-20 13:22:06 +00:00
Alexander Potapenko b4ba995366 [ASan] Fix the log_path option to use different log files for parent and child processes after fork().
llvm-svn: 172828
2013-01-18 16:44:27 +00:00
Dmitry Vyukov af96edbad2 asan: fix format string in CHECK
llvm-svn: 172203
2013-01-11 15:07:49 +00:00
Kostya Serebryany 5e2a7acdbe [asan] more sceleton code for asan_allocator2
llvm-svn: 169836
2012-12-11 09:02:36 +00:00
Alexander Potapenko 1746f555ee Add a libsanitizer API __sanitizer_sandbox_on_notify(void* reserved), which should be used by
the client programs to notify the tools that sandboxing is about to be turned on.

llvm-svn: 169732
2012-12-10 13:10:40 +00:00
Dmitry Vyukov e3e0557f19 tsan: fix lint warning and make output tests more robust
llvm-svn: 169511
2012-12-06 15:42:54 +00:00
Bill Wendling f9528843d2 Remove unused variable.
llvm-svn: 169485
2012-12-06 07:43:17 +00:00
Kostya Serebryany 1e3d387459 [tsan] add MmapAlignedOrDie
llvm-svn: 169474
2012-12-06 06:10:31 +00:00
Kostya Serebryany f22c697f58 [asan] get rid of some of the uses of kPageSize. The intent is to get rid of it completely to support platforms with multiple possible page sizes.
llvm-svn: 168517
2012-11-23 15:38:49 +00:00
Alexey Samsonov 58358897a3 [Sanitizer] Add internal_isatty to sanitizer_libc and PrintsToTty to determine whether error reports are printed to terminal
llvm-svn: 167298
2012-11-02 15:18:34 +00:00
Alexey Samsonov 008274440a [Sanitizer] move unit test for Printf from tsan to sanitizer_common
llvm-svn: 167296
2012-11-02 12:36:11 +00:00
Alexey Samsonov 20ba98fdb1 [Sanitizer] Use kStderrFd constant instead of hardcoded 2
llvm-svn: 167291
2012-11-02 09:38:47 +00:00
Alexey Samsonov fd67c83e7e [Sanitizer]: add __sanitizer_set_report_fd function to alter file descriptor for error reports
llvm-svn: 167290
2012-11-02 09:23:36 +00:00
Kostya Serebryany 45d849c4bd [asan] add asan option log_path=PATH to let users redirect asan reports to a file PATH.PID instead of stderr
llvm-svn: 163872
2012-09-14 04:35:14 +00:00
Alexey Samsonov 5c6b93bc33 [Sanitizer] Get rid of dependency between sanitizer_common and asan/tsan runtimes: implement tool-specific Die and CheckFailed functions via callbacks
llvm-svn: 163603
2012-09-11 09:44:48 +00:00
Alexey Samsonov d77fbba74a [Sanitizer] implement straightforward nlogn sorting, as qsort() may call malloc, which leads to deadlock in ASan allocator
llvm-svn: 160262
2012-07-16 11:27:17 +00:00
Dmitry Vyukov 5dc3f01676 tsan/asan: kill STL
First, placement new from standard library conflicts with our own.
Second, we are in trouble if user uses the same function (we either get instrumented code in runtime, or non-instrumented code in user program).

llvm-svn: 159738
2012-07-05 09:23:37 +00:00
Alexey Samsonov e4a889866d [Sanitizer] move atomic ops, min/max and sort to commnon runtime
llvm-svn: 158496
2012-06-15 07:00:31 +00:00
Alexey Samsonov fe44fbd750 [Sanitizer] Move ReadFileToBuffer to sanitizer_common.
llvm-svn: 158138
2012-06-07 05:38:26 +00:00
Alexey Samsonov ee07290628 [Sanitizer] Move more functions/constants to sanitizer_common.
llvm-svn: 158056
2012-06-06 09:26:25 +00:00