Skip to content

Commit 78bc7a3

Browse files
Merge pull request #6115 from MicrosoftDocs/FromPublicMasterBranch
Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main)
2 parents 6f79b9d + ff2c818 commit 78bc7a3

File tree

2 files changed

+38
-36
lines changed

2 files changed

+38
-36
lines changed

docs/build/reference/zc-conformance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Here are the **`/Zc`** compiler options:
3636
| [`/Zc:hiddenFriend[-]`](zc-hiddenfriend.md) | Enforce Standard C++ hidden friend rules. Off by default unless **`/permissive-`** is specified. |
3737
| [`/Zc:implicitNoexcept[-]`](zc-implicitnoexcept-implicit-exception-specifiers.md) | Enable implicit **`noexcept`** on required functions. On by default. |
3838
| [`/Zc:inline[-]`](zc-inline-remove-unreferenced-comdat.md) | Remove unreferenced functions or data if they're COMDAT or have internal linkage only. Off by default. |
39-
| [`/Zc:lambda[-]`](zc-lambda.md) | Enable new lambda processor for conformance-mode syntactic checks in generic lambdas. Off by default unless **`/std:c++20`** or later is specified. |
39+
| [`/Zc:lambda[-]`](zc-lambda.md) | Enable new lambda processor for conformance-mode syntactic checks in generic lambdas. Off by default unless **`/permissive-`** or **`/std:c++20`** or later is specified. |
4040
| [`/Zc:noexceptTypes[-]`](zc-noexcepttypes.md) | Enforce C++17 **`noexcept`** rules. Off by default unless **`/std:c++17`** or later is specified. |
4141
| [`/Zc:nrvo[-]`](zc-nrvo.md) | Enable optional copy and move elisions. Off by default unless **`/O2`**, **`/permissive-`**, or **`/std:c++20`** or later is specified. |
4242
| [`/Zc:preprocessor[-]`](zc-preprocessor.md) | Use the new conforming preprocessor. Off by default unless **`/std:c11`** or later is specified. |

docs/sanitizers/asan-runtime.md

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ helpviewer_keywords: ["AddressSanitizer runtime", "Address Sanitizer runtime", "
77

88
# AddressSanitizer runtime
99

10-
The AddressSanitizer runtime library intercepts common memory allocation functions and operations to enable inspection of memory accesses. There are several different runtime libraries that support the various types of executables the compiler may generate. The compiler and linker automatically link the appropriate runtime libraries, as long as you pass the [`/fsanitize=address`](../build/reference/fsanitize.md) option at compile time. You can override the default behavior by using the **`/NODEFAULTLIB`** option at link time. For more information, see the section on [linking](./asan-building.md#linker) in the [AddressSanitizer language, build, and debugging reference](./asan-building.md).
10+
The AddressSanitizer runtime library intercepts common memory allocation functions and operations to enable inspection of memory accesses. There are several different runtime libraries that support the various types of executables the compiler may generate. The compiler and linker automatically link the appropriate runtime libraries, as long as you pass the [`/fsanitize=address`](../build/reference/fsanitize.md) option at compile time. You can override the default behavior by using the **`/NODEFAULTLIB`** option at link time. For more information, see the section on [linking](asan-building.md#linker) in the [AddressSanitizer language, build, and debugging reference](asan-building.md).
1111

12-
When compiling with `cl /fsanitize=address`, the compiler generates instructions to manage and check [shadow bytes](./asan-shadow-bytes.md). Your program uses this instrumentation to check memory accesses on the stack, in the heap, or in the global scope. The compiler also produces metadata describing stack and global variables. This metadata enables the runtime to generate precise error diagnostics: function names, lines, and columns in your source code. Combined, the compiler checks and runtime libraries can precisely diagnose many types of [memory safety bugs](./asan-error-examples.md) if they're encountered at run-time.
12+
When compiling with `cl /fsanitize=address`, the compiler generates instructions to manage and check [shadow bytes](asan-shadow-bytes.md). Your program uses this instrumentation to check memory accesses on the stack, in the heap, or in the global scope. The compiler also produces metadata describing stack and global variables. This metadata enables the runtime to generate precise error diagnostics: function names, lines, and columns in your source code. Combined, the compiler checks and runtime libraries can precisely diagnose many types of [memory safety bugs](asan-error-examples.md) if they're encountered at run-time.
1313

14-
The list of runtime libraries for linking to the AddressSanitizer runtime, as of Visual Studio 17.7 Preview 3, follows. For more information about the `/MT` (statically link the runtime) and `/MD` (dynamically link the redist at runtime) options, see [/MD, /MT, /LD (Use Run-Time Library)](../build/reference/md-mt-ld-use-run-time-library.md).
14+
The list of runtime libraries for linking to the AddressSanitizer runtime, as of Visual Studio 17.7 Preview 3, follows. For more information about the `/MT` (statically link the runtime) and `/MD` (dynamically link the redist at runtime) options, see [`/MD`, `/MT`, `/LD` (Use Run-Time Library)](../build/reference/md-mt-ld-use-run-time-library.md).
1515

1616
> [!NOTE]
1717
> In the following table, *`{arch}`* is either *`i386`* or *`x86_64`*.
1818
> These libraries use Clang conventions for architecture names. MSVC conventions are normally `x86` and `x64` rather than `i386` and `x86_64`, but they refer to the same architectures.
1919
20-
| CRT option | AddressSanitizer runtime library (.lib) | Address runtime binary (.dll)
20+
| CRT option | AddressSanitizer runtime library (`.lib`) | Address runtime binary (`.dll`)
2121
|--|--|--|
2222
| `/MT` or `/MTd` | *`clang_rt.asan_dynamic-{arch}`*, *`clang_rt.asan_static_runtime_thunk-{arch}`* | *`clang_rt.asan_dynamic-{arch}`*
2323
| `/MD` or `/MDd` | *`clang_rt.asan_dynamic-{arch}`*, *`clang_rt.asan_dynamic_runtime_thunk-{arch}`* | *`clang_rt.asan_dynamic-{arch}`*
@@ -31,7 +31,7 @@ The image shows three scenarios for linking the runtime library. The first is /M
3131
The following diagram shows how the ASan library is linked for various compiler options:
3232

3333
:::image type="complex" source="media/asan-one-dll.png" alt-text="Diagram of how the ASan runtime dll is linked."
34-
The image shows four scenarios for linking the ASan runtime library. The scenarios are for /MT (statically link the runtime), /MTd (statically link the debug runtime), /MD (dynamically link the redist at runtime), /MDd (dynamically link the debug redist at runtime). In all cases, my_exe.exe links and its associates my_dll.dll link to a single instance of clang-rt.asan-dynamix-x86_64.dll.
34+
The image shows four scenarios for linking the ASan runtime library. The scenarios are for /MT (statically link the runtime), /MTd (statically link the debug runtime), /MD (dynamically link the redist at runtime), /MDd (dynamically link the debug redist at runtime). In all cases, my_exe.exe links and its associates my_dll.dll link to a single instance of clang_rt.asan_dynamic-x86_64.dll.
3535
:::image-end:::
3636

3737
Even when statically linking, the ASan runtime DLL must be present at runtime--unlike other C Runtime components.
@@ -63,7 +63,7 @@ The image shows four scenarios for linking the ASan runtime library. The scenari
6363

6464
The AddressSanitizer achieves function interception through many hotpatching techniques. These techniques are [best documented within the source code itself](https://github.com/llvm/llvm-project/blob/1a2eaebc09c6a200f93b8beb37130c8b8aab3934/compiler-rt/lib/interception/interception_win.cpp#L11).
6565

66-
The runtime libraries intercept many common memory management and memory manipulation functions. For a list, see [AddressSanitizer list of intercepted functions](#intercepted_functions). The allocation interceptors manage metadata and shadow bytes related to each allocation call. Every time a CRT function such as `malloc` or `delete` is called, the interceptors set specific values in the AddressSanitizer shadow-memory region to indicate whether those heap locations are currently accessible and what the bounds of the allocation are. These shadow bytes allow the compiler-generated checks of the [shadow bytes](./asan-shadow-bytes.md) to determine whether a load or store is valid.
66+
The runtime libraries intercept many common memory management and memory manipulation functions. For a list, see [AddressSanitizer list of intercepted functions](#intercepted_functions). The allocation interceptors manage metadata and shadow bytes related to each allocation call. Every time a CRT function such as `malloc` or `delete` is called, the interceptors set specific values in the AddressSanitizer shadow-memory region to indicate whether those heap locations are currently accessible and what the bounds of the allocation are. These shadow bytes allow the compiler-generated checks of the [shadow bytes](asan-shadow-bytes.md) to determine whether a load or store is valid.
6767

6868
Interception isn't guaranteed to succeed. If a function prologue is too short for a `jmp` to be written, interception can fail. If an interception failure occurs, the program throws a `debugbreak` and halts. If you attach a debugger, it makes the cause of the interception issue clear. If you have this problem, [report a bug](https://aka.ms/feedback/report?space=62).
6969

@@ -72,7 +72,7 @@ Interception isn't guaranteed to succeed. If a function prologue is too short fo
7272
7373
## Custom allocators and the AddressSanitizer runtime
7474

75-
The AddressSanitizer runtime provides interceptors for common allocator interfaces, `malloc`/`free`, `new`/`delete`, `HeapAlloc`/`HeapFree` (via `RtlAllocateHeap`/`RtlFreeHeap`). Many programs make use of custom allocators for one reason or another, an example would be any program using `dlmalloc` or a solution using the `std::allocator` interface and `VirtualAlloc()`. The compiler is unable to automatically add shadow-memory management calls to a custom allocator. It's the user's responsibility to use the [provided manual poisoning interface](#poisoning). This API enables these allocators to function properly with the existing AddressSanitizer runtime and [shadow byte](./asan-shadow-bytes.md) conventions.
75+
The AddressSanitizer runtime provides interceptors for common allocator interfaces, `malloc`/`free`, `new`/`delete`, `HeapAlloc`/`HeapFree` (via `RtlAllocateHeap`/`RtlFreeHeap`). Many programs make use of custom allocators for one reason or another, an example would be any program using `dlmalloc` or a solution using the `std::allocator` interface and `VirtualAlloc()`. The compiler is unable to automatically add shadow-memory management calls to a custom allocator. It's the user's responsibility to use the [provided manual poisoning interface](#poisoning). This API enables these allocators to function properly with the existing AddressSanitizer runtime and [shadow byte](asan-shadow-bytes.md) conventions.
7676

7777
## <a name="poisoning"></a> Manual AddressSanitizer poisoning interface
7878

@@ -103,6 +103,7 @@ For an illustration of the alignment requirement and potential issues, see the p
103103

104104
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).
105105

106+
106107
### Configure runtime options
107108

108109
ASan runtime options are set in one of two ways:
@@ -113,15 +114,15 @@ If the environment variable and the user function specify conflicting options, t
113114

114115
Multiple options are specified by separating them with a colon (`:`).
115116

116-
The following example sets [`alloc_dealloc_mismatch`](./error-alloc-dealloc-mismatch.md) to one and `symbolize` to zero:
117+
The following example sets [`alloc_dealloc_mismatch`](error-alloc-dealloc-mismatch.md) to one and `symbolize` to zero:
117118

118119
```cmd
119120
set ASAN_OPTIONS=alloc_dealloc_mismatch=1:symbolize=0
120121
```
121122

122123
Or add the following function to your code:
123124

124-
```C++
125+
```cpp
125126
extern "C" const char* __asan_default_options()
126127
{
127128
return "alloc_dealloc_mismatch=1:symbolize=0";
@@ -130,8 +131,8 @@ extern "C" const char* __asan_default_options()
130131

131132
### Unsupported AddressSanitizer options
132133

133-
- detect_container_overflow
134-
- unmap_shadow_on_exit
134+
- `detect_container_overflow`
135+
- `unmap_shadow_on_exit`
135136

136137
> [!NOTE]
137138
> The AddressSanitizer runtime option `halt_on_error` doesn't function the way you might expect. In both the Clang and the MSVC runtime libraries, many error types are considered **non-continuable**, including most memory corruption errors.
@@ -152,9 +153,10 @@ For more information, see the [Differences with Clang 12.0](asan.md#differences)
152153
- If set to `"ignore"`, the runtime doesn't attempt to correct any overwritten functions and proceeds with execution.
153154

154155
- `windows_fast_fail_on_error`
155-
Boolean (false by default), set to `true` to enable the process to terminate with a __fastfail(71) after printing the error report.
156-
>[!NOTE]
157-
>When abort_on_error value is set to true, on Windows the program terminates with an exit(3). In order to not change current behavior we decided to introduce this new option instead. If both abort_on_error and windows_fast_fail_on_error are true, the program will exit with the __fastfail.
156+
Boolean (`false` by default), set to `true` to enable the process to terminate with a `__fastfail(71)` after printing the error report.
157+
158+
> [!NOTE]
159+
> When `abort_on_error` value is set to `true`, on Windows the program terminates with an `exit(3)`. In order to not change current behavior we decided to introduce this new option instead. If both `abort_on_error` and `windows_fast_fail_on_error` are `true`, the program will exit with the `__fastfail`.
158160
159161
- `windows_hook_legacy_allocators`
160162
Boolean, set to `false` to disable interception of [`GlobalAlloc`](/windows/win32/api/winbase/nf-winbase-globalalloc) and [`LocalAlloc`](/windows/win32/api/winbase/nf-winbase-localalloc) allocators.
@@ -217,7 +219,7 @@ The AddressSanitizer runtime hotpatches many functions to enable memory safety c
217219
- [`realloc`](../c-runtime-library/reference/realloc.md)
218220
- [`RtlAllocateHeap`](/windows-hardware/drivers/ddi/ntifs/nf-ntifs-rtlallocateheap)
219221
- [`RtlCreateHeap`](/windows-hardware/drivers/ddi/ntifs/nf-ntifs-rtlcreateheap)
220-
- [`RtlDestroyHeap`](/windows-hardware/drivers/ddi/ntifs/nf-ntifs-rtlcreateheap)
222+
- [`RtlDestroyHeap`](/windows-hardware/drivers/ddi/ntifs/nf-ntifs-rtldestroyheap)
221223
- [`RtlFreeHeap`](/windows-hardware/drivers/ddi/ntifs/nf-ntifs-rtlfreeheap)
222224
- [`RtlRaiseException`](/windows/win32/api/rtlsupportapi/nf-rtlsupportapi-rtlraiseexception)
223225
- `RtlReAllocateHeap` (undocumented)
@@ -248,26 +250,26 @@ The interceptors listed here are only installed when an AddressSanitizer runtime
248250
`set ASAN_OPTIONS=windows_hook_legacy_allocators=false`
249251

250252
- [`GlobalAlloc`](/windows/win32/api/winbase/nf-winbase-globalalloc)
251-
- [`GlobalFree`](/windows/win32/api/winbase/nf-winbase-GlobalFree)
252-
- [`GlobalHandle`](/windows/win32/api/winbase/nf-winbase-GlobalHandle)
253-
- [`GlobalLock`](/windows/win32/api/winbase/nf-winbase-GlobalLock)
254-
- [`GlobalReAlloc`](/windows/win32/api/winbase/nf-winbase-GlobalReAlloc)
255-
- [`GlobalSize`](/windows/win32/api/winbase/nf-winbase-GlobalSize)
256-
- [`GlobalUnlock`](/windows/win32/api/winbase/nf-winbase-GlobalUnlock)
257-
- [`LocalAlloc`](/windows/win32/api/winbase/nf-winbase-LocalAlloc)
258-
- [`LocalFree`](/windows/win32/api/winbase/nf-winbase-LocalFree)
259-
- [`LocalHandle`](/windows/win32/api/winbase/nf-winbase-LocalHandle)
260-
- [`LocalLock`](/windows/win32/api/winbase/nf-winbase-LocalLock)
261-
- [`LocalReAlloc`](/windows/win32/api/winbase/nf-winbase-LocalReAlloc)
262-
- [`LocalSize`](/windows/win32/api/winbase/nf-winbase-LocalSize)
263-
- [`LocalUnlock`](/windows/win32/api/winbase/nf-winbase-LocalUnlock)
253+
- [`GlobalFree`](/windows/win32/api/winbase/nf-winbase-globalfree)
254+
- [`GlobalHandle`](/windows/win32/api/winbase/nf-winbase-globalhandle)
255+
- [`GlobalLock`](/windows/win32/api/winbase/nf-winbase-globallock)
256+
- [`GlobalReAlloc`](/windows/win32/api/winbase/nf-winbase-globalrealloc)
257+
- [`GlobalSize`](/windows/win32/api/winbase/nf-winbase-globalsize)
258+
- [`GlobalUnlock`](/windows/win32/api/winbase/nf-winbase-globalunlock)
259+
- [`LocalAlloc`](/windows/win32/api/winbase/nf-winbase-localalloc)
260+
- [`LocalFree`](/windows/win32/api/winbase/nf-winbase-localfree)
261+
- [`LocalHandle`](/windows/win32/api/winbase/nf-winbase-localhandle)
262+
- [`LocalLock`](/windows/win32/api/winbase/nf-winbase-locallock)
263+
- [`LocalReAlloc`](/windows/win32/api/winbase/nf-winbase-localrealloc)
264+
- [`LocalSize`](/windows/win32/api/winbase/nf-winbase-localsize)
265+
- [`LocalUnlock`](/windows/win32/api/winbase/nf-winbase-localunlock)
264266

265267
## See also
266268

267-
[AddressSanitizer overview](./asan.md)\
268-
[AddressSanitizer known issues](./asan-known-issues.md)\
269-
[AddressSanitizer build and language reference](./asan-building.md)\
270-
[AddressSanitizer shadow bytes](./asan-shadow-bytes.md)\
271-
[AddressSanitizer cloud or distributed testing](./asan-offline-crash-dumps.md)\
272-
[AddressSanitizer debugger integration](./asan-debugger-integration.md)\
273-
[AddressSanitizer error examples](./asan-error-examples.md)
269+
[AddressSanitizer overview](asan.md)\
270+
[AddressSanitizer known issues](asan-known-issues.md)\
271+
[AddressSanitizer build and language reference](asan-building.md)\
272+
[AddressSanitizer shadow bytes](asan-shadow-bytes.md)\
273+
[AddressSanitizer cloud or distributed testing](asan-offline-crash-dumps.md)\
274+
[AddressSanitizer debugger integration](asan-debugger-integration.md)\
275+
[AddressSanitizer error examples](asan-error-examples.md)

0 commit comments

Comments
 (0)