/usr/share/doc/clang-6.0-doc/html/LeakSanitizer.html is in clang-6.0-doc 1:6.0-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LeakSanitizer — Clang 6 documentation</title>
<link rel="stylesheet" href="_static/haiku.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="SanitizerCoverage" href="SanitizerCoverage.html" />
<link rel="prev" title="DataFlowSanitizer Design Document" href="DataFlowSanitizerDesign.html" />
</head>
<body>
<div class="header" role="banner"><h1 class="heading"><a href="index.html">
<span>Clang 6 documentation</span></a></h1>
<h2 class="heading"><span>LeakSanitizer</span></h2>
</div>
<div class="topnav" role="navigation" aria-label="top navigation">
<p>
«  <a href="DataFlowSanitizerDesign.html">DataFlowSanitizer Design Document</a>
  ::  
<a class="uplink" href="index.html">Contents</a>
  ::  
<a href="SanitizerCoverage.html">SanitizerCoverage</a>  »
</p>
</div>
<div class="content">
<div class="section" id="leaksanitizer">
<h1>LeakSanitizer<a class="headerlink" href="#leaksanitizer" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
<li><a class="reference internal" href="#more-information" id="id3">More Information</a></li>
</ul>
</div>
<div class="section" id="introduction">
<h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>LeakSanitizer is a run-time memory leak detector. It can be combined with
<a class="reference internal" href="AddressSanitizer.html"><span class="doc">AddressSanitizer</span></a> 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.</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#id2">Usage</a><a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<p>LeakSanitizer is supported on x86_64 Linux and OS X. In order to use it,
simply build your program with <a class="reference internal" href="AddressSanitizer.html"><span class="doc">AddressSanitizer</span></a>:</p>
<div class="highlight-console"><div class="highlight"><pre><span></span><span class="gp">$</span> cat memory-leak.c
<span class="gp">#</span>include <stdlib.h>
<span class="go">void *p;</span>
<span class="go">int main() {</span>
<span class="go"> p = malloc(7);</span>
<span class="go"> p = 0; // The memory is leaked here.</span>
<span class="go"> return 0;</span>
<span class="go">}</span>
<span class="gp">%</span> clang -fsanitize<span class="o">=</span>address -g memory-leak.c <span class="p">;</span> <span class="nv">ASAN_OPTIONS</span><span class="o">=</span><span class="nv">detect_leaks</span><span class="o">=</span><span class="m">1</span> ./a.out
<span class="go">==23646==ERROR: LeakSanitizer: detected memory leaks</span>
<span class="go">Direct leak of 7 byte(s) in 1 object(s) allocated from:</span>
<span class="gp"> #</span><span class="m">0</span> 0x4af01b in __interceptor_malloc /projects/compiler-rt/lib/asan/asan_malloc_linux.cc:52:3
<span class="gp"> #</span><span class="m">1</span> 0x4da26a in main memory-leak.c:4:7
<span class="gp"> #</span><span class="m">2</span> 0x7f076fd9cec4 in __libc_start_main libc-start.c:287
<span class="go">SUMMARY: AddressSanitizer: 7 byte(s) leaked in 1 allocation(s).</span>
</pre></div>
</div>
<p>To use LeakSanitizer in stand-alone mode, link your program with
<code class="docutils literal"><span class="pre">-fsanitize=leak</span></code> flag. Make sure to use <code class="docutils literal"><span class="pre">clang</span></code> (not <code class="docutils literal"><span class="pre">ld</span></code>) for the
link step, so that it would link in proper LeakSanitizer run-time library
into the final executable.</p>
</div>
<div class="section" id="more-information">
<h2><a class="toc-backref" href="#id3">More Information</a><a class="headerlink" href="#more-information" title="Permalink to this headline">¶</a></h2>
<p><a class="reference external" href="https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer">https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer</a></p>
</div>
</div>
</div>
<div class="bottomnav" role="navigation" aria-label="bottom navigation">
<p>
«  <a href="DataFlowSanitizerDesign.html">DataFlowSanitizer Design Document</a>
  ::  
<a class="uplink" href="index.html">Contents</a>
  ::  
<a href="SanitizerCoverage.html">SanitizerCoverage</a>  »
</p>
</div>
<div class="footer" role="contentinfo">
© Copyright 2007-2018, The Clang Team.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.7.
</div>
</body>
</html>
|