chore: support AddressSanitizer (ASan)
Summary
- chore: support AddressSanitizer (ASAN)
This adds support for ASAN both in rust code and core tarantool. To build with ASAN, simply run
# Build with --profile=asan and a few more special flags...
make build-asan
Keep in mind that ASAN-enabled executable lives in
target/x86_64-unknown-linux-gnu/asan/picodata
as opposed to
target/debug/picodata
Further reading
- https://github.com/japaric/rust-san
- https://github.com/rust-lang/cargo/issues/6375#issuecomment-444900324
- https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/sanitizer.html
Demos
diff --git a/src/main.cc b/src/main.cc
index f8938e68b..74f4cfc9e 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -638,10 +638,14 @@ print_help(const char *program)
puts("to see online documentation, submit bugs or contribute a patch.");
}
+static char volatile bytes[4];
+
extern "C"
int
tarantool_main(int argc, char **argv, void (*cb)(void *), void *cb_data)
{
+ *(volatile char * volatile)(&bytes[5]);
+
// Picodata forks the process and only the child runs tarantool_main.
// Therefore master_pid must be set here instead of the static memory,
// so that the resources are cleaned up at the end
diff --git a/src/cli/run.rs b/src/cli/run.rs
index eff78f69..987b191a 100644
--- a/src/cli/run.rs
+++ b/src/cli/run.rs
@@ -125,6 +125,9 @@ pub fn main(args: args::Run) -> ! {
std::process::exit(1);
}));
+ let xs = [0, 1, 2, 3];
+ let y = unsafe { *xs.as_ptr().offset(4) };
+
// Note that we don't really need to pass the `config` here,
// because it's stored in the global variable which we can
// access from anywhere. But we still pass it explicitly just
- Close #...
- Cherry-pick to: none / 24.4 / 24.3 / 24.2
- Docs follow-up: not necessary / new issue
Ref: #380
Edited by Dmitry Ivanov