| Crates.io | sanitizers |
| lib.rs | sanitizers |
| version | 0.0.11 |
| created_at | 2024-02-16 18:53:08.769253+00 |
| updated_at | 2024-11-22 09:01:07.394164+00 |
| description | Interfaces and FFI bindings for the sanitizers interfaces |
| homepage | https://github.com/rcvalle/rust-crate-sanitizers |
| repository | https://github.com/rcvalle/rust-crate-sanitizers |
| max_upload_size | |
| id | 1142719 |
| size | 224,074 |
Interfaces and FFI bindings for the sanitizers interfaces.
To install the sanitizers crate:
On a command prompt or terminal with your package root's directory as the current working directory, run the following command:
cargo add sanitizers
Or:
Add the sanitizers crate to your package root's Cargo.toml file and
replace X.Y.Z by the version you want to install:
[dependencies]
sanitizers = "X.Y.Z"
On a command prompt or terminal with your package root's directory as the current working directory, run the following command:
cargo fetch
To use the sanitizers crate:
Import the sanitizer module or funtions from the sanitizers crate. E.g.:
use sanitizers::asan::*;
Use the provided interface for the sanitizer. E.g.:
...
let mut data = vec![0u8; 100];
let data_ptr = data.as_mut_ptr() as *const c_void;
// Poison the memory region
unsafe {
__asan_poison_memory_region(data_ptr, data.len());
}
// Check if the memory region is poisoned
let is_poisoned = unsafe { __asan_address_is_poisoned(data_ptr) };
assert_eq!(is_poisoned, 1);
...
Build your package with the sanitizer enabled. It is recommended to rebuild
the standard library with the sanitizer enabled by using the Cargo build-std
feature (i.e., -Zbuild-std) when enabling the sanitizer. E.g.:
RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=lld -Zsanitizer=address" \
cargo build -Zbuild-std -Zbuild-std-features \
--target x86_64-unknown-linux-gnu
See CONTRIBUTING.md.
Licensed under the Apache License, Version 2.0 or the MIT License. See LICENSE-APACHE or LICENSE-MIT for license text and copyright information.