Hi All,
OS: RHEL7 (x86_64 GNU/Linux)
Kernal: 3.10.0-123.8.1.el7.x86_64
Compiler: gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)
RAM: 24 GB
Our product contains shared libraries, archive libraries, java programs (jars) and many executable (c, c++, java).
Our aim is to evaluate the value of Tsan (thread sanitizer) for our product and find concurrency issues.
Therefore, we have built all shared libraries and executable (c, c++) with tsan enabled as follows:
Compile flags: -fsanitize=thread -g
Shared library linking flags: -fsanitize=thread -shared -lpthread -ldl
Executable linking flags: -fsanitize=thread -pie -lpthread -ldl
Note: We have also linked "-ltsan" wherever required.
In addition, we have
built object files associated with archive library with "-fPIC" to fix following type of compilation error.
/bin/ld: something.a(something.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
After compiling all necessary modules with tsan enabled:
When we execute tests (executable) that uses other executable (c, c++) and shared libraries, tsan reports gets generated without any issue.
However, when we execute "main" product which uses shared libraries, archive libraries, java programs (jars) and many executable (c, c++, java) then it shows following "well-known" error message.
FATAL: ThreadSanitizer can not mmap the shadow memory (something is mapped at 0x400000 < 0x7cf000000000)
FATAL: Make sure to compile with -fPIE and to link with -pie.
We have further analyzed but unable to find any root cause.
However, our product have several shared libraries which it access through JNI.
We feel that shared libraries compiled with tsan and access through JNI might cause this issue.
We have also found issue (not similar but close enough)
https://github.com/google/sanitizers/issues/386 related to address sanitizer.
Please let us know your suggestion and some pointers to resolve shadow memory issue.
Kindly let us know if you need any further information.