Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions docs/sanitizers/error-alloc-dealloc-mismatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["alloc-dealloc-mismatch error", "AddressSanitizer error al

> Address Sanitizer Error: Mismatch between allocation and deallocation APIs

## Remarks

Enables runtime detection of mismatched memory operations that may lead to undefined behavior, such as:
- `malloc` must be paired with `free`, not `delete` or `delete[]`.
- `new` must be paired with `delete`, not `free` or `delete[]`.
Expand Down
18 changes: 10 additions & 8 deletions docs/sanitizers/error-allocation-size-too-big.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ helpviewer_keywords: ["allocation-size-too-big error", "AddressSanitizer error a

> Address Sanitizer Error: allocation-size-too-big

## Remarks

This example shows the error found when an allocation is too large for the heap. Example sourced from [LLVM compiler-rt test suite](https://github.com/llvm/llvm-project/tree/main/compiler-rt/test/asan/TestCases).

## Example
Expand Down Expand Up @@ -50,11 +52,11 @@ devenv /debugexe example1.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-calloc-overflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["calloc-overflow error", "AddressSanitizer error calloc-ov

> Address Sanitizer Error: calloc-overflow

## Remarks

The CRT function [`calloc`](../c-runtime-library/reference/calloc.md) creates an array in memory with elements initialized to 0. The arguments can create an internal error that leads to a NULL pointer as the return value.

## Example
Expand Down Expand Up @@ -45,11 +47,11 @@ devenv /debugexe example1.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-container-overflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ helpviewer_keywords: ["container-overflow error", "AddressSanitizer error contai

> Address Sanitizer Error: Container overflow

## Remarks

In Visual Studio 2022 version 17.2 and later, the Microsoft Visual C++ standard library (STL) is partially enlightened to work with the AddressSanitizer. The following container types have annotations to detect memory access issues:

| Standard container type | Disable annotations macro | Supported in version |
Expand Down Expand Up @@ -90,11 +92,11 @@ If you want the implementation to trust that your custom allocator is handling t

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-double-free.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ ms.custom: sfi-image-nochange

> Address Sanitizer Error: Deallocation of freed memory

## Remarks

In C, you can call `free` erroneously. In C++, you can call `delete` more than once. In these examples, we show errors with `delete`, `free`, and `HeapCreate`.

## Example C++ - double `operator delete`
Expand Down Expand Up @@ -106,11 +108,11 @@ devenv /debugexe example3.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-dynamic-stack-buffer-overflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["dynamic-stack-buffer-overflow error", "AddressSanitizer e

> Address Sanitizer Error: dynamic-stack-buffer-overflow

## Remarks

This example shows the error that results from a buffer access outside the bounds of a stack-allocated object.

## Example - `alloca` overflow (right)
Expand Down Expand Up @@ -170,11 +172,11 @@ devenv /debugexe example3.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-global-buffer-overflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["global-buffer-overflow error", "AddressSanitizer error gl

> Address Sanitizer Error: Global buffer overflow

## Remarks

The compiler generates metadata for any variable in the `.data` or `.bss` sections. These variables have language scope of global or file static. They're allocated in memory before `main()` starts. Global variables in C are treated much differently than in C++. This difference is because of the complex rules for linking C.

In C, a global variable can be declared in several source files, and each definition can have different types. The compiler can't see all the possible definitions at once, but the linker can. For C, the linker defaults to selecting the largest-sized variable out of all the different declarations.
Expand Down Expand Up @@ -152,11 +154,11 @@ devenv /debugexe example3.exe -l

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-heap-buffer-overflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["heap-buffer-overflow error", "AddressSanitizer error heap

> Address Sanitizer Error: Heap buffer overflow

## Remarks

This example demonstrates the error that results when a memory access occurs outside the bounds of a heap-allocated object.

## Example - classic heap buffer overflow
Expand Down Expand Up @@ -109,11 +111,11 @@ devenv /debugexe example3.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-heap-use-after-free.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["heap-use-after-free error", "AddressSanitizer error heap-

> Address Sanitizer Error: Use of deallocated memory

## Remarks

We show three examples where storage in the heap can be allocated via `malloc`, `realloc` (C), and `new` (C++), along with a mistaken use of `volatile`.

## Example - `malloc`
Expand Down Expand Up @@ -144,11 +146,11 @@ The exception thrown dialog points to line 12, *x = 42, and says: Address Saniti

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-invalid-allocation-alignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["invalid-allocation-alignment error", "AddressSanitizer er

> Address Sanitizer Error: invalid-allocation-alignment

## Remarks

The [`_aligned_malloc`](../c-runtime-library/reference/aligned-malloc.md) function requires a power of 2 for expressing the alignment. We simulate the "external" calculation of some alignment factor using an unoptimized global variable.

## Example
Expand Down Expand Up @@ -42,11 +44,11 @@ devenv /debugexe example1.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-memcpy-param-overlap.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["memcpy-param-overlap error", "AddressSanitizer error memc

> Address Sanitizer Error: memcpy-param-overlap

## Remarks

> [!NOTE]
> The `/Oi` flag is required to reliably detect `memcpy-param-overlap` errors. This flag tells the compiler to treat `memcpy` and other functions as intrinsics, which is necessary because some versions of the standard library implement them as such. Since ASan is a dynamic analysis tool, it can only detect errors with an observable runtime effect. Note that when `/O2` is also set, ASan may not be able to reliably detect `memcpy-param-overlap` errors because the intrinsic variant of these functions isn't guaranteed to be used. For more information, see [`/Oi` docs](../build/reference/oi-generate-intrinsic-functions.md).

Expand Down Expand Up @@ -48,11 +50,11 @@ devenv /debugexe example1.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-new-delete-type-mismatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["new-delete-type-mismatch error", "AddressSanitizer error

> Address Sanitizer Error: Deallocation size different from allocation size

## Remarks

In this example, only `~Base`, and not `~Derived`, is called. The compiler generates a call to `~Base()` because the `Base` destructor isn't **`virtual`**. When we call `delete b`, the object's destructor is bound to the default definition. The code deletes an empty base class (or 1 byte on Windows). A missing **`virtual`** keyword on the destructor declaration is a common C++ error when using inheritance.

## Example - virtual destructor
Expand Down Expand Up @@ -64,11 +66,11 @@ devenv /debugexe example1.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-stack-buffer-overflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["stack-buffer-overflow error", "AddressSanitizer error sta

> Address Sanitizer Error: Stack buffer overflow

## Remarks

A stack buffer overflow can happen many ways in C or C++. We provide several examples for this category of error that you can catch by a simple recompile.

## Example - stack buffer overflow
Expand Down Expand Up @@ -112,11 +114,11 @@ devenv /debugexe example3.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
18 changes: 10 additions & 8 deletions docs/sanitizers/error-stack-buffer-underflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords: ["stack-buffer-underflow error", "AddressSanitizer error st

> Address Sanitizer Error: Stack buffer underflow

## Remarks

These error messages indicate a memory access to somewhere before the beginning of a stack variable.

## Example - local array underflow
Expand Down Expand Up @@ -80,11 +82,11 @@ devenv /debugexe example2.exe

## See also

[AddressSanitizer overview](./asan.md)\
[AddressSanitizer known issues](./asan-known-issues.md)\
[AddressSanitizer build and language reference](./asan-building.md)\
[AddressSanitizer runtime reference](./asan-runtime.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)
[AddressSanitizer overview](asan.md)\
[AddressSanitizer known issues](asan-known-issues.md)\
[AddressSanitizer build and language reference](asan-building.md)\
[AddressSanitizer runtime reference](asan-runtime.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)
Loading