Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d3cae22
Add ASan Runtime Options Page
macgyvercodilla Aug 8, 2025
62a8be9
Remove unsupported Runtime options. Code Escape flags, values, and code
macgyvercodilla Aug 8, 2025
4b5730b
Write original description for check_malloc_usable_size
macgyvercodilla Aug 11, 2025
b155f11
Update windows flags
macgyvercodilla Aug 11, 2025
b2c6db0
Remove flags with no codepath
macgyvercodilla Aug 11, 2025
ba303de
Fix default value for detect_odr_violation
macgyvercodilla Aug 11, 2025
1f985ca
Add AddressSanitizer Runtime Options to TOC
macgyvercodilla Aug 11, 2025
06bc053
Removed coverage
macgyvercodilla Aug 11, 2025
628fdb2
Removed allow_addr2line
macgyvercodilla Aug 11, 2025
4e983bb
Fix TOC
macgyvercodilla Aug 11, 2025
277f4a2
Use complete, conjugated sentences
39otsu Aug 12, 2025
10f8757
Update docs/sanitizers/asan-flags.md
39otsu Aug 12, 2025
f6c0f6b
Update docs/sanitizers/asan-runtime.md
39otsu Aug 12, 2025
6bf0908
Remove extra word
macgyvercodilla Aug 14, 2025
81b01f8
check_printf not supported on windows
macgyvercodilla Aug 14, 2025
bbb34f4
include not supported on windows
macgyvercodilla Aug 14, 2025
a82940d
Not Supported on windows
macgyvercodilla Aug 14, 2025
f9ce953
Not supported
macgyvercodilla Aug 14, 2025
edb3e0d
Not supported
macgyvercodilla Aug 14, 2025
d1cbd1d
Merge branch 'add-asan-flags' of https://github.com/39otsu/cpp-docs-p…
macgyvercodilla Aug 14, 2025
d9b1669
Update docs/sanitizers/asan-flags.md
39otsu Aug 14, 2025
358044b
Update docs/sanitizers/asan-runtime.md
39otsu Aug 14, 2025
2c9e9b5
Update docs/sanitizers/asan-flags.md
39otsu Aug 14, 2025
4aecc9b
Update docs/sanitizers/asan-flags.md
39otsu Aug 14, 2025
dcf021f
Remove flags for later commit
macgyvercodilla Aug 14, 2025
a1bd6fc
Fix linking
macgyvercodilla Aug 14, 2025
cccf1e6
Merge branch 'add-asan-flags' of https://github.com/39otsu/cpp-docs-p…
macgyvercodilla Aug 14, 2025
9104da3
Update docs/sanitizers/asan-flags.md
39otsu Aug 15, 2025
eeed551
Update docs/sanitizers/asan-flags.md
39otsu Aug 15, 2025
8a8a77f
Update docs/sanitizers/asan-flags.md
39otsu Aug 15, 2025
6e7f383
Update docs/sanitizers/asan-flags.md
39otsu Aug 15, 2025
8d84c4c
Remove more unused flags
macgyvercodilla Aug 15, 2025
6d7cd9c
Fix verbiage
macgyvercodilla Aug 15, 2025
925462e
Fix verbiage
macgyvercodilla Aug 15, 2025
3696d2b
Remove flag and fix verbiage
macgyvercodilla Aug 15, 2025
adb8ee3
Improve verbiage
macgyvercodilla Aug 15, 2025
1b31a19
Merge branch 'add-asan-flags' of https://github.com/39otsu/cpp-docs-p…
macgyvercodilla Aug 15, 2025
de63d18
Fix table syntax
macgyvercodilla Aug 15, 2025
f05cd86
Added experimental disclaimer
macgyvercodilla Aug 15, 2025
b4a378d
We still honor quarantine_size
macgyvercodilla Aug 15, 2025
e553bab
Update docs/sanitizers/asan-flags.md
39otsu Aug 15, 2025
21412ee
Update docs/sanitizers/asan-flags.md
39otsu Aug 15, 2025
25e3e35
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
3294e87
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
9ffd68e
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
0acef61
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
042aa0d
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
7f917eb
Modify flag descriptions
macgyvercodilla Aug 25, 2025
c4bd9a3
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
5c70307
Remove absolute linking
macgyvercodilla Aug 25, 2025
7e1c524
Merge branch 'add-asan-flags' of https://github.com/39otsu/cpp-docs-p…
macgyvercodilla Aug 25, 2025
de3ea57
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
5c30a89
Fix table formatting
macgyvercodilla Aug 25, 2025
91cd515
Removed deprecated flag
macgyvercodilla Aug 25, 2025
2c3c96a
Incorporate Acrolinx suggestions
macgyvercodilla Aug 25, 2025
342a008
More Acrolinx suggestions
macgyvercodilla Aug 25, 2025
809d8fa
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
5e2feab
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
33c1648
Update docs/sanitizers/asan-flags.md
39otsu Aug 25, 2025
a832613
Add values for stack_trace_format
macgyvercodilla Aug 25, 2025
4f2daa0
Merge branch 'add-asan-flags' of https://github.com/39otsu/cpp-docs-p…
macgyvercodilla Aug 25, 2025
a8d5cca
Fix description
macgyvercodilla Aug 25, 2025
ec50c94
Verbosity level
macgyvercodilla Aug 25, 2025
25d96f1
Add line breaks in stack_trace_format description
macgyvercodilla Aug 25, 2025
5a3850c
Change integer to boolean
macgyvercodilla Aug 25, 2025
0ba0253
Update AddressSanitizer options descriptions
TylerMSFT Sep 3, 2025
e56d2df
Reorder runtime reference in table of contents
TylerMSFT Sep 3, 2025
7a1207f
Update ASAN_OPTIONS descriptions for clarity
TylerMSFT Sep 3, 2025
c77b36b
Fix formatting and descriptions in asan-flags.md
TylerMSFT Sep 3, 2025
7a8a30b
Very small edit. Should have got it earlier.
TylerMSFT Sep 3, 2025
2922a7e
Code escape values
macgyvercodilla Sep 3, 2025
d2cd848
Merge branch 'add-asan-flags' of https://github.com/39otsu/cpp-docs-p…
macgyvercodilla Sep 3, 2025
cdcc4a5
Revert "Code escape values"
macgyvercodilla Sep 3, 2025
fb5fa01
Merge pull request #6036 from 39otsu/add-asan-flags
JillGrant615 Sep 3, 2025
039329a
Merge pull request #6065 from MicrosoftDocs/main
learn-build-service-prod[bot] Sep 4, 2025
993e83b
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs…
Sep 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions docs/sanitizers/asan-flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: "AddressSanitizer Runtime Options"
description: "List of runtime options for the Microsoft C/C++ Address Sanitizer"
ms.date: 8/08/2025
helpviewer_keywords: ["AddressSanitizer options", "AddressSanitizer flags", "Address sanitizer options", "Address sanitizer flags", "asan options", "asan flags", "sanitizer flags", "asan_options", "AddressSanitizerFlags", "SanitizerCommonFlags"]
---

# AddressSanitizer Runtime Options

The following table lists the options for the AddressSanitizer. Enable them via the `ASAN_OPTIONS` environment variable or by overriding the `__asan_default_options()` user function described [here](./asan-runtime.md#runtime-options).

> [!NOTE]
> These descriptions account for Microsoft Visual C++ (MSVC) specific behaviors, which may vary from Clang's runtime options.


| Flag | Default value | Description |
|------|---------------|-------------|
|`abort_on_error` | `false` | If `true`, ASan calls `abort()` instead of `_exit()` after printing the error report.|
|`alloc_dealloc_mismatch` | `false` | Detects mismatched memory operations such as `malloc`/`delete`, `new[]`/`free`, and so on.|
|`allocator_frees_and_returns_null_on_realloc_zero` | `true` | If set to `true`, `realloc(p, 0)` is the same as `free(p)` by default (which is the same as the POSIX standard). If set to `false`, `realloc(p, 0)` returns a pointer to an allocated space that can't be used. |
|`allocator_may_return_null` | `false` | If `true`, the allocator returns `nullptr` when out of memory. Instead of crashing, ASan emits a warning about the allocator's failure and execution continues.|
|`allow_user_poisoning` | `true` | If `true`, you may manually mark memory regions as poisoned or unpoisoned using the [Manual AddressSanitizer poising interface](./asan-runtime.md#poisoning).|
|`check_initialization_order` | `false` | If `true`, attempts to catch initialization order issues.|
|`continue_on_error` | 0 | Allows an application to continue running while reporting memory safety errors.<br>0-disabled.<br>1-enabled; errors are sent to `stdout`.<br>2-enabled; errors are sent to `stderr`.<br>For more information, see [continue_on_error](asan-continue-on-error.md).|
|`detect_container_overflow` | `true` | If `true`, honor the container overflow annotations. For more information, see [ContainerOverflow](./error-container-overflow.md).|
|`detect_invalid_pointer_pairs` | `false` | If `true`, ASan detects operations like `<`, `<=`, `>`, `>=`, and `-` on invalid pointer pairs such as pointers that belong to different objects.|
|`detect_stack_use_after_return` | `false` | Experimental. If `true`, ASan enables `stack-use-after-return` checking at runtime. Requires `/fsanitize-address-use-after-return`. For more information, see [stack-use-after-return](./error-stack-use-after-return.md).|
|`exitcode` | 1 | Overrides the program exit status with this value if ASan finds an error.|
|`external_symbolizer_path` | "" | Path to the external symbolizer. If empty, ASan searches `$PATH` for the symbolizer.|
|`fast_unwind_on_malloc` | `true` | If available, ASan uses the fast frame-pointer-based unwinder on `malloc`/`free`.|
|`halt_on_error` | `true` | Not supported. Use `continue_on_error` instead.|
|`handle_segv` | `true` | If `true`, ASan handles `SEGV` errors.|
|`handle_sigfpe` | `true` | If `true`, ASan handles `SIGFPE` errors.|
|`handle_sigill` | `true` | If `true`, ASan handles `SIGILL` errors.|
|`help` | `false` | If `true`, ASan prints the flag options to the console.|
|`iat_overwrite`|`error`|`error` - reports an error whenever an overwrite is detected.<br>`protect` - trys to avoid using the overwritten definition.<br>`ignore` - doesn't try to correct any overwritten functions. For more information, see [`iat_overwrite`](./asan-runtime.md#msvc-specific-addresssanitizer-runtime-options).|
|`include_if_exists` | "" | Reads options from the specified file. ASan doesn't fail if the file doesn't exist.|
|`intercept_strpbrk` | `true` | If `true`, uses custom wrappers for `strpbrk` to find more errors.|
|`intercept_strspn` | `true` | If `true`, uses custom wrappers for `strspn` and `strcspn` to find more errors.|
|`intercept_strstr` | `true` | If `true`, uses custom wrappers for `strstr` and `strcasestr` to find more errors.|
|`malloc_context_size` | 1 | Maximum number of stack frames to keep for each allocation/deallocation.|
|`malloc_fill_byte` | `0xbe` | Value used to fill newly allocated memory.|
|`max_malloc_fill_size` | 4096 | The ASan allocator fills an allocation with `malloc_fill_byte` up to `max_malloc_fill_size` on a call to `malloc`.|
|`max_redzone` | 2048 | Maximum size (in bytes) of redzones around heap objects.|
|`new_delete_type_mismatch` | `true` | Report errors on mismatch between the size of `new` and `delete`. For more information, see [`new-delete-type-mismatch`](./error-new-delete-type-mismatch.md).|
|`poison_heap` | `true` | If `true`, poison the heap memory on allocation and deallocation. `false` is useful for benchmarking the allocator or instrumentator.|
|`poison_partial` | `true` | If `true`, poison partially addressable 8-byte aligned words. This flag affects heap and global buffers, but not stack buffers.|
|`print_cmdline` | `false` | Print the command line on crash. With `continue_on_error` set >= 1, prints the current working directory and is `UTF-16` aware.|
|`print_summary` | `true` | If `false`, disables showing error summaries that accompany error reports.|
|`quarantine_size_mb` | -1 | Size (in Mb) of quarantine used to detect `use-after-free` errors. A lower value may increase the chance of false negatives.|
|`redzone` | 16 | Minimum size (in bytes) of redzones around heap objects. Requirement: `redzone >= 16` and must be a power of two.|
|`replace_str` | `true` | If `true`, uses custom wrappers and replacements for `libc` string functions to find more errors.|
|`report_globals` | 1 | How to respond to buffer overflow for globals:<br>0-don't detect buffer overflow on globals.<br>1 - detect buffer overflow.<br>2 - detect buffer overflow and print registered globals data.|
|`sleep_before_dying` | 0 | Number of seconds to sleep between printing an error report and terminating the program.|
|`stack_trace_format` | `DEFAULT` | Format string used to render stack frames. `DEFAULT` - ` #%n %p %F %L`. List of available placeholders:<br> `%%` - represents a `'%'` character<br> `%n` - frame number (copy of `frame_no`)<br> `%p` - `PC`<br> `%m` - path to module<br> `%o` - offset in the module<br> `%f` - function name<br> `%q` - if available, offset in the function<br> `%s` - path to source file<br> `%l` - line in the source file<br> `%c` - column in the source file<br> `%F` - if the function is known, ASan prints `in <func name>` followed by the offset in this function if source is unknown<br> `%S` - ASan prints file/line/column information<br> `%L` - If file information is available, ASan prints the file name, line, and column. If module information is available, ASan prints the module name, offset, and architecture. If neither are available, ASan prints `(<unknown module>)`<br> `%M` - If known, ASan prints module basename and offset, or `PC`|
|`strict_memcmp` | `true` | If `true`, assumes that `memcmp(p1, p2, n)` always reads `n` bytes before comparing `p1` and `p2`.|
|`strict_string_checks` | `false` | If `true` checks that string arguments are properly null-terminated.|
|`strip_path_prefix` | "" | Strips this prefix from file paths in error reports.|
|`symbolize` | `true` | If `true`, use the `llvm-symbolizer` to turn virtual addresses into file or line locations.|
|`symbolize_inline_frames` | `true` | Print inlined frames in stacktraces.|
|`verbosity` | 0 | Verbosity level:<br>0 - default verbosity.<br>1 - more output.<br>2 - even more output.<br>3 - maximum verbosity. |
|`windows_fast_fail_on_error`| `false` | If `true`, the process can terminate with a `__fastfail(71)` after printing the error report. For more information, see [`windows_fast_fail_on_error`](./asan-runtime.md#msvc-specific-addresssanitizer-runtime-options).|
|`windows_hook_legacy_allocators`| `true` |If `true`, enables hooking of (`Global`/`Local`)(`Alloc`/`Free`/`Size`/`ReAlloc`/`Lock`/`Unlock`) functions.|

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer shadow bytes](./asan-shadow-bytes.md)\
[AddressSanitizer cloud or distributed testing](./asan-offline-crash-dumps.md)\
[AddressSanitizer debugger integration](./asan-debugger-integration.md)\
[AddressSanitizer error examples](./asan-error-examples.md)
2 changes: 1 addition & 1 deletion docs/sanitizers/asan-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ For an illustration of the alignment requirement and potential issues, see the p

## Runtime options

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).
The MSVC AddressSanitizer is a regularly synced fork of the [Clang AddressSanitizer runtime](https://github.com/llvm/llvm-project). As a result, MSVC implicitly inherits many of Clang's ASan runtime options. A complete list of options that we actively maintain and test can be found [here](./asan-flags.md). If you discover options that don't function as expected, [report a bug](https://aka.ms/feedback/report?space=62).

### Configure runtime options

Expand Down
2 changes: 2 additions & 0 deletions docs/sanitizers/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ items:
href: ../sanitizers/asan-continue-on-error.md
- name: "Build and language reference"
href: ../sanitizers/asan-building.md
- name: "Runtime options"
href: ../sanitizers/asan-flags.md
- name: "Runtime reference"
href: ../sanitizers/asan-runtime.md
- name: "Debugger integration"
Expand Down