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/sanitizers/asan-runtime.md
+41-1Lines changed: 41 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,47 @@ For an illustration of the alignment requirement and potential issues, see the p
98
98
99
99
## Run-time options
100
100
101
-
Microsoft C/C++ (MSVC) uses a runtime based on the [Clang AddressSanitizer runtime from the llvm-project repository](https://github.com/llvm/llvm-project). Because of this, most runtime options are shared between the two versions. [A complete list of the public Clang runtime options is available here](https://github.com/google/sanitizers/wiki/SanitizerCommonFlags). We document some differences in the sections that follow. If you discover options that don't function as expected, [report a bug](https://aka.ms/feedback/report?space=62).
101
+
The MSVC AddressSanitizer is based on the [Clang AddressSanitizer runtime from the llvm-project repository](https://github.com/llvm/llvm-project). Because of this, most of clang's ASan runtime options available in MSVC as well. [A complete list of the public Clang runtime options is available here](https://github.com/google/sanitizers/wiki/SanitizerCommonFlags). We document some differences in the sections that follow. If you discover options that don't function as expected, [report a bug](https://aka.ms/feedback/report?space=62).
102
+
103
+
### Configuring runtime options
104
+
105
+
ASan runtime options can be set in one of two ways: through the `ASAN_OPTIONS` environment variable, or the `__asan_default_options` user function. If the environment variable and the user function select conflicting options, the selection in the `ASAN_OPTIONS` environment variable takes precedence.
106
+
107
+
For example, to select the [`alloc_dealloc_mismatch`](./error-alloc-dealloc-mismatch.md) flag, you may use:
108
+
109
+
```cmd
110
+
set ASAN_OPTIONS=alloc_dealloc_mismatch=1
111
+
```
112
+
113
+
or alternatively use the user-function
114
+
115
+
```C++
116
+
extern "C" const char*__asan_default_options() {
117
+
return "alloc_dealloc_mismatch=1";
118
+
}
119
+
120
+
// ... your code below, such as your `main` function
121
+
```
122
+
123
+
Multiple options can be specified by separating them with a colon (i.e `:`). For example, to additionally set `symbolize=0`, one may use:
124
+
125
+
126
+
```cmd
127
+
set ASAN_OPTIONS=alloc_dealloc_mismatch=1:symbolize=0
128
+
```
129
+
130
+
or alternatively, through the the user-function
131
+
132
+
```C++
133
+
extern "C" const char*__asan_default_options() {
134
+
return "alloc_dealloc_mismatch=1:symbolize=0;
135
+
}
136
+
137
+
// ... your code below, such as your `main` function
138
+
```
139
+
140
+
> [!NOTE]
141
+
> The `ASAN_OPTIONS` environment variable is recommended method for selecting runtime options because it makes the configuration available to the process from the beginning, which helps with correctness. Meanwhile, the user function can only be parsed after the ASan runtime has already been initialized, which means it's options are applied retroactively.
0 commit comments