From 8907f6d317429f8ab9142d4dadbf2db6ebbf60bc Mon Sep 17 00:00:00 2001 From: Ramon de C Valle Date: Fri, 20 Dec 2024 05:11:49 +0000 Subject: [PATCH] sanitizers: Add documentation for the `no_sanitize` attribute Add documentation for the `no_sanitize` attribute, being stabilized in rust-lang/rust#123617 along with AddressSanitizer and LeakSanitizer. --- src/attributes/codegen.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index 297d6436f..3e135c9fe 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -59,6 +59,28 @@ The *`no_builtins` [attribute]* may be applied at the crate level to disable optimizing certain code patterns to invocations of library functions that are assumed to exist. +## The `no_sanitize` attribute + +The `no_sanitize` attribute can be used to selectively disable sanitizer +instrumentation in an annotated function. This might be useful to: avoid +instrumentation overhead in a performance critical function, or avoid +instrumenting code that contains constructs unsupported by given sanitizer. + +The precise effect of this annotation depends on particular sanitizer in use. +For example, with `no_sanitize(thread)`, the thread sanitizer will no longer +instrument non-atomic store / load operations, but it will instrument atomic +operations to avoid reporting false positives and provide meaning full stack +traces. + +``` rust +#![feature(no_sanitize)] + +#[no_sanitize(address)] +fn foo() { + // ... +} +``` + ## The `target_feature` attribute r[attributes.codegen.target_feature]