Linking error with Dataflow sanitizer

Hi everyone,

I am currently trying to compile a project with the Dataflow sanitizer.
I have recompiled the libcxx and other dependencies using the sanitizer and the libc++abi.

The libraries are linked dynamically but when I try to execute the binary I get the following error:
symbol lookup error: ./Variane_testharness: undefined symbol: dfs$_ZNKSt9exception4whatEv

The project is a verilog project that is translated to CPP with verilator.

Does anyone know how I can resolve this?

Cheers,
Floris

Removing the dfs$ prefix from the mangled name, the symbol that’s missing is std::exception::what(), which normally comes from libc++abi. Are you sure that libc++abi.so contains the dfsan-prefixed symbol and your link line order is correct?

On my machine:

$ ninja cxx cxxabi && nm lib/libc++abi.so.1.0 | grep exception | grep what
000000000011cd60 T dfs$_ZNKSt13bad_exception4whatEv
000000000011cc90 T dfs$_ZNKSt9exception4whatEv

Hi Mitch,

I checked the lib and the symbols seem to be present:

$ nm /usr/local/lib/libc++.so.1.0 | grep exception | grep what
0000000000236554 T dfs$_ZNKSt13bad_exception4whatEv
0000000000236538 T dfs$_ZNKSt9exception4whatEv

What should be the link order?

Unfortunately without more info (like the compile/link commands) I’d be unable to help - but it seems like you’re either linking the wrong libc++ implicitly, or your link line order doesn’t resolve the dependencies in the right way (example). You can eliminate the latter problem by linking with lld (-fuse-ld=lld), as IIRC it doesn’t have problems resolving out-of-order libraries. You might also find clang’s verbose mode (-v) useful to find the linker invocation, and can use the linker’s verbose option (-Wl,-v if invoked through the clang driver) to determine which libc++ you ended up trying to link with.