Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined reference to '_asan_init_v4' when compiling

When linking my code compiled with the AddressSanitizer tool, I'm getting many errors of the kind undefined reference to '_asan_init_v4'.

clang -fPIC -g -fno-omit-frame-pointer -DNDEBUG -Wl,-z,defs \
  -shared -Wl,-soname,libqpid-dispatch.so -o libqpid-dispatch.so \
  CMakeFiles/qpid-dispatch.dir/alloc_pool.c.o \
  CMakeFiles/qpid-dispatch.dir/amqp.c.o \
  [...]
  -lpthread -lrt -ldl -lpython3.7m -lwebsockets -fsanitize=address

Some examples of the errors

/nix/store/1zf4cnaaidjajwb4gx4mnkqc5dypkcdy-binutils-2.31.1/bin/ld: CMakeFiles/qpid-dispatch.dir/http-libwebsockets.c.o: in function `qd_http_server_free':
/home/jdanek/repos/qpid/qpid-dispatch/src/http-libwebsockets.c:824: undefined reference to `__ubsan_handle_type_mismatch_v1'
/nix/store/1zf4cnaaidjajwb4gx4mnkqc5dypkcdy-binutils-2.31.1/bin/ld: /home/jdanek/repos/qpid/qpid-dispatch/src/http-libwebsockets.c:825: undefined reference to `__ubsan_handle_type_mismatch_v1'
/nix/store/1zf4cnaaidjajwb4gx4mnkqc5dypkcdy-binutils-2.31.1/bin/ld: /home/jdanek/repos/qpid/qpid-dispatch/src/http-libwebsockets.c:825: undefined reference to `__ubsan_handle_type_mismatch_v1'
/nix/store/1zf4cnaaidjajwb4gx4mnkqc5dypkcdy-binutils-2.31.1/bin/ld: /home/jdanek/repos/qpid/qpid-dispatch/src/http-libwebsockets.c:825: undefined reference to `__ubsan_handle_type_mismatch_v1'
/nix/store/1zf4cnaaidjajwb4gx4mnkqc5dypkcdy-binutils-2.31.1/bin/ld: /home/jdanek/repos/qpid/qpid-dispatch/src/http-libwebsockets.c:825: undefined reference to `__ubsan_handle_type_mismatch_v1'
/nix/store/1zf4cnaaidjajwb4gx4mnkqc5dypkcdy-binutils-2.31.1/bin/ld: /home/jdanek/repos/qpid/qpid-dispatch/src/http-libwebsockets.c:825: undefined reference to `__asan_report_load8'
/nix/store/1zf4cnaaidjajwb4gx4mnkqc5dypkcdy-binutils-2.31.1/bin/ld: /home/jdanek/repos/qpid/qpid-dispatch/src/http-libwebsockets.c:825: undefined reference to `__asan_report_load8'

Note: I am using NixOS 19.09 and Clang 10.

like image 287
vamshi Avatar asked Feb 27 '17 09:02

vamshi


1 Answers

You should be using the compile flag -fsanitize=address: https://github.com/google/sanitizers/wiki/AddressSanitizer

Note that -fsanitize=address = -lasan + some add'l options. And using -lasan has been discouraged by ASan developers.

like image 110
BoltzmannBrain Avatar answered Nov 13 '22 21:11

BoltzmannBrain