Skip to content

Latest commit

 

History

History
71 lines (44 loc) · 4.08 KB

fsanitize.md

File metadata and controls

71 lines (44 loc) · 4.08 KB
description title ms.date f1_keywords helpviewer_keywords
Learn more about the /fsanitize (enable sanitizers) compiler option
/fsanitize (Enable sanitizers)
02/17/2022
/fsanitize
-fsanitize
/fsanitize=address
/fsanitize=fuzzer
/fsanitize-address-use-after-return
-fsanitize-address-use-after-return
/fno-sanitize-address-vcasan-lib
-fno-sanitize-address-vcasan-lib
VC.Project.VCCLCompilerTool.EnableASAN
/fsanitize [C++]
-fsanitize=address [C++]
address sanitizer compiler option [C++]
/fsanitize-address-use-after-return
/fno-sanitize-address-vcasan-lib

/fsanitize (Enable sanitizers)

Use the /fsanitize compiler options to enable sanitizers.

Syntax

/fsanitize=address
/fsanitize=fuzzer
/fsanitize-address-use-after-return
/fno-sanitize-address-vcasan-lib

Remarks

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=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 and /fno-sanitize-address-vcasan-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.

To set the /fsanitize=address compiler option in the Visual Studio development environment

  1. Open your project's Property Pages dialog box.

  2. Select the Configuration Properties > C/C++ > General property page.

  3. Modify the Enable Address Sanitizer property. To enable it, choose Yes (/fsanitize=address).

  4. Choose OK or Apply to save your changes.

To set the /fsanitize=fuzzer compiler option in the Visual Studio development environment

  1. Open your project's Property Pages dialog box.

  2. Select the Configuration Properties > C/C++ > General property page.

  3. Modify the Enable Fuzzer property. To enable it, choose Yes (/fsanitize=fuzzer).

  4. Choose OK or Apply to save your changes.

To set the advanced compiler options

  1. Open your project's Property Pages dialog box.

  2. Select the Configuration Properties > C/C++ > Command Line property page.

  3. Modify the Additional Options property to set /fsanitize-address-use-after-return or /fno-sanitize-address-vcasan-lib.

  4. Choose OK or Apply to save your changes.

To set this compiler option programmatically

  • See xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A.

See also

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