Skip to content

Commit

Permalink
sanitizers: Add documentation for the no_sanitize attribute
Browse files Browse the repository at this point in the history
Add documentation for the `no_sanitize` attribute, being stabilized in
rust-lang/rust#123617 along with AddressSanitizer and LeakSanitizer.
  • Loading branch information
rcvalle committed Dec 20, 2024
1 parent 1dffb2b commit a29174a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/attributes/codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ 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
#[no_sanitize(address)]
fn foo() {
// ...
}
```

## The `target_feature` attribute

r[attributes.codegen.target_feature]
Expand Down

0 comments on commit a29174a

Please sign in to comment.