jbcoe
jbcoe

Reputation: 3921

Why does an address sanitized build of a C++ library give non-reproducible ASAN issues in libcxx classes?

When building with -fsanitize=address I sometimes see bad memory access issues from libc++ classes.

The errors do not appear to be repeatable from run-to-run and sometimes do not happen at all.

What is happening? How can I prevent this?

Upvotes: 2

Views: 388

Answers (1)

jbcoe
jbcoe

Reputation: 3921

"If libc++ containers cross from instrumented (rebuilt with ASan) to non-instrumented code, Address Sanitizer might report container overflow false positives."

If your program is linking with libraries built with libc++ without ASAN then you need to define _LIBCXX_HAS_NO_ASAN when building.

See Why does Xcode define _LIBCPP_HAS_NO_ASAN when creating an address-sanitized build?

Upvotes: 2

Related Questions