1
<html xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0">
3
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4
<title>4.�Addrcheck: a lightweight memory checker</title>
5
<link rel="stylesheet" href="vg_basic.css" type="text/css">
6
<meta name="generator" content="DocBook XSL Stylesheets V1.69.0">
7
<link rel="start" href="index.html" title="Valgrind Documentation">
8
<link rel="up" href="manual.html" title="Valgrind User Manual">
9
<link rel="prev" href="mc-manual.html" title="3.�Memcheck: a heavyweight memory checker">
10
<link rel="next" href="cg-manual.html" title="5.�Cachegrind: a cache profiler">
12
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13
<div><table class="nav" width="100%" cellspacing="3" cellpadding="3" border="0" summary="Navigation header"><tr>
14
<td width="22px" align="center" valign="middle"><a accesskey="p" href="mc-manual.html"><img src="images/prev.png" width="18" height="21" border="0" alt="Prev"></a></td>
15
<td width="25px" align="center" valign="middle"><a accesskey="u" href="manual.html"><img src="images/up.png" width="21" height="18" border="0" alt="Up"></a></td>
16
<td width="31px" align="center" valign="middle"><a accesskey="h" href="index.html"><img src="images/home.png" width="27" height="20" border="0" alt="Up"></a></td>
17
<th align="center" valign="middle">Valgrind User Manual</th>
18
<td width="22px" align="center" valign="middle"><a accesskey="n" href="cg-manual.html"><img src="images/next.png" width="18" height="21" border="0" alt="Next"></a></td>
20
<div class="chapter" lang="en">
21
<div class="titlepage"><div><div><h2 class="title">
22
<a name="ac-manual"></a>4.�Addrcheck: a lightweight memory checker</h2></div></div></div>
24
<p><b>Table of Contents</b></p>
25
<dl><dt><span class="sect1"><a href="ac-manual.html#id2594951">4.1. Kinds of bugs that Addrcheck can find</a></span></dt></dl>
27
<p>To use this tool, you must specify
28
<code class="computeroutput">--tool=addrcheck</code> on the Valgrind
30
<p>Note: Addrcheck does not work in Valgrind 3.1.0. We may
31
reinstate it in later releases.</p>
32
<div class="sect1" lang="en">
33
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
34
<a name="id2594951"></a>4.1.�Kinds of bugs that Addrcheck can find</h2></div></div></div>
35
<p>Addrcheck is a simplified version of the Memcheck tool
36
described in Section 3. It is identical in every way to
37
Memcheck, except for one important detail: it does not do the
38
undefined-value checks that Memcheck does. This means Addrcheck
39
is faster than Memcheck, and uses less memory.
40
Addrcheck can detect the following errors:</p>
41
<div class="itemizedlist"><ul type="disc">
42
<li><p>Reading/writing memory after it has been free'd</p></li>
43
<li><p>Reading/writing off the end of malloc'd blocks</p></li>
44
<li><p>Reading/writing inappropriate areas on the stack</p></li>
45
<li><p>Memory leaks -- where pointers to malloc'd blocks are lost
47
<li><p>Mismatched use of malloc/new/new [] vs free/delete/delete []</p></li>
48
<li><p>Overlapping <code class="computeroutput">src</code> and
49
<code class="computeroutput">dst</code> pointers in
50
<code class="computeroutput">memcpy()</code> and related
53
<p>Rather than duplicate much of the Memcheck docs here,
54
users of Addrcheck are advised to read <a href="mc-manual.html#mc-manual.bugs">Kinds of bugs that Memcheck can find</a>.
55
Some important points:</p>
56
<div class="itemizedlist"><ul type="disc">
57
<li><p>Addrcheck is exactly like Memcheck, except that all the
58
value-definedness tracking machinery has been removed.
59
Therefore, the Memcheck documentation which discusses
60
definedess ("V-bits") is irrelevant. The stuff on
61
addressibility ("A-bits") is still relevant.</p></li>
62
<li><p>Addrcheck accepts the same command-line flags as
63
Memcheck, with the exception of ... (to be filled in).</p></li>
65
<p>Like Memcheck, Addrcheck will do memory leak checking
66
(internally, the same code does leak checking for both
67
tools). The only difference is how the two tools decide
68
which memory locations to consider when searching for
69
pointers to blocks. Memcheck will only consider 4-byte
70
aligned locations which are validly addressible and which
71
hold defined values. Addrcheck does not track definedness
72
and so cannot apply the last, "defined value",
74
<p>The result is that Addrcheck's leak checker may
75
"discover" pointers to blocks that Memcheck would not. So it
76
is possible that Memcheck could (correctly) conclude that a
77
block is leaked, yet Addrcheck would not conclude
79
<p>Whether or not this has any effect in practice is
80
unknown. I suspect not, but that is mere speculation at this
84
<p>Addrcheck is, therefore, a fine-grained address checker.
85
All it really does is check each memory reference to say whether
86
or not that location may validly be addressed. Addrcheck has a
87
memory overhead of one bit per byte of used address space. In
88
contrast, Memcheck has an overhead of nine bits per byte.</p>
89
<p>Addrcheck is quite pleasant to use. It's faster than
90
Memcheck, and the lack of valid-value checks has another side
91
effect: the errors it does report are relatively easy to track
92
down, compared to the tedious and often confusing search
93
sometimes needed to find the cause of uninitialised-value errors
94
reported by Memcheck.</p>
98
<br><table class="nav" width="100%" cellspacing="3" cellpadding="2" border="0" summary="Navigation footer">
100
<td rowspan="2" width="40%" align="left">
101
<a accesskey="p" href="mc-manual.html"><<�3.�Memcheck: a heavyweight memory checker</a>�</td>
102
<td width="20%" align="center"><a accesskey="u" href="manual.html">Up</a></td>
103
<td rowspan="2" width="40%" align="right">�<a accesskey="n" href="cg-manual.html">5.�Cachegrind: a cache profiler�>></a>
106
<tr><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td></tr>