Commit Graph

248 Commits

Author SHA1 Message Date
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 993f1f38fd Continue to keep 'SUMMARY: ' prefix in lsan. Whoops!
llvm-svn: 193232
2013-10-23 07:58:11 +00:00
Sergey Matveev fd10073aeb [lsan] When detect_leaks=false, be completely silent.
In particular, don't make a fuss if we're passed a malformed suppressions file,
or if we have trouble identifying ld.so. Also, make LSan interface functions
no-ops in this case.

llvm-svn: 193108
2013-10-21 19:35:00 +00:00
Sergey Matveev 27ef175ef0 [lsan] Fix bug when discovering indirectly leaked objects.
If an object contains pointers to itself, that doesn't make it indirectly
leaked. D'oh!

llvm-svn: 192716
2013-10-15 16:00:11 +00:00
Dmitry Vyukov 7502a3a90c tsan: use verbosity flag in sanitizer_common code directly
now it's available from common_flags()

llvm-svn: 192705
2013-10-15 14:12:26 +00:00
Sergey Matveev 43d90cbd86 [lsan] Support ASan's stack-use-after-return mode in LSan.
Treat the fake stack as live memory.

llvm-svn: 192593
2013-10-14 14:04:50 +00:00
Sergey Matveev da9f5e7e7f [asan] Improve thread lifetime tracking on POSIX systems.
Call AsanThread::Destroy() from a late-running TSD destructor.
Previously we called it before any user-registered TSD destructors, which caused
false positives in LeakSanitizer.

llvm-svn: 192585
2013-10-14 12:01:05 +00:00
Alexey Samsonov c129e65661 [Sanitizer] Turn GetStackTrace() into StackTrace::Unwind()
llvm-svn: 192533
2013-10-12 12:23:00 +00:00
Sergey Matveev dc75cf3368 [sanitizer] Move the PTHREAD_DESTRUCTOR_ITERATIONS constant to sanitizer_linux.h.
Add a test.

llvm-svn: 192442
2013-10-11 12:09:49 +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 3b54a83d26 [LSan] Rework r191522 - treat allocations with short stack traces as live
llvm-svn: 191662
2013-09-30 10:57:56 +00:00
Alexey Samsonov f56ddf7fd1 [LSan] Don't report leaks with single-frame stack traces
llvm-svn: 191522
2013-09-27 13:54:20 +00:00
Evgeniy Stepanov 58dbe06230 [asan] Fix deadlock in stack unwinder on android/x86.
Fixes PR17116.
Patch by 林作健 (manjian2006 at gmail.com).

llvm-svn: 190590
2013-09-12 08:16:28 +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
Sergey Matveev b9d34443f2 [lsan] Colorize LSan reports.
llvm-svn: 189804
2013-09-03 13:31:03 +00:00
Alexey Samsonov 5b5c99d219 ASan, LSan, MSan: try to find llvm-symbolizer binary in PATH if it is not provided. Now we don't need to explicitly set the location of llvm-symbolizer in lit test configs.
llvm-svn: 189801
2013-09-03 13:22:51 +00:00
Alexey Samsonov 614a5ea990 Revert r189347: it breaks on machines w/o installed debug versions of system libraries
llvm-svn: 189350
2013-08-27 14:04:01 +00:00
Alexey Samsonov ea0ef986e2 LSan: Check that dynamic linker library is properly symbolized
llvm-svn: 189347
2013-08-27 13:39:33 +00:00
Sergey Matveev 9e3e80208f [sanitizer] Add a fast version of StackDepotGet() for use in LSan.
Add a class that holds a snapshot of the StackDepot optimized for querying by
ID. This allows us to speed up LSan dramatically.

llvm-svn: 189217
2013-08-26 13:24:43 +00:00
Alexey Samsonov 903c3250d2 Slightly improve lint checker script and fix a few style issues
llvm-svn: 189092
2013-08-23 07:43:56 +00:00
Sergey Matveev 5371e90f7a [lsan] Add a regression test for building C code.
llvm-svn: 189016
2013-08-22 14:48:44 +00:00
Sergey Matveev f6ca04d468 [lsan] Add a stress test.
llvm-svn: 189012
2013-08-22 13:32:10 +00:00
Sergey Matveev bed55036a9 [lsan] Build standalone LSan with -fno-rtti.
Fix issue where C code could not be built with -fsanitize=leak.

llvm-svn: 189010
2013-08-22 13:23:22 +00:00
Alexey Samsonov 287fca44af [LSan] Add support for building standalone LSan runtime to Make build (compiler-rt part)
llvm-svn: 188804
2013-08-20 14:49:01 +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
Daniel Dunbar bc5dbc435e [tests] Update to use lit_config and lit package, as appropriate.
llvm-svn: 188116
2013-08-09 22:14:01 +00:00
Alexey Samsonov fd078b9405 Enable pipefail for LSan tests
llvm-svn: 187873
2013-08-07 08:46:09 +00:00
Sergey Matveev 6459a370a7 [lsan] Add leak_check_at_exit flag.
We needed a way to tell LSan to invoke leak checking only if __do_leak_check()
is called explicitly. This can now be achieved by setting
leak_check_at_exit=false.

llvm-svn: 187578
2013-08-01 14:57:07 +00:00
Rafael Espindola 3cf7eb50a9 Disable pipefail for lsan.
llvm-svn: 187274
2013-07-26 23:42:16 +00:00
Sergey Matveev 9c012165ad [lsan] Make __lsan_do_leak_check() honor the detect_leaks flag.
Also move detect_leaks to common flags.

llvm-svn: 186821
2013-07-22 12:38:17 +00:00
Sergey Matveev 1ac4824841 [lsan] Print direct leaks first.
Direct leaks are higher priority, so it makes sense to have them on top.

llvm-svn: 186819
2013-07-22 11:18:32 +00:00
Hans Wennborg 2e304b6ffd Use --driver-mode=g++ instead of -ccc-cxx; required after Clang r186605
llvm-svn: 186607
2013-07-18 20:48:50 +00:00
Sergey Matveev 655bd0d08c [lsan] Add __lsan_do_leak_check() to the public interface.
Let users override the normal behavior to run leak checking earlier in
the process. Also fix a couple nits here and there.

llvm-svn: 186581
2013-07-18 14:06:07 +00:00
Sergey Matveev 28dc98ab0d [lsan] Increase the hardcoded limit on number of leaks.
We never expected to see so many leaks in the real world. Until we did.

llvm-svn: 186157
2013-07-12 12:31:22 +00:00
Sergey Matveev ddd7b6a1c8 [lsan] Fix test.
llvm-svn: 185817
2013-07-08 14:08:05 +00:00
Sergey Matveev bdeff959a1 [lsan] Handle fork() correctly.
Update the main thread's os_id on every pthread_create, and before
initiating leak checking. This ensures that we have the correct os_id even if we
have forked after Init().

llvm-svn: 185815
2013-07-08 12:57:24 +00:00
Alexey Samsonov 852d8a4c18 [LSan] Use overridable hook to report error summary
llvm-svn: 185805
2013-07-08 10:59:52 +00:00
Alexey Samsonov e71f37c1cd Define the path to llvm-symbolizer tool in a common config to reduce copy-paste
llvm-svn: 185286
2013-06-30 14:47:38 +00:00
Sergey Matveev 202881d1fe [lsan] Fix build again.
llvm-svn: 185157
2013-06-28 15:23:15 +00:00
Sergey Matveev b3fa575f7b [lsan] Fix build.
llvm-svn: 185156
2013-06-28 15:18:06 +00:00
Sergey Matveev 6672004c47 [lsan] When verbosity > 1, always print suppressions and summary (even if no leaks found).
Also fix an output bug.

llvm-svn: 185153
2013-06-28 15:05:16 +00:00
Sergey Matveev 2b19ee3da8 [lsan] Add suppression support.
llvm-svn: 185152
2013-06-28 14:38:31 +00:00
Sergey Matveev 1c34897887 [lsan] Fix flaky test.
llvm-svn: 185079
2013-06-27 14:24:07 +00:00
Alexey Samsonov 895784a5b0 [LSan] Add the way to disable LSan at link time
llvm-svn: 185066
2013-06-27 09:35:50 +00:00
Sergey Matveev c3332bc8c3 [lsan] Define interceptors more correctly. Also, always clear allocated memory.
llvm-svn: 184849
2013-06-25 14:05:52 +00:00
Sergey Matveev 4e0215a71c Revert to C-style callbacks for iteration over allocator chunks.
Also clean up LSan code, fix some comments and replace void* with uptr
to bring down the number of reinterpret_casts.

llvm-svn: 184700
2013-06-24 08:34:50 +00:00
Alexey Samsonov 43937b3758 Add cmake rules for building LSan common on Mac OS
llvm-svn: 184639
2013-06-22 16:33:52 +00:00
Sergey Matveev 38fa1ff710 [lsan] Try REALLY hard to fix Win build.
llvm-svn: 184557
2013-06-21 15:50:49 +00:00
Sergey Matveev 85f1fffdfb [lsan] This time really fix Win build.
llvm-svn: 184556
2013-06-21 15:22:12 +00:00
Sergey Matveev 7ed5c687ed [lsan] Fix win build.
llvm-svn: 184555
2013-06-21 15:14:57 +00:00
Sergey Matveev d28c03c03a [lsan] Increase allocator space; minor fixes.
llvm-svn: 184554
2013-06-21 15:10:20 +00:00
Sergey Matveev b94d5e2d1c [asan] Move lsan_disabled out of thread context.
Fix for the case where disabler is used in pthread key destructor.

llvm-svn: 184553
2013-06-21 14:51:52 +00:00
Sergey Matveev 5e6b9eccce [asan] Define LSan annotations as no-ops if leak detection is not supported.
llvm-svn: 184422
2013-06-20 13:39:42 +00:00
Sergey Matveev dac35c24c0 [lsan] Move symbolization and reporting out of StopTheWorld callback.
llvm-svn: 184303
2013-06-19 14:04:11 +00:00
Sergey Matveev 2717e7be06 [lsan] Set current_thread_tid correctly for main thread.
llvm-svn: 184189
2013-06-18 14:44:45 +00:00
Alexey Samsonov 7e325fb477 Properly install LSan interface header, rely on sanitizer header presence in lit tests
llvm-svn: 183977
2013-06-14 11:45:36 +00:00
Alexey Samsonov bd0428b81a [LSan] Use a typedef for frontier vector
llvm-svn: 183973
2013-06-14 10:07:56 +00:00
Alexey Samsonov b0d92b3312 [Sanitizer] Rename InternalVector to InternalMmapVector
llvm-svn: 183972
2013-06-14 09:59:40 +00:00
Alexey Samsonov 5e520c5e09 [LSan] fix link flags for building unit tests
llvm-svn: 183891
2013-06-13 07:23:18 +00:00
Sergey Matveev 978460c12c [lsan] Harmonized some naming inconsistencies.
llvm-svn: 183748
2013-06-11 15:26:20 +00:00
Sergey Matveev 5129c5e56f [lsan] Fix the unittest makefiles.
llvm-svn: 183735
2013-06-11 09:52:02 +00:00
Dmitry Vyukov 50ef53ebfc tsan: fix lint warnings
llvm-svn: 183642
2013-06-10 10:00:54 +00:00
Alexey Samsonov 575c599554 Drop support for 32-bit PowerPC in sanitizer tools.
llvm-svn: 183499
2013-06-07 09:44:43 +00:00
Sergey Matveev 1c4e214c32 [lsan] Put SANITIZER_INTERFACE_ATTRIBUTE on LSan interface functions.
llvm-svn: 183429
2013-06-06 18:40:55 +00:00
Sergey Matveev db356560fc [sanitizer] Do not fall back to SlowUnwindStack() in GetStackTrace()
llvm-svn: 183414
2013-06-06 14:19:36 +00:00
Sergey Matveev ecc4f5ba8e [lsan] Implement __lsan_ignore_object().
Leak annotation similar to HeapChecker's IgnoreObject().

llvm-svn: 183412
2013-06-06 14:17:56 +00:00
Alexey Samsonov f6630ecee9 Simplify lit configs for asan/lsan/msan unit tests
llvm-svn: 183410
2013-06-06 13:48:20 +00:00
Alexey Samsonov e3bf521b7c Remove a bunch of copy-paste: use common config for sanitizer lit/unit tests
llvm-svn: 183407
2013-06-06 13:28:37 +00:00
Sergey Matveev 17ee1abfa7 [lsan] Add __lsan_disable() and __lsan_enable().
Objects allocated after a call to __lsan_disable() will be treated as
live memory. Also add a ScopedDisabler.

llvm-svn: 183099
2013-06-03 11:21:34 +00:00
Sergey Matveev 1a566ced91 [lsan] Added a dummy unittest to suppress LIT warnings.
llvm-svn: 183004
2013-05-31 14:15:54 +00:00
Sergey Matveev 5494e0bec3 [lsan] Run the leak detection tests under both ASan and LSan.
Change the LSan lit test logic. Now "check-lsan" tests the leak
checking functionality in both standalone LSan and ASan.

llvm-svn: 183000
2013-05-31 13:13:55 +00:00
Sergey Matveev 69f11803ec [lsan] Use the fast version of GetBlockBegin for leak checking in LSan and ASan.
llvm-svn: 182994
2013-05-31 11:13:45 +00:00
Sergey Matveev e615432313 [lsan] Convert the remaining LSan tests to output tests.
llvm-svn: 182839
2013-05-29 10:12:37 +00:00
Alexey Samsonov 75289297af Exclude sanitizer_nolibc_test from TSan test run. Fix lint warnings
llvm-svn: 182837
2013-05-29 09:40:07 +00:00
Sergey Matveev 39e8a6d87e [lsan] Begin converting LSan tests to output tests.
In this CL all old tests are removed and one LIT test is added.

llvm-svn: 182730
2013-05-27 11:41:46 +00:00
Sergey Matveev 9cda3df8bd [sanitizer] Move FindThreadByOSIdLocked from lsan to sanitizer_common.
llvm-svn: 182728
2013-05-27 10:35:51 +00:00
Alexey Samsonov 9c2bcf8c15 Improve support for compiler-rt tests in CMake build.
Now compiler-rt tests run correctly if compiler-rt is checked out into
arbitrary directory (not necessarily projects/compiler-rt).
Patch by Greg Fitzgerald!

llvm-svn: 182726
2013-05-27 09:35:24 +00:00
Sergey Matveev e45a0677a6 [lsan] Allow the ignored TLS range to be empty.
llvm-svn: 182657
2013-05-24 18:07:53 +00:00
Sergey Matveev 37dff38495 [lsan] Minor adjustments to LSan messages.
llvm-svn: 182648
2013-05-24 15:36:30 +00:00
Sergey Matveev c7715a228a [lsan] Prettify LSan reports and add a summary.
llvm-svn: 182646
2013-05-24 14:49:13 +00:00
Sergey Matveev bc880f3a54 [lsan] Add exitcode flag. Kill the process if leaks are found.
llvm-svn: 182641
2013-05-24 13:16:02 +00:00
Sergey Matveev a4a01975d5 [lsan] Add lit test support.
"check-lsan" now runs both the tests from lib/lsan/tests and any lit
tests found under lib/lsan/lit_tests.

llvm-svn: 182583
2013-05-23 12:58:56 +00:00
Sergey Matveev bb12f840b5 [lsan] Ensure lsan is initialized when interceptors are called.
Also remove unnecessary ifdefs.

llvm-svn: 182571
2013-05-23 10:24:44 +00:00
Alexey Samsonov 49eb5700e2 Revert r182465 and add lsan-common library to makefile-based build
llvm-svn: 182470
2013-05-22 13:20:37 +00:00
Sergey Matveev 20ccf95f80 [lsan] Invoke leak detection with atexit().
Keeps it consistent between ASan and LSan.

llvm-svn: 182399
2013-05-21 17:56:45 +00:00
Sergey Matveev 17f5705d3c [asan] Do not invoke LSan hooks unless CAN_SANITIZE_LEAKS.
llvm-svn: 182389
2013-05-21 15:35:34 +00:00
Sergey Matveev 620744556a [lsan] Change CMakeLists to build the common LSan module for ASan.
Also, define CAN_SANITIZE_LEAKS.

llvm-svn: 182383
2013-05-21 14:12:11 +00:00
Sergey Matveev aa0b45a094 [lsan] LSan in LD_PRELOAD library form.
llvm-svn: 182376
2013-05-21 12:49:33 +00:00
Alexey Samsonov cbbdfc50ee Build LSan on x86_64 only if this target is supported
llvm-svn: 182272
2013-05-20 14:16:45 +00:00
Sergey Matveev 6dd91e475a [lsan] Fix r182256.
Add missing call to GetUserBegin().

llvm-svn: 182267
2013-05-20 14:04:56 +00:00
Sergey Matveev bcfd838bcb [lsan] GetUserBegin() in LSan.
Separate the notions of user-visible chunk and allocator chunk, to facilitate
ASan integration.

llvm-svn: 182256
2013-05-20 13:08:23 +00:00
Sergey Matveev 3c20829559 [lsan] CMakeLists and lit test configs for LSan.
llvm-svn: 182251
2013-05-20 11:13:33 +00:00
Sergey Matveev 48c1d1acad [lsan] Tests for LeakSanitizer.
llvm-svn: 182250
2013-05-20 11:09:27 +00:00
Sergey Matveev b5483be858 [lsan] Common leak checking module.
Leak checking functionality which will be shared between
LSan/ASan/MSan.

llvm-svn: 182249
2013-05-20 11:06:50 +00:00
Sergey Matveev 3d97cdd140 [lsan] Standalone LSan initialization.
llvm-svn: 182248
2013-05-20 11:04:43 +00:00
Sergey Matveev a5f9691dfb [lsan] Interceptors for standalone LSan.
llvm-svn: 182247
2013-05-20 11:01:40 +00:00
Sergey Matveev c7d003ec43 [lsan] Thread registry for standalone LSan.
llvm-svn: 182246
2013-05-20 10:57:53 +00:00
Sergey Matveev 866abfb3fe [lsan] Allocator for standalone LSan.
This is the first in a series of CLs implementing LeakSanitizer.
http://clang.llvm.org/docs/LeakSanitizer.html

llvm-svn: 182245
2013-05-20 10:54:00 +00:00