Commit Graph

86 Commits

Author SHA1 Message Date
Evgeniy Stepanov 769d46f373 [sanitizer] Use system unwinder in signal handlers on Android.
Because of the way Bionic sets up signal stack frames, libc unwinder is unable
to step through it, resulting in broken SEGV stack traces.

Luckily, libcorkscrew.so on Android implements an unwinder that can start with
a signal context, thus sidestepping the issue.

llvm-svn: 201151
2014-02-11 13:38:57 +00:00
Kostya Serebryany 336d97146a [asan] increase the buffer size for printing asan legend, add a test for legend
llvm-svn: 200387
2014-01-29 11:12:09 +00:00
Evgeniy Stepanov 20513c0937 [asan] More buffering in report printing.
llvm-svn: 199888
2014-01-23 11:51:03 +00:00
Evgeniy Stepanov 631bd92292 [asan] Print shadow memory and legend as a single printf call.
llvm-svn: 199878
2014-01-23 10:52:33 +00:00
Evgeniy Stepanov 4819d28e53 [asan] clang-format part of asan_report.cc
llvm-svn: 199877
2014-01-23 10:49:47 +00:00
Kostya Serebryany a650116adb [asan] convert a CHECK failure in __sanitizer_annotate_contiguous_container into a proper warning message
llvm-svn: 197899
2013-12-23 07:01:43 +00:00
Alexey Samsonov f2c7659cf8 [ASan] Get rid of ASan-specific functions for printing stack traces
llvm-svn: 197672
2013-12-19 11:25:05 +00:00
Kostya Serebryany 67968632ba [asan] rename contiguous-container-buffer-overflow (too long) to container-overflow
llvm-svn: 195352
2013-11-21 12:23:52 +00:00
Kostya Serebryany 7b664299f0 [asan] new shadow poison magic for contiguous-container-buffer-overflow, addressed Alexey Samsonov's comments for r195011
llvm-svn: 195117
2013-11-19 08:40:07 +00:00
Alexey Samsonov 9ff4598225 [ASan] Do not rely on malloc context in allocator reports.
Invoke a fatal stack trace unwinder when ASan prints allocator-relevant
error reports (double-free, alloc-dealloc-mismatch, invalid-free).
Thus we'll be able to print complete stack trace even if allocation/free
stacks are not stored (malloc_context_size=0).

Based on the patch by Yuri Gribov!

llvm-svn: 194579
2013-11-13 14:46:58 +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
Alexey Samsonov 590fe110f9 [Sanitizer] Revert r193501 and properly fix r193448
llvm-svn: 193522
2013-10-28 16:31:39 +00:00
Timur Iskhodzhanov a1d048acb7 Work around ASan/Win breakage by r193448
llvm-svn: 193501
2013-10-27 13:37:23 +00:00
Peter Collingbourne 791e65dcfb Overhaul the symbolizer interface.
This moves away from creating the symbolizer object and initializing the
external symbolizer as separate steps.  Those steps now always take place
together.

Sanitizers with a legacy requirement to specify their own symbolizer path
should use InitSymbolizer to initialize the symbolizer with the desired
path, and GetSymbolizer to access the symbolizer.  Sanitizers with no
such requirement (e.g. UBSan) can use GetOrInitSymbolizer with no need for
initialization.

The symbolizer interface has been made thread-safe (as far as I can
tell) by protecting its member functions with mutexes.

Finally, the symbolizer interface no longer relies on weak externals, the
introduction of which was probably a mistake on my part.

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

llvm-svn: 193448
2013-10-25 23:03:29 +00:00
Nick Lewycky d27d668342 Make sure ASan always emits an error summary if it reports an error.
llvm-svn: 193229
2013-10-23 06:19:04 +00:00
Kostya Serebryany 9628839869 [asan] reduce the size of AsanThreadContext by storing the stack trace in the stack depot
llvm-svn: 192979
2013-10-18 14:50:44 +00:00
Alexey Samsonov df6e6569c0 [ASan] Don't die with internal ASan error on large buffer overflows
Summary:
Out-of-bound access may touch not-yet allocated or already freed
and recycled from quarantine chunks. We should treat this situation as
a "free-range memory access" and avoid printing any data about that
irrelevant chunk (which may be inconsistent).

This should fix https://code.google.com/p/address-sanitizer/issues/detail?id=183

Reviewers: kcc

Reviewed By: kcc

CC: timurrrr, llvm-commits

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

llvm-svn: 192581
2013-10-14 11:13:54 +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 48e256466a [ASan] Check that getSymbolizer() is defined. Turn magic mapping constants into named variables
llvm-svn: 190787
2013-09-16 15:45:06 +00:00
Kostya Serebryany 729c8dc65b [asan] fully re-implement the FakeStack (use-after-return) to make it faster and async-signal-safe. The implementation is not yet complete (see FIXMEs) but the existing tests pass.
llvm-svn: 190588
2013-09-12 07:11:58 +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
Timur Iskhodzhanov 190784b21b [ASan] Don't crash in DescribeHeapAddress if we don't know the current thread's ID
Also make DescribeThread easier to use.
This was firing on Dr.ASan runs, not sure how to repro InvalidTID in a simple test.

llvm-svn: 190392
2013-09-10 08:36:21 +00:00
Timur Iskhodzhanov 2b8d35f8ac [asan] Hopefully fix the RTL build on Windows (part 2)
llvm-svn: 189817
2013-09-03 15:09:21 +00:00
Kostya Serebryany 14b7caca13 [asan] attemping to fix the Windows build
llvm-svn: 189814
2013-09-03 14:53:02 +00:00
Kostya Serebryany 6bafcd1949 implement PR17059: more visible diagnostics for stack-buffer-overflow
llvm-svn: 189806
2013-09-03 13:58:04 +00:00
Sergey Matveev b9d34443f2 [lsan] Colorize LSan reports.
llvm-svn: 189804
2013-09-03 13:31:03 +00:00
Kostya Serebryany 8d42228e47 fix PR17061 (and pleeease, don't ask me for a test, this is just a minor output formatting issue :)
llvm-svn: 189783
2013-09-03 09:44:56 +00:00
Timur Iskhodzhanov 10286e1e59 [ASan/RTL] Disable colored reporting on Windows
llvm-svn: 188545
2013-08-16 11:26:26 +00:00
Timur Iskhodzhanov eee13914e2 Define SANITIZER_INTERFACE_ATTRIBUTE on Windows and fix all the places where SANITIZER_INTERFACE_ATTRIBUTE or SANITIZER_ATTRIBUTE_WEAK are used
llvm-svn: 188261
2013-08-13 11:42:45 +00:00
Kostya Serebryany 6a068a715d [asan] initialize fake_stack lazily and increase its maximal size. This makes -fsanitize=address,use-after-return more robust: all SPEC tests pass now. In the default mode thread stacks become a bit smaller.
llvm-svn: 184934
2013-06-26 12:16:05 +00:00
Timur Iskhodzhanov cc61eefd4b Fix MSVC W3 compiler warnings
llvm-svn: 182857
2013-05-29 14:11:44 +00:00
Kostya Serebryany 6ca6ba2f2c [asan] fix the reported PCs for powerpc64
llvm-svn: 182477
2013-05-22 14:21:34 +00:00
Sergey Matveev 0c8ed9ce44 [asan] Common flags in ASan.
Some flags that are common to ASan/MSan/TSan/LSan have been moved to
sanitizer_common.

llvm-svn: 181193
2013-05-06 11:27:58 +00:00
Alexey Samsonov 46cc45a291 [ASan] Symbolize correct address when printint error summary
llvm-svn: 179274
2013-04-11 11:45:04 +00:00
Alexey Samsonov c0443c5d25 [ASan] fix a typo in legend in error report
llvm-svn: 179161
2013-04-10 07:00:25 +00:00
Kostya Serebryany 5b4267f7e7 [sanitizer] found a bug by code inspection: CHECK(a=b) instead of CHECK(a==b). Was puzzled why lint did not catch it. Turns out this check was disabled for asan source. fix all cases and enable the check
llvm-svn: 178872
2013-04-05 14:40:25 +00:00
Alexey Samsonov 734aab4066 [Sanitizer] Use a common mutex to prevent mixing reports from different sanitizers. This fixes PR15516
llvm-svn: 178853
2013-04-05 07:30:29 +00:00
Alexey Samsonov e624795558 [ASan] More careful reports for globals that are ASCII strings
llvm-svn: 178458
2013-04-01 08:57:38 +00:00
Alexey Samsonov 7152debedd [ASan] Demangle global names in error reports.
llvm-svn: 178131
2013-03-27 10:41:22 +00:00
Kostya Serebryany 88b2b45ec8 [asan] print thread number while reporting invalid-free and double-free; add tests; also add a test for use-after-poison
llvm-svn: 177993
2013-03-26 08:01:37 +00:00
Kostya Serebryany 667a34a120 [asan] Change the way we report the alloca frame on stack-buff-overflow.
Before: the function name was stored by the compiler as a constant string
and the run-time was printing it.
Now: the PC is stored instead and the run-time prints the full symbolized frame.
This adds a couple of instructions into every function with non-empty stack frame,
but also reduces the binary size because we store less strings (I saw 2% size reduction).
This change bumps the asan ABI version to v3.

compiler-rt part, llvm part will follow.

Example of report (now):
==31711==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffa77cf1c5 at pc 0x41feb0 bp 0x7fffa77cefb0 sp 0x7fffa77cefa8
READ of size 1 at 0x7fffa77cf1c5 thread T0
    #0 0x41feaf in Frame0(int, char*, char*, char*) stack-oob-frames.cc:20
    #1 0x41f7ff in Frame1(int, char*, char*) stack-oob-frames.cc:24
    #2 0x41f477 in Frame2(int, char*) stack-oob-frames.cc:28
    #3 0x41f194 in Frame3(int) stack-oob-frames.cc:32
    #4 0x41eee0 in main stack-oob-frames.cc:38
    #5 0x7f0c5566f76c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c)
    #6 0x41eb1c (/usr/local/google/kcc/llvm_cmake/a.out+0x41eb1c)
Address 0x7fffa77cf1c5 is located in stack of thread T0 at offset 293 in frame
    #0 0x41f87f in Frame0(int, char*, char*, char*) stack-oob-frames.cc:12  <<<<<<<<<<<<<< this is new
  This frame has 6 object(s):
    [32, 36) 'frame.addr'
    [96, 104) 'a.addr'
    [160, 168) 'b.addr'
    [224, 232) 'c.addr'
    [288, 292) 's'
    [352, 360) 'd'

llvm-svn: 177723
2013-03-22 10:36:24 +00:00
Alexey Samsonov 54afba8b62 [ASan] Switch ASan to generic ThreadRegistry from sanitizer_common. Delete ASan-specific AsanThreadRegistry.
llvm-svn: 177634
2013-03-21 11:23:41 +00:00
Alexey Samsonov cf025cb2e6 [ASan] Move GetCurrentThread/SetCurrentThread from AsanThreadRegistry class into plain functions: they don't actually use registry
llvm-svn: 177501
2013-03-20 09:23:28 +00:00
Kostya Serebryany c4722a65a5 [asan] while generating the description of a global variable, emit the module name in a separate field, thus not duplicating this information if every description. This decreases the binary size (observed up to 3%). https://code.google.com/p/address-sanitizer/issues/detail?id=168 . This changes the asan API version. compiler-rt part, llvm-part will follow
llvm-svn: 177253
2013-03-18 08:04:55 +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 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
Evgeniy Stepanov 1bc7298c44 [asan] Fix nonsensical reports of partial right OOB.
In case of partial right OOB, ASan was reporting
  X is located 0 bytes to the right of [A, B)
where X was actually inside [A, B).

With this change, ASan will report B as the error address in such case.

llvm-svn: 174373
2013-02-05 14:32:03 +00:00
Kostya Serebryany 6c17547ef1 [asan] two more internal flags for asan-rt: print_stats (0) and print_legend (1)
llvm-svn: 173671
2013-01-28 07:34:22 +00:00
Kostya Serebryany 7d2e4c0389 [asan] simplify the code that poisons global redzones, add some more tests
llvm-svn: 173251
2013-01-23 11:14:21 +00:00
Kostya Serebryany b3d04ede8c [asan] add a new interface function __asan_describe_address, useful for running asan-ified binary under a debugger (e.g. gdb)
llvm-svn: 171217
2012-12-29 10:18:31 +00:00