Skip to content

Commit 9662ff6

Browse files
Merge pull request #5987 from davidmrdavid/dev/dajusto/document-asan-user-function
Document how to opt in to ASan runtime options
2 parents 51c4753 + 2ba9246 commit 9662ff6

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

docs/sanitizers/asan-runtime.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,34 @@ Any manual poisoning of shadow bytes must consider the alignment requirements. T
9696

9797
For an illustration of the alignment requirement and potential issues, see the provided [ASan alignment examples](https://github.com/mcgov/asan_alignment_example). One is a small program to show what can go wrong with manual shadow memory poisoning. The second is an example implementation of manual poisoning using the `std::allocator` interface.
9898

99-
## Run-time options
99+
## Runtime options
100100

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+
### Configure runtime options
104+
105+
ASan runtime options are set in one of two ways:
106+
- The `ASAN_OPTIONS` environment variable
107+
- The `__asan_default_options` user function
108+
109+
If the environment variable and the user function specify conflicting options, the options in the `ASAN_OPTIONS` environment variable take precedence.
110+
111+
Multiple options are specified by separating them with a colon (`:`).
112+
113+
The following example sets [`alloc_dealloc_mismatch`](./error-alloc-dealloc-mismatch.md) to one and `symbolize` to zero:
114+
115+
```cmd
116+
set ASAN_OPTIONS=alloc_dealloc_mismatch=1:symbolize=0
117+
```
118+
119+
Or add the following function to your code:
120+
121+
```C++
122+
extern "C" const char* __asan_default_options()
123+
{
124+
return "alloc_dealloc_mismatch=1:symbolize=0";
125+
}
126+
```
102127

103128
### Unsupported AddressSanitizer options
104129

0 commit comments

Comments
 (0)