Kostya Serebryany | ce98c9b | 2011-11-28 20:51:02 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ --> |
| 4 | <html> |
| 5 | <head> |
| 6 | <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| 7 | <title>AddressSanitizer, a fast memory error detector</title> |
| 8 | <link type="text/css" rel="stylesheet" href="../menu.css"> |
| 9 | <link type="text/css" rel="stylesheet" href="../content.css"> |
| 10 | <style type="text/css"> |
| 11 | td { |
| 12 | vertical-align: top; |
| 13 | } |
| 14 | </style> |
| 15 | </head> |
| 16 | <body> |
| 17 | |
| 18 | <!--#include virtual="../menu.html.incl"--> |
| 19 | |
Kostya Serebryany | 7a31d7b | 2011-11-28 22:34:10 +0000 | [diff] [blame^] | 20 | <div id="content"> |
| 21 | |
Kostya Serebryany | ce98c9b | 2011-11-28 20:51:02 +0000 | [diff] [blame] | 22 | <h1>AddressSanitizer</h1> |
| 23 | <ul> |
| 24 | <li> <a href="intro">Introduction</a> |
| 25 | <li> <a href="usage">Usage</a> |
| 26 | <ul><li> <a href="has_feature">__has_feature(address_sanitizer)</a></ul> |
| 27 | <li> <a href="platforms">Supported Platforms</a> |
| 28 | <li> <a href="limitations">Limitations</a> |
| 29 | <li> <a href="status">Current Status</a> |
| 30 | </ul> |
| 31 | |
| 32 | <h2 id="intro">Introduction</h2> |
| 33 | AddressSanitizer is a fast memory error detector. |
| 34 | It consists of a compiler instrumentation module and a run-time library. |
| 35 | The tool can detect the following types of bugs: |
| 36 | <ul> <li> Out-of-bounds accesses to <ul><li>heap <li>stack <li>globals</ul> |
| 37 | <li> Use-after-free |
| 38 | <li> Use-after-return (to some extent) |
| 39 | <li> Double-free |
| 40 | </ul> |
| 41 | Typical slowdown introduced by AddressSanitizer is <b>2x</b>. |
| 42 | |
| 43 | <h2 id="intro">Usage</h2> |
| 44 | In order to use AddressSanitizer simply compile and link your program with |
| 45 | <tt>-faddress-sanitizer</tt> flag and optimization level <tt>-O1</tt> or higher |
| 46 | and then run it. If a bug is detected, the program will print an error message |
| 47 | and exit. |
| 48 | |
| 49 | <h3 id="has_feature">__has_feature(address_sanitizer)</h3> |
| 50 | In some cases one may need to execute different code depending on whether |
| 51 | AddressSanitizer is enabled. |
| 52 | <a href="LanguageExtensions.html#__has_feature_extension">__has_feature</a> |
| 53 | can be used for this purpose. |
| 54 | <pre> |
| 55 | #if defined(__has_feature) && __has_feature(address_sanitizer) |
| 56 | code that runs only under AddressSanitizer |
| 57 | #else |
| 58 | code that does not run under AddressSanitizer |
| 59 | #endif |
| 60 | </pre> |
| 61 | |
| 62 | <h2 id="platforms">Supported Platforms</h2> |
| 63 | AddressSanitizer is supported on the following platforms: |
| 64 | <ul> <li>Linux <ul> <li> i386 <li> x86_64 <li> ARM </ul> |
| 65 | <li>Darwin <ul> <li> i386 <li> x86_64 </ul> |
| 66 | </ul> |
| 67 | |
| 68 | <h2 id="limitations">Limitations</h2> |
| 69 | <ul> |
| 70 | <li> AddressSanitizer uses more real memory than a native run. |
| 71 | How much -- depends on the allocations sizes. The smaller the |
| 72 | allocations you make the bigger the overhead. |
| 73 | <li> On 64-bit platforms AddressSanitizer maps (but not reserves) |
| 74 | 16+ Terabytes of virtual address space. |
| 75 | This means that tools like <tt>ulimit</tt> may not work as usually expected. |
| 76 | <li> Static linking is not supported. |
| 77 | </ul> |
| 78 | |
| 79 | |
| 80 | <h2 id="status">Current Status</h2> |
| 81 | AddressSanitizer is work-in-progress and is not yet fully functional in the LLVM/Clang head. |
| 82 | For the up-to-date usable version and full documentation refer to |
| 83 | <a href="http://code.google.com/p/address-sanitizer/">http://code.google.com/p/address-sanitizer</a>. |
| 84 | |
| 85 | |
Kostya Serebryany | 7a31d7b | 2011-11-28 22:34:10 +0000 | [diff] [blame^] | 86 | </div> |
Kostya Serebryany | ce98c9b | 2011-11-28 20:51:02 +0000 | [diff] [blame] | 87 | </body> |
| 88 | </html> |