Skip to content

Commit a29174a

Browse files
committed
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.
1 parent 1dffb2b commit a29174a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/attributes/codegen.md

+20
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ The *`no_builtins` [attribute]* may be applied at the crate level to disable
5959
optimizing certain code patterns to invocations of library functions that are
6060
assumed to exist.
6161

62+
## The `no_sanitize` attribute
63+
64+
The `no_sanitize` attribute can be used to selectively disable sanitizer
65+
instrumentation in an annotated function. This might be useful to: avoid
66+
instrumentation overhead in a performance critical function, or avoid
67+
instrumenting code that contains constructs unsupported by given sanitizer.
68+
69+
The precise effect of this annotation depends on particular sanitizer in use.
70+
For example, with `no_sanitize(thread)`, the thread sanitizer will no longer
71+
instrument non-atomic store / load operations, but it will instrument atomic
72+
operations to avoid reporting false positives and provide meaning full stack
73+
traces.
74+
75+
``` rust
76+
#[no_sanitize(address)]
77+
fn foo() {
78+
// ...
79+
}
80+
```
81+
6282
## The `target_feature` attribute
6383

6484
r[attributes.codegen.target_feature]

0 commit comments

Comments
 (0)