intrigued_66
intrigued_66

Reputation: 17258

undefined symbol: __asan_option_detect_stack_use_after_return

I'm trying to compile C++ using clang's address sanitizer to output the sanitize results within a core dump, so I added:

CXXFLAGS += -fsanitize=address

to have the compiler options:

/opt/llvm-3.8.0/bin/clang++ \
  --gcc-toolchain=/opt/gcc-5.2.0 -fsanitize=address -DLINUX \
  -DLINUX64 -DTB_USE_RCU -DURCU_INLINE_SMALL_FUNCTIONS \
  -DU_USING_ICU_NAMESPACE=0 -DNDEBUG -D_POSIX_PTHREAD_SEMANTICS \
  -fPIC -D_GNU_SOURCE -DTB_USE_RCU -DTB_USE_RCU \
  -D_GLIBCXX_USE_CXX11_ABI=0 -m64 --gcc-toolchain=/opt/gcc-5.2.0 \
  -flto=full -std=gnu++14 -D_GLIBCXX_DEPRECATED= -pipe \
  -fno-omit-frame-pointer -ffast-math -fno-finite-math-only \
  -pthread -march=core2 -mtune=corei7 -g -O3 -Qunused-arguments \
  -fnon-call-exceptions -fvisibility=hidden \
  -fvisibility-inlines-hidden -Wall -Wextra -Wshadow \
  -Wpointer-arith -Wno-self-assign -Wno-unused-function \
  -Wno-gnu-empty-initializer -Wno-unused-parameter \
  -Wno-ignored-qualifiers -Wno-mismatched-tags \
  -Wno-unused-local-typedef -Wno-parentheses-equality \
  -Wno-unused-private-field -Wno-missing-field-initializers \
  -Wno-missing-braces -Werror=return-type \
  -Werror=overloaded-virtual -c MyClass.cpp -o MyClass.o

but I get the error:

undefined symbol: __asan_option_detect_stack_use_after_return

What's the simplest way to resolve this?

Upvotes: 18

Views: 14361

Answers (1)

Xiangyu Meng
Xiangyu Meng

Reputation: 31

The executable need to link against the static ASAN library, should be done by, looks like you are using ld rather than clang for linking job. Check here.

-fsanitize=address -static-libasan

If you use cmake, it will be look like:

CXXFLAGS += -fsanitize=address -static-libasan
LDFLAGS += -fsanitize=address -static-libasan

Refer to this blog.

Upvotes: 0

Related Questions