r258476 - [Docs] Slightly update LSan documentation.

Alexey Samsonov via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 21 17:35:45 PST 2016


Author: samsonov
Date: Thu Jan 21 19:35:45 2016
New Revision: 258476

URL: http://llvm.org/viewvc/llvm-project?rev=258476&view=rev
Log:
[Docs] Slightly update LSan documentation.

Modified:
    cfe/trunk/docs/AddressSanitizer.rst
    cfe/trunk/docs/LeakSanitizer.rst

Modified: cfe/trunk/docs/AddressSanitizer.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AddressSanitizer.rst?rev=258476&r1=258475&r2=258476&view=diff
==============================================================================
--- cfe/trunk/docs/AddressSanitizer.rst (original)
+++ cfe/trunk/docs/AddressSanitizer.rst Thu Jan 21 19:35:45 2016
@@ -232,6 +232,23 @@ problems happening in certain source fil
     type:*BadInitClassSubstring*=init
     src:bad/init/files/*=init
 
+Suppressing memory leaks
+------------------------
+
+Memory leak reports produced by :doc:`LeakSanitizer` (if it is run as a part
+of AddressSanitizer) can be suppressed by a separate file passed as
+
+.. code-block:: bash
+
+    LSAN_OPTIONS=suppressions=MyLSan.supp
+
+which contains lines of the form `leak:<pattern>`. Memory leak will be
+suppressed if pattern matches any function name, source file name, or
+library name in the symbolized stack trace of the leak report. See
+`full documentation
+<https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions>`_
+for more details.
+
 Limitations
 ===========
 

Modified: cfe/trunk/docs/LeakSanitizer.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LeakSanitizer.rst?rev=258476&r1=258475&r2=258476&view=diff
==============================================================================
--- cfe/trunk/docs/LeakSanitizer.rst (original)
+++ cfe/trunk/docs/LeakSanitizer.rst Thu Jan 21 19:35:45 2016
@@ -9,21 +9,39 @@ Introduction
 ============
 
 LeakSanitizer is a run-time memory leak detector. It can be combined with
-:doc:`AddressSanitizer` to get both memory error and leak detection.
-LeakSanitizer does not introduce any additional slowdown when used in this mode.
-The LeakSanitizer runtime can also be linked in separately to get leak detection
-only, at a minimal performance cost.
-
-Current status
-==============
-
-LeakSanitizer is turned on by default, but it is only supported on x86\_64
-Linux.
-
-The combined mode has been tested on fairly large software projects. The
-stand-alone mode has received much less testing.
-
-There are plans to support LeakSanitizer in :doc:`MemorySanitizer` builds.
+:doc:`AddressSanitizer` to get both memory error and leak detection, or
+used in a stand-alone mode. LSan adds almost no performance overhead
+until the very end of the process, at which point there is an extra leak
+detection phase.
+
+Usage
+=====
+
+LeakSanitizer is only supported on x86\_64 Linux. In order to use it,
+simply build your program with :doc:`AddressSanitizer`:
+
+.. code-block:: console
+
+    $ cat memory-leak.c
+    #include <stdlib.h>
+    void *p;
+    int main() {
+      p = malloc(7);
+      p = 0; // The memory is leaked here.
+      return 0;
+    }
+    % clang -fsanitize=address -g memory-leak.c ; ./a.out
+    ==23646==ERROR: LeakSanitizer: detected memory leaks
+    Direct leak of 7 byte(s) in 1 object(s) allocated from:
+        #0 0x4af01b in __interceptor_malloc /projects/compiler-rt/lib/asan/asan_malloc_linux.cc:52:3
+        #1 0x4da26a in main memory-leak.c:4:7
+        #2 0x7f076fd9cec4 in __libc_start_main libc-start.c:287
+    SUMMARY: AddressSanitizer: 7 byte(s) leaked in 1 allocation(s).
+
+To use LeakSanitizer in stand-alone mode, link your program with
+``-fsanitize=leak`` flag. Make sure to use ``clang`` (not ``ld``) for the
+link step, so that it would link in proper LeakSanitizer run-time library
+into the final executable.
 
 More Information
 ================




More information about the cfe-commits mailing list