ASan is incompatible with Rust's jemalloc on Travis
In helping to debug https://trac.torproject.org/projects/tor/ticket/25386 I've found that many of the segfaults at runtime are attributable to Rust pulling in jemalloc by default for tests, which apparently doesn't play well with ASan when linked in.
I've found that using code like:
#[global_allocator] static ALLOCATOR: std::alloc::System = std::alloc::System;
is enough to solve the problem. This tells Rust that it should use the system allocator (e.g. the malloc/free symbols) instead of jemalloc. This was stabilized very recently in Rust, though, so using it may not be so trivial!
In some local testing I was able to get away with adding the above declaration to the
tor_allocate crate for the most part, but crates like
smartlist don't already link to
tor_allocate and needed the above declaration with a
#[cfg(test)] as well. Once this was all added though I mostly no longer saw segfaults related to jemalloc and ASan