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
{{ message }}
Repository navigation
Commit 1cd5a21
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/sanitizers/asan-offline-crash-dumps.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,17 +52,17 @@ The following steps are for local or distributed scenarios that lead to creation
52
52
53
53
1. Open Visual Studio and select **Continue without code**. Then select **File** > **Open** > **File** to open the File Open dialog. Make sure the file name suffix is **.dmp**.
54
54
55
-

55
+
:::image type="content" source="./media/asan-open-crash-dump-file.png" alt-text="Screenshot of the File Open File menu in Visual Studio.":::
56
56
57
57
The screen shown here needs one more step to enable the IDE access to symbols and source.
58
58
59
59
1. Set the symbol paths, and then choose **Debug with Native Only**.
60
60
61
-

61
+
:::image type="content" source="./media/asan-dump-file-open.png" alt-text="Screenshot of the Minidump Summary display in Visual Studio.":::
62
62
63
63
This screenshot shows the final loaded dump file, with sources and AddressSanitizer metadata loaded.
64
64
65
-

65
+
:::image type="content" source="./media/asan-view-crash-metadata.png" alt-text="Screenshot of the debugger showing source files and AddressSanitizer metadata.":::
Copy file name to clipboardExpand all lines: docs/sanitizers/asan.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Microsoft's AddressSanitizer technology enables integration with the Visual Stud
36
36
37
37
The AddressSanitizer is installed by default with C++ workloads in the Visual Studio Installer. However, if you're upgrading from an older version of Visual Studio 2019, you'll need to use the Installer to enable ASan support after the upgrade:
38
38
39
-

39
+
:::image type="content" source="media/asan-installer-option.png" alt-text="Visual Studio Installer screenshot highlighting the C++ AddressSanitizer component":::
40
40
41
41
You can choose **Modify** on your existing Visual Studio installation from the Visual Studio Installer to get to the screen above.
42
42
@@ -95,13 +95,13 @@ int main() {
95
95
96
96
Using a developer command prompt for Visual Studio 2019, compile *`main.cpp`* using `/fsanitize=address /Zi`
97
97
98
-

98
+
:::image type="content" source="media/asan-command-basic-global-overflow.png" alt-text="Screenshot of a command prompt showing the command to compile with AddressSanitizer options.":::
99
99
100
100
When you run the resulting *`main.exe`* at the command line, it creates the formatted error report seen below.
101
101
102
102
Consider the overlaid, red boxes that highlight seven key pieces of information:
103
103
104
-

104
+
:::image type="content" source="media/asan-basic-global-overflow.png" alt-text="Screenshot of the debugger showing a basic global overflow error.":::
105
105
106
106
### Red highlights, from top to bottom
107
107
@@ -120,7 +120,7 @@ Consider the overlaid, red boxes that highlight seven key pieces of information:
120
120
121
121
AddressSanitizer is integrated with the Visual Studio IDE. To turn on the AddressSanitizer for an MSBuild project, right-click on the project in Solution Explorer and choose Properties. In the Property Pages dialog, select **Configuration Properties** > **C/C++** > **General**, then modify the **Enable AddressSanitizer** property. Choose **OK** to save your changes.
122
122
123
-

123
+
:::image type="content" source="media/asan-project-system-dialog.png" alt-text="Screenshot of the Property Pages dialog showing the Enable AddressSanitizer property.":::
124
124
125
125
To build from the IDE, opt out of [these incompatible options](./asan-known-issues.md#incompatible-options). For an existing project compiled by using **`/Od`** (or Debug mode), you may need to turn off these options:
126
126
@@ -130,15 +130,15 @@ To build from the IDE, opt out of [these incompatible options](./asan-known-issu
130
130
131
131
To build and run the debugger, enter **F5**. You'll see this window in Visual Studio:
132
132
133
-

133
+
:::image type="content" source="media/asan-global-buffer-overflow-F5.png" alt-text="Screenshot of the debugger showing a global buffer overflow error.":::
134
134
135
135
## <aname="ide-cmake"></a> Using the AddressSanitizer from Visual Studio: CMake
136
136
137
137
To enable the AddressSanitizer for [a CMake project created to target Windows](../build/cmake-projects-in-visual-studio.md), take these steps:
138
138
139
139
1. Open the **Configurations** dropdown in the toolbar at the top of the IDE and select **Manage Configurations**.
140
140
141
-

141
+
:::image type="content" source="media/asan-cmake-configuration-dropdown.png" alt-text="Screenshot of the CMake configuration dropdown.":::
142
142
143
143
That selection opens the CMake Project Settings UI, which is saved in a CMakeSettings.json file.
144
144
@@ -148,13 +148,13 @@ To enable the AddressSanitizer for [a CMake project created to target Windows](.
148
148
149
149
This image is of CMakeSettings.json after that change:
150
150
151
-

151
+
:::image type="content" source="media/asan-cmake-json.png" alt-text="Screenshot of the text editor view of CMakeSettings.json.":::
152
152
153
153
1. Enter **Ctrl+S** to save this JSON file, then enter **F5** to recompile and run under the debugger.
154
154
155
155
This screenshot captures the error from the CMake build.
156
156
157
-

157
+
:::image type="content" source="media/asan-cmake-error-f5.png" alt-text="Screenshot of the CMake build error message.":::
@@ -164,11 +164,11 @@ These new dump files can lead to efficiencies when analyzing a bug. You don't ne
164
164
165
165
To produce a new type of dump file that can be viewed in Visual Studio on another machine at a later date:
166
166
167
-
```makefile
167
+
```cmd
168
168
set ASAN_SAVE_DUMPS=MyFileName.dmp
169
169
```
170
170
171
-
Starting with Visual Studio 16.9 you can display **a precisely diagnosed error**, stored in MyFileName.dmp, on top of your source code.
171
+
Starting with Visual Studio 16.9 you can display **a precisely diagnosed error**, stored in your *`*.dmp`* file, on top of your source code.
172
172
173
173
[This new crash dump functionality](./asan-offline-crash-dumps.md) enables cloud-based workflows, or distributed testing. It can also be used to file a detailed, actionable bug in any scenario.
Copy file name to clipboardExpand all lines: docs/sanitizers/error-alloc-dealloc-mismatch.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ devenv /debugexe example1.exe 2
50
50
51
51
### Resulting error
52
52
53
-

53
+
:::image type="content" source="media/alloc-dealloc-mismatch-example-1.png" alt-text="Screenshot of debugger displaying alloc-dealloc-mismatch error in example 1.":::
Copy file name to clipboardExpand all lines: docs/sanitizers/error-allocation-size-too-big.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ devenv /debugexe example1.exe
46
46
47
47
### Resulting error
48
48
49
-

49
+
:::image type="content" source="media/allocation-size-too-big-example-1.png" alt-text="Screenshot of debugger displaying allocation-size-too-big error in example 1.":::
Copy file name to clipboardExpand all lines: docs/sanitizers/error-calloc-overflow.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ devenv /debugexe example1.exe
41
41
42
42
### Resulting error
43
43
44
-

44
+
:::image type="content" source="media/calloc-overflow-example-1.png" alt-text="Screenshot of debugger displaying calloc-overflow error in example 1.":::
Copy file name to clipboardExpand all lines: docs/sanitizers/error-dynamic-stack-buffer-overflow.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ devenv /debugexe example1.exe
44
44
45
45
### Resulting error
46
46
47
-

47
+
:::image type="content" source="media/dynamic-stack-buffer-overflow-example-1.png" alt-text="Screenshot of debugger displaying dynamic-stack-buffer-overflow error in example 1.":::
48
48
49
49
## Example - `alloca` overflow (left)
50
50
@@ -76,7 +76,7 @@ devenv /debugexe example2.exe
76
76
77
77
### Resulting error - `alloca` overflow (left)
78
78
79
-

79
+
:::image type="content" source="media/dynamic-stack-buffer-overflow-example-2.png" alt-text="Screenshot of debugger displaying dynamic-stack-buffer-overflow error in example 2.":::
80
80
81
81
## Example - several calls to `alloca`
82
82
@@ -166,7 +166,7 @@ devenv /debugexe example3.exe
166
166
167
167
### Resulting error - several calls to alloca
168
168
169
-

169
+
:::image type="content" source="media/dynamic-stack-buffer-overflow-example-3.png" alt-text="Screenshot of debugger displaying dynamic-stack-buffer-overflow error in example 3.":::

62
+
:::image type="content" source="media/global-overflow-example-1.png" alt-text="Screenshot of debugger displaying global-buffer-overflow error in example 1.":::
63
63
64
64
## Example - simple function level static
65
65
@@ -93,7 +93,7 @@ devenv /debugexe example2.exe
93
93
94
94
### Resulting error - simple function level static
95
95
96
-

96
+
:::image type="content" source="media/global-overflow-example-2.png" alt-text="Screenshot of debugger displaying global-buffer-overflow error in example 2.":::

152
+
:::image type="content" source="media/global-overflow-example-3.png" alt-text="Screenshot of debugger displaying global-buffer-overflow error in example 3.":::
Copy file name to clipboardExpand all lines: docs/sanitizers/error-heap-buffer-overflow.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ devenv /debugexe example1.exe
39
39
40
40
### Resulting error
41
41
42
-

42
+
:::image type="content" source="media/heap-buffer-overflow-example-1.png" alt-text="Screenshot of debugger displaying heap-buffer-overflow error in example 1.":::
43
43
44
44
## Example - improper down cast
45
45
@@ -74,7 +74,7 @@ devenv /debugexe example2.exe
74
74
75
75
### Resulting error - improper down cast
76
76
77
-

77
+
:::image type="content" source="media/heap-buffer-overflow-example-2.png" alt-text="Screenshot of debugger displaying heap-buffer-overflow error in example 2.":::
78
78
79
79
## Example - strncpy into heap
80
80
@@ -105,7 +105,7 @@ devenv /debugexe example3.exe
105
105
106
106
### Resulting error - strncpy into heap
107
107
108
-

108
+
:::image type="content" source="media/heap-buffer-overflow-example-3.png" alt-text="Screenshot of debugger displaying heap-buffer-overflow error in example 3.":::
0 commit comments