Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Use the /fsanitize compiler options to enable sanitizers.
Syntax
/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
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=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.
To set the /fsanitize=address compiler option in the Visual Studio development environment
Open your project's Property Pages dialog box.
Select the Configuration Properties > C/C++ > General property page.
Modify the Enable AddressSanitizer property. To enable it, choose Yes (/fsanitize=address).
Choose OK or Apply to save your changes.
To set the /fsanitize=fuzzer compiler option in the Visual Studio development environment
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.
To set the advanced compiler options
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.
To set this compiler option programmatically
- See AdditionalOptions.
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