Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OMPT] Linking with libraries that provide "RunningOnValgrind" symbols causes "Unable to find TSan function" messages #122319

Open
paulfloyd opened this issue Jan 9, 2025 · 0 comments
Labels
openmp:libomptarget OpenMP offload runtime

Comments

@paulfloyd
Copy link

paulfloyd commented Jan 9, 2025

Off-topic remark. I'm a bit baffled as to why TSAN has a "RunningOnValgrind" that doesn't do what it says (it doesn't detect that the exe is running on Valgrind, it just looks at the TSAN_OPTIONS).

The app that I'm working on uses Google Perftools tcmallloc. I'm doing some tests with LLVM OMP.

When I run our exe I get

Unable to find TSan function AnnotateHappensAfter.
Unable to find TSan function AnnotateHappensBefore.
Unable to find TSan function AnnotateIgnoreWritesBegin.
Unable to find TSan function AnnotateIgnoreWritesEnd.
Unable to find TSan function AnnotateNewMemory.
Unable to find TSan function __tsan_func_entry.
Unable to find TSan function __tsan_func_exit.
Warning: please export TSAN_OPTIONS='ignore_noninstrumented_modules=1' to avoid false positive reports from the OpenMP runtime!

This is similar to issue #93524

This is because you are checking for TSAN with a function called "RunningOnValgrind". However, tcmalloc, with which our exe links statically, also contains a "RunningOnValgrind".

I'm doing a test, trying to use "_tsan_init" rather than "RunningOnValgrind".

So far, just a few tests, but it looks OK. A non-TSAN exe no longer prints the warnings. And a TSAN exe still does TSAN checks.

diff --git a/openmp/tools/archer/ompt-tsan.cpp b/openmp/tools/archer/ompt-tsan.cpp
index d7658077e83a..6cc8e370eb34 100644
--- a/openmp/tools/archer/ompt-tsan.cpp
+++ b/openmp/tools/archer/ompt-tsan.cpp
@@ -167,8 +167,8 @@ DECLARE_TSAN_FUNCTION(AnnotateNewMemory, const char *, int,
 DECLARE_TSAN_FUNCTION(__tsan_func_entry, const void *)
 DECLARE_TSAN_FUNCTION(__tsan_func_exit)
 
-// RunningOnValgrind is used to detect absence of TSan and must intentionally be a nullptr.
-static int (*RunningOnValgrind)(void);
+// __tsan_init is used to detect absence of TSan and must intentionally be a nullptr.
+static void (*__tsan_init)(void);
 }
 
 // This marker is used to define a happens-before arc. The race detector will
@@ -1252,12 +1252,12 @@ ompt_start_tool(unsigned int omp_version, const char *runtime_version) {
 
   // The OMPT start-up code uses dlopen with RTLD_LAZY. Therefore, we cannot
   // rely on dlopen to fail if TSan is missing, but would get a runtime error
-  // for the first TSan call. We use RunningOnValgrind to detect whether
+  // for the first TSan call. We use __tsan_init to detect whether
   // an implementation of the Annotation interface is available in the
   // execution or disable the tool (by returning NULL).
 
-  findTsanFunctionSilent(RunningOnValgrind, (int (*)(void)));
-  if (!RunningOnValgrind) // if we are not running on TSAN, give a different
+  findTsanFunctionSilent(__tsan_init, (void (*)(void)));
+  if (!__tsan_init) // if we are not running on TSAN, give a different
                           // tool the chance to be loaded
   {
     if (archer_flags->verbose)
@EugeneZelenko EugeneZelenko added openmp:libomptarget OpenMP offload runtime and removed new issue labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomptarget OpenMP offload runtime
Projects
None yet
Development

No branches or pull requests

3 participants