You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cpp/ASAN/asan-top-level.md
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -20,26 +20,26 @@ Using this flag can reduce your time spent on:
20
20
- Stress testing
21
21
- Integrating new code
22
22
23
-
The Address Sanitizer is a compiler and runtime runtime [introduced by Google](https://www.usenix.org/conference/atc12/technical-sessions/presentation/serebryany). Many projects can enable the Address Sanitizer with a project setting, or a single additional compiler switch: `-fanitize=address`. The new flag is compatible with all levels of optimization. There are conflicts in three compilation modes: [edit-and-continue](), [incremental linking](), and [/RTC](https://docs.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-160). Apart from those three modes, all other configurations are supported when targeting x86 and x64.
23
+
The Address Sanitizer is a compiler and runtime [introduced by Google](https://www.usenix.org/conference/atc12/technical-sessions/presentation/serebryany). Compiling with `cl -fsanitize=addres`is a powerful alternative to both [/RTC](..\..\build\reference\rtc-run-time-error-checks.md), and [/analyze](../..\code-quality/code-analysis-for-c-cpp-overview.md). It provides run-time bug-finding technologies which leverage your existing build systems and existing test assets.
24
24
25
-
Compiling with `-fsanitize=address`is a powerful alternative to both [/RTC](https://docs.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-160), and [/analyze](https://docs.microsoft.com/en-us/cpp/code-quality/code-analysis-for-c-cpp-overview?view=msvc-160). It provides run-time bug-finding technologies which leverage your existing build systems and existing test assets.
25
+
Projects can enable the Address Sanitizer with a project setting, or a single additional compiler switch: **-fanitize=address**. The new flag is compatible with all levels of optimization but it is not compatible with three compilation modes: [edit-and-continue](), [incremental linking](..\..\build\reference\incremental-link-incrementally.md), and [/RTC](..\..\build\reference\rtc-run-time-error-checks.md). Apart from those three modes, all other configurations are supported when targeting x86 and x64.
26
26
27
-
We also link a new library to your executable. By setting the environment variable via **`set ASAN_SAVE_DUMPS=”MyFileName.dmpx”`** your program can automatically create a new type of crash dump file that will contain extra meta-data for post-mortem debugging. These dump files can be displayed off-line, with Visual Studio's new debugger IDE. These dump files are an enabler for:
27
+
The Address Sanitizer is integrated with the Visual Studio the project system, CMake system and the IDE.
28
+
29
+
Using the flag -fsanitize=address, the driver (cl.exe) will link a new library with your executable. This library enables integration with the IDE and it can optionally create a new crash dump file. Setting an environment variable via `set ASAN_SAVE_DUMPS=”MyFileName.dmpx”`your program can automatically create a new type of crash dump file that will contain extra meta-data for efficient, post-mortem debugging of **precisely diagnosed bugs**. These files facilitate using the Address Sanitizer in:
28
30
29
31
- On-premise single machine or distributed testing
30
32
- Cloud based workflows for testing
31
33
32
-
These test systems can store the dump files, with **precisely diagnosed bugs**, for later viewing super imposed on your source code in the IDE.
33
-
34
34
### Installing the Address Sanitizer
35
35
36
36
Simply [**install the Address Sanitizer functionality**]().
37
37
38
-
After installing you can build your executables with the `-fsanitize=address`compiler switch using any of the following:
38
+
After installing, you can build your executables with the `-fsanitize=address`compiler switch using any of the following:
39
39
40
40
- Command line
41
41
- Visual Studio project system
42
-
- Visual Studio Cmake make integration
42
+
- Visual Studio CMake integration
43
43
44
44
You simply run your program normally. This will light up [many types of precisely diagnosed bugs](#errors). These [errors can be reported three (3) ways](#TBD): in the debugger IDE, on the command line or stored in a new type of dump file for precise off-line processing.
45
45
@@ -68,10 +68,11 @@ This article will cover the information needed to enable the three workflows lis
68
68
69
69
Compile with `-fsanitize=address` to enable Address Sanitizer. The compiler flag `-fsanitize=address` is compatible with all existing C++ or C optimization levels (e.g., /Od, /O1, /O2, /O2 /GL and PGO), works with static and dynamic CRTs (e.g. /MD, /MDd, /MT, /MTd) and can be used to create an .EXE or .DLL. Debug information is required for optimal formatting of call stacks. In this example we explicitly pass `-/Zi`.
70
70
71
-
The Address Sanitizer libraries (.lib files) will be linked for you. For more detail, and for guidelines on partitioned build systems, see [building to target the Address Sanitizer runtime.](.\ASan-building.md).
71
+
The Address Sanitizer libraries (.lib files) will be linked for you. For more detail, and for guidelines on partitioned build systems, see [building to target the Address Sanitizer runtime.](.\asan-building.md).
72
72
73
73
### Example - basic global buffer overflow:
74
74
75
+
75
76
```cpp
76
77
// main.cpp
77
78
#include<stdio.h>
@@ -85,11 +86,11 @@ The Address Sanitizer libraries (.lib files) will be linked for you. For more de
85
86
}
86
87
```
87
88
88
-
Using a Developer Command Prompt for VS 2019, compile main.cpp as `-fsanitize=address -Zi`
89
+
Using a Developer Command Prompt for VS 2019, compile main.cpp using `-fsanitize=address -Zi`
0 commit comments