description | title | ms.date | f1_keywords | helpviewer_keywords | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about the /fsanitize (enable sanitizers) compiler option |
/fsanitize (Enable sanitizers) |
02/17/2022 |
|
|
Use the /fsanitize
compiler options to enable sanitizers.
/fsanitize=address
/fsanitize=kernel-address
/fsanitize=fuzzer
/fsanitize-address-use-after-return
/fno-sanitize-address-vcasan-lib
/fsanitize-address-asan-compat-lib
/fno-sanitize-address-asan-compat-lib
The /fsanitize=address
compiler option enables AddressSanitizer, a powerful compiler and runtime technology to uncover hard-to-find bugs. Support for the /fsanitize=address
option is available starting in Visual Studio 2019 version 16.9.
The /fsanitize=kernel-address
compiler option enables Kernel AddressSanitizer (KASan). KASan is the kernel-mode variant of AddressSanitizer, available starting in Visual Studio 2022 version 17.11. KASan is only supported on Windows 11 24H2 or Windows Server 2025 and higher, and requires building using a Windows SDK 10.0.26100.2161 and higher. Building with KASan also implies the /fsanitize-address-asan-compat-lib
compiler option.
The /fsanitize=fuzzer
compiler option enables experimental support for LibFuzzer. LibFuzzer is a coverage-guided fuzzing library that can be used to find bugs and crashes caused by user-provided input. We recommended you use /fsanitize=address
with LibFuzzer. This option is useful for fuzzing tools such as OneFuzz. For more information, see the OneFuzz documentation and OneFuzz GitHub project. Support for the /fsanitize=fuzzer
option is available starting in Visual Studio 2022 version 17.0.
The /fsanitize
option doesn't allow comma-separated syntax, for example: /fsanitize=address,fuzzer
. These options must be specified individually.
The /fsanitize-address-use-after-return
, /fno-sanitize-address-vcasan-lib
, /fsanitize-address-asan-compat-lib
, and /fno-sanitize-address-asan-compat-lib
compiler options, and the /INFERASANLIBS
(Use inferred sanitizer libs) and /INFERASANLIBS:NO
linker options offer support for advanced users. For more information, see AddressSanitizer build and language reference.
-
Open your project's Property Pages dialog box.
-
Select the Configuration Properties > C/C++ > General property page.
-
Modify the Enable Address Sanitizer property. To enable it, choose Yes (/fsanitize=address).
-
Choose OK or Apply to save your changes.
-
Open your project's Property Pages dialog box.
-
Select the Configuration Properties > C/C++ > General property page.
-
Modify the Enable Fuzzer property. To enable it, choose Yes (/fsanitize=fuzzer).
-
Choose OK or Apply to save your changes.
-
Open your project's Property Pages dialog box.
-
Select the Configuration Properties > C/C++ > Command Line property page.
-
Modify the Additional Options property to set /fsanitize-address-use-after-return or /fno-sanitize-address-vcasan-lib.
-
Choose OK or Apply to save your changes.
- See xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A.
MSVC compiler options
MSVC compiler command-line syntax
/INFERASANLIBS
(Use inferred sanitizer libs)
/fsanitize-coverage
(Configure sanitizer coverage)
AddressSanitizer overview
AddressSanitizer known issues
AddressSanitizer build and language reference