4

Our clang++ build of executables with undefined behavior sanitizer works fine for executables when compiled as follows:

ccache clang++ -Qunused-arguments -fcolor-diagnostics -c -MMD -MP -std=c++11 --O1 -g3 -fPIC -fsanitize=address,undefined -fno-omit-frame-pointer -I /usr/lib/jvm/java-8-openjdk-amd64/include -I /usr/lib/jvm/java-8-openjdk-amd64/include/linux -o native/instrumen.o native/instrument.cpp

And linked to an executable as follows:

ccache clang++ -Qunused-arguments -fcolor-diagnostics -fsanitize=address,undefined -o cegis -Wl,--start-group native/instrument.o -Wl,--end-group

However, if we link it in a shared library as follows:

ccache clang++ -Qunused-arguments -fcolor-diagnostics -fsanitize=address,undefined -shared -o libsynth4j.so native/synth4j.o native/instrument.o ../lib/libinfo.a

We get the following error when trying to load the library from Java using JNI:

libsynth4j.so: undefined symbol: __ubsan_vptr_type_cache

Are there any additional considerations when creating shared libraries instead of executables using the clang undefined behaviour sanitizer? Our clang++ version is 3.7 running on Ubuntu Linux.

Pascal Kesseli
  • 1,620
  • 1
  • 21
  • 37
  • a workaround for the error (based on https://stackoverflow.com/a/50621267/104453) is to to preload the shared library with the symbol: `LD_PRELOAD=$(clang -print-file-name=libclang_rt.ubsan_standalone-x86_64.so)` – marcin Mar 19 '21 at 18:19

0 Answers0