How to build a clang memory sanitizer instrumented version of gRPC?

84 views
Skip to first unread message

Mark Andrews

unread,
Sep 24, 2020, 3:27:59 PM9/24/20
to grpc.io
I would like to instrument some c++ code that uses grpc (clang 9, ubuntu 18) with memory sanitizer, and to do this, all the libraries it uses must be built with msan too.

from the  memory sanitizer docs :

```
It is critical that you should build all the code in your program (including libraries it uses, in particular, C++ standard library) with MSan. See MemorySanitizerLibcxxHowTo for more details.  
```

However, I have so far not succeeded in building msan instrumented grpc, and would appreciate some help on how to do this. 

I was able to build address sanitized grpc simply by setting CONFIG=asan in the supplied Makefile, but this does not work with CONFIG=msan (plus adding instrumented libc++.so and libc++abi.so as described in docs)

cmake doesn't seem to have any options to turn on MSAN, and I'm not familiar with bazel.

Wondering how to build MSAN instrumented grpc? 

thanks in advance!

yas...@google.com

unread,
Oct 1, 2020, 3:05:43 PM10/1/20
to grpc.io
Our current test infrastructure uses bazel for msan tests but earlier we were using Makefile with `CONFIG=msan` which is why I'm surprised that it did not work for you.

Mark Andrews

unread,
Oct 3, 2020, 8:43:10 AM10/3/20
to grpc.io
The issue I run into is some sort of versioning problem:

$ clang --version
clang version 9.0.0-2~ubuntu18.04.2 (tags/RELEASE_900/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin


but running make on the Makefile with `CONFIG=msan` fails during probobuf build with:

checking zlib version... ok (1.2.0.4 or later)
checking for library containing zlibVersion... no
checking whether clang++ supports C++11 features by default... no
checking whether clang++ supports C++11 features with -std=c++11... no
checking whether clang++ supports C++11 features with +std=c++11... no
checking whether clang++ supports C++11 features with -h std=c++11... no
checking whether clang++ supports C++11 features with -std=c++0x... no
checking whether clang++ supports C++11 features with +std=c++0x... no
checking whether clang++ supports C++11 features with -h std=c++0x... no
configure: error: *** A compiler with support for C++11 language features is required.
Makefile:794: recipe for target '/var/dev/github/grpc/libs/msan/protobuf/libprotobuf.a' failed
make: *** [/var/dev/github/grpc/libs/msan/protobuf/libprotobuf.a] Error 1

searching around brought up some old posts that might be related, e.g.:


Reply all
Reply to author
Forward
0 new messages